blob: 9cacfda480f464e4253dbd0c3ea800bf7ee7a8cc [file] [log] [blame]
// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_VIEW_H_
#define CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_VIEW_H_
#include <map>
#include <memory>
#include <optional>
#include <string>
#include <vector>
#include "base/callback_list.h"
#include "base/gtest_prod_util.h"
#include "base/memory/raw_ptr.h"
#include "base/scoped_observation.h"
#include "base/task/cancelable_task_tracker.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "build/branding_buildflags.h"
#include "build/build_config.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/exclusive_access/exclusive_access_context.h"
#include "chrome/browser/ui/tabs/tab_renderer_data.h"
#include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
#include "chrome/browser/ui/translate/partial_translate_bubble_model.h"
#include "chrome/browser/ui/user_education/browser_user_education_interface.h"
#include "chrome/browser/ui/views/exclusive_access_bubble_views_context.h"
#include "chrome/browser/ui/views/frame/browser_view_layout.h"
#include "chrome/browser/ui/views/frame/browser_widget.h"
#include "chrome/browser/ui/views/frame/contents_container_view.h"
#include "chrome/browser/ui/views/frame/contents_web_view.h"
#include "chrome/browser/ui/views/frame/immersive_mode_controller.h"
#include "chrome/browser/ui/views/frame/tab_strip_region_view.h"
#include "chrome/browser/ui/views/intent_picker_bubble_view.h"
#include "chrome/browser/ui/views/omnibox/omnibox_popup_closer.h"
#include "chrome/browser/ui/views/tabs/tab.h"
#include "chrome/browser/ui/webui/tab_search/tab_search.mojom.h"
#include "chrome/common/buildflags.h"
#include "components/enterprise/buildflags/buildflags.h"
#include "components/infobars/core/infobar_container.h"
#include "components/user_education/common/feature_promo/feature_promo_handle.h"
#include "components/webapps/browser/banners/app_banner_manager.h"
#include "content/public/browser/page_user_data.h"
#include "content/public/browser/permission_controller.h"
#include "content/public/browser/permission_result.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h"
#include "third_party/blink/public/common/permissions/permission_utils.h"
#include "ui/base/accelerators/accelerator.h"
#include "ui/base/metadata/metadata_header_macros.h"
#include "ui/base/mojom/window_show_state.mojom-forward.h"
#include "ui/base/pointer/touch_ui_controller.h"
#include "ui/gfx/native_ui_types.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/controls/webview/unhandled_keyboard_event_handler.h"
#include "ui/views/widget/widget_delegate.h"
#include "ui/views/widget/widget_observer.h"
#include "ui/views/window/client_view.h"
#if BUILDFLAG(IS_CHROMEOS)
#include "ui/compositor/compositor_metrics_tracker.h"
#endif
// NOTE: For more information about the objects and files in this directory,
// view: http://dev.chromium.org/developers/design-documents/browser-window
class AccessibilityFocusHighlight;
class BookmarkBarController;
class BookmarkBarView;
class Browser;
class ContentsContainerView;
class ContentsLayoutManager;
struct DropData;
class ExclusiveAccessBubbleViews;
class InfoBarContainerView;
class LocationBarView;
class MultiContentsView;
class ScrimView;
class SidePanel;
class TabDragDelegate;
class TabSearchBubbleHost;
class TabStrip;
class TabStripViewInterface;
class ToolbarButtonProvider;
class ToolbarView;
class TopContainerLoadingBar;
class TopContainerView;
class TopControlsSlideController;
class TopControlsSlideControllerTest;
class VerticalTabStripRegionView;
class WebAppFrameToolbarView;
class WebUITabStripContainerView;
namespace gfx {
class AnimationRunner;
} // namespace gfx
namespace ui {
class NativeTheme;
} // namespace ui
namespace version_info {
enum class Channel;
}
namespace views {
class WebView;
} // namespace views
namespace webapps {
enum class InstallableWebAppCheckResult;
struct WebAppBannerData;
} // namespace webapps
///////////////////////////////////////////////////////////////////////////////
// BrowserView
//
// A ClientView subclass that provides the contents of a browser window,
// including the TabStrip, toolbars, download shelves, the content area etc.
//
class BrowserView : public BrowserWindow,
public TabStripModelObserver,
public ui::AcceleratorProvider,
public views::WidgetDelegate,
public views::WidgetObserver,
public content::WebContentsObserver,
public views::ClientView,
public infobars::InfoBarContainer::Delegate,
public ExclusiveAccessContext,
public ExclusiveAccessBubbleViewsContext,
public ImmersiveModeController::Observer,
public webapps::AppBannerManager::Observer,
public views::FocusChangeListener {
METADATA_HEADER(BrowserView, views::ClientView)
public:
// The width of the vertical tab strip.
static constexpr int kVerticalTabStripWidth = 240;
explicit BrowserView(Browser* browser);
BrowserView(const BrowserView&) = delete;
BrowserView& operator=(const BrowserView&) = delete;
~BrowserView() override;
void set_browser_widget(std::unique_ptr<BrowserWidget> widget) {
browser_widget_ = std::move(widget);
paint_as_active_subscription_ =
browser_widget_->RegisterPaintAsActiveChangedCallback(
base::BindRepeating(&BrowserView::PaintAsActiveChanged,
base::Unretained(this)));
}
BrowserWidget* browser_widget() const { return browser_widget_.get(); }
// Returns a pointer to the BrowserView* interface implementation (an
// instance of this object, typically) for a given native window, or null if
// there is no such association.
//
// Don't use this unless you only have a NativeWindow. In nearly all
// situations plumb through browser and use it.
static BrowserView* GetBrowserViewForNativeWindow(gfx::NativeWindow window);
// Returns the BrowserView used for the specified Browser.
static BrowserView* GetBrowserViewForBrowser(
const BrowserWindowInterface* browser);
// After calling RevealTabStripIfNeeded(), there is normally a delay before
// the tabstrip is hidden. Tests can use this function to disable that delay
// (and hide immediately).
static void SetDisableRevealerDelayForTesting(bool disable);
bool IsLoadingAnimationRunning() const;
// Returns a Browser instance of this view.
Browser* browser() { return browser_; }
const Browser* browser() const { return browser_; }
const TopControlsSlideController* top_controls_slide_controller() const {
return top_controls_slide_controller_.get();
}
// Returns the constraining bounding box that should be used to lay out the
// FindBar within. This is _not_ the size of the find bar, just the bounding
// box it should be laid out within. The coordinate system of the returned
// rect is in the coordinate system of the frame, since the FindBar is a child
// window.
gfx::Rect GetFindBarBoundingBox() const;
// Returns the preferred height of the TabStrip. Used to position the
// incognito avatar icon.
int GetTabStripHeight() const;
// Returns the preferred size of the Web App Frame Toolbar. Used for example
// to determine the height of the title bar.
// Returns an empty size if this browser is not for a web app.
gfx::Size GetWebAppFrameToolbarPreferredSize() const;
// Returns all the ContentsContainerViews that belong to this browser.
std::vector<ContentsContainerView*> GetContentsContainerViews();
// Returns the ContentsContainerView for the active tab.
ContentsContainerView* GetActiveContentsContainerView();
// Returns the ContentsContainerView that corresponds to `web_contents`.
// Returns nullptr if there isn't a corresponding ContentsContainerView.
ContentsContainerView* GetContentsContainerViewFor(
content::WebContents* web_contents);
// Container for the tabstrip, toolbar, etc.
TopContainerView* top_container() { return top_container_; }
#if BUILDFLAG(IS_MAC)
views::Widget* overlay_widget() { return overlay_widget_.get(); }
const views::Widget* overlay_widget() const { return overlay_widget_.get(); }
views::View* overlay_view() { return overlay_view_tracker_.view(); }
const views::View* overlay_view() const {
return overlay_view_tracker_.view();
}
views::Widget* tab_overlay_widget() { return tab_overlay_widget_.get(); }
const views::Widget* tab_overlay_widget() const {
return tab_overlay_widget_.get();
}
views::View* tab_overlay_view() { return tab_overlay_view_.get(); }
const views::View* tab_overlay_view() const {
return tab_overlay_view_.get();
}
// Returns if this browser view will use immersive fullscreen mode, based
// on the state of the two relevant base::Features, as well as the type of
// browser this is a view for.
bool UsesImmersiveFullscreenMode() const;
// Returns if this browser view will use immersive fullscreen tabbed mode.
// In tabbed mode the tab strip is contained within the window's titlebar. In
// non-tabbed mode the tab strip is positioned below the titlebar.
// The return value is determined based on the state of
// `features::kImmersiveFullscreen` as well as the type of browser.
bool UsesImmersiveFullscreenTabbedMode() const;
#endif
// Container for the web contents.
views::View* contents_container() { return contents_container_; }
views::View* main_container() { return main_container_; }
SidePanel* contents_height_side_panel() {
return contents_height_side_panel_;
}
MultiContentsView* multi_contents_view() { return multi_contents_view_; }
TabStripViewInterface* tab_strip_view() const {
return tab_strip_region_view_.get();
}
VerticalTabStripRegionView* vertical_tab_strip_region_view() const {
return vertical_tab_strip_container_;
}
// Accessor for the TabStrip.
TabStrip* tabstrip() { return tab_strip_region_view_->tab_strip(); }
// Accessor for the WebUI tab strip.
WebUITabStripContainerView* webui_tab_strip() { return webui_tab_strip_; }
// Accessor for the Toolbar.
const ToolbarView* toolbar() const { return toolbar_; }
ToolbarView* toolbar() { return toolbar_; }
// Bookmark bar may be null, for example for pop-ups.
BookmarkBarView* bookmark_bar() { return bookmark_bar_view_.get(); }
// Returns the do-nothing view which controls the z-order of the find bar
// widget relative to views which paint into layers and views which have an
// associated NativeView. The presence / visibility of this view is not
// indicative of the visibility of the find bar widget or even whether
// FindBarController is initialized.
View* find_bar_host_view() { return find_bar_host_view_; }
// Accessor for the InfobarContainer.
InfoBarContainerView* infobar_container() { return infobar_container_; }
// Accessor for the FullscreenExitBubbleViews.
ExclusiveAccessBubbleViews* exclusive_access_bubble() {
return exclusive_access_bubble_.get();
}
// Accessors for the contents WebView.
// Will return the single active contents view. If side by side is enabled,
// it may make more sense to use GetAllVisibleContentsWebViews() depending on
// the use case.
ContentsWebView* contents_web_view() {
return static_cast<ContentsWebView*>(GetContentsView());
}
ScrimView* window_scrim_view() { return window_scrim_view_; }
base::WeakPtr<BrowserView> GetAsWeakPtr() {
return weak_ptr_factory_.GetWeakPtr();
}
// Accessor for the BrowserView's TabSearchBubbleHost instance.
TabSearchBubbleHost* GetTabSearchBubbleHost();
// Returns true if the top UI are visible on screen.
bool GetTabStripVisible() const;
// Returns true if the top UI should be drawn.
// On macOS, it is possible that the top UI is drawn but hidden.
bool ShouldDrawTabStrip() const;
// Returns true if the profile associated with this Browser window is
// incognito.
bool GetIncognito() const;
// Returns true if the profile associated with this Browser window is
// a guest session.
bool GetGuestSession() const;
// Returns true if the profile associated with this Browser window is
// not incognito or a guest session.
bool GetRegularOrGuestSession() const;
// Provides the containing frame with the accelerator for the specified
// command id. This can be used to provide menu item shortcut hints etc.
// Returns true if an accelerator was found for the specified |cmd_id|, false
// otherwise.
bool GetAccelerator(int cmd_id, ui::Accelerator* accelerator) const;
// Returns true if the specificed |accelerator| is registered with this view.
bool IsAcceleratorRegistered(const ui::Accelerator& accelerator);
// Returns the active WebContents.
content::WebContents* GetActiveWebContents();
// Returns true if the Browser object associated with this BrowserView
// supports tabs, such as all normal browsers, and tabbed apps like terminal.
bool GetSupportsTabStrip() const;
// Returns true if the Browser object associated with this BrowserView is a
// normal window (i.e. a browser window, not an app or popup).
bool GetIsNormalType() const;
// Returns true if the Browser object associated with this BrowserView is a
// for an installed web app.
bool GetIsWebAppType() const;
// Returns true if the Browser object associated with this BrowserView is for
// a Picture in Picture window.
bool GetIsPictureInPictureType() const;
// Returns the document picture in picture options from |browser_|'s
// CreateParams.
std::optional<blink::mojom::PictureInPictureWindowOptions>
GetDocumentPictureInPictureOptions() const;
// Returns true if the top browser controls (a.k.a. top-chrome UIs) are
// allowed to slide up and down with the gesture scrolls on the current tab's
// page.
bool GetTopControlsSlideBehaviorEnabled() const;
// Returns the current shown ratio of the top browser controls.
float GetTopControlsSlideBehaviorShownRatio() const;
// Returns the widget for anchoring bubbles and dialogs.
// This returns BrowserWidget except on fullscreen macOS where the toolbar is
// hosted in an OverlayWidget.
views::Widget* GetWidgetForAnchoring();
// See ImmersiveModeController for description.
// TODO(crbug.com/427826289): Eliminate this accessor and pass
// ImmersiveModeController to dependent features during construction.
ImmersiveModeController* immersive_mode_controller();
const ImmersiveModeController* immersive_mode_controller() const;
// Returns true if the view has been initialized.
bool initialized() const { return initialized_; }
// Restores the focused view. This is also used to set the initial focus
// when a new browser window is created.
void RestoreFocus();
// Called during the widget's fullscreen state changes without going through
// FullscreenController. This method does any processing which was skipped.
void FullscreenStateChanging();
// Called after the widget's fullscreen state is changed without going through
// FullscreenController. This method does any processing which was skipped.
void FullscreenStateChanged();
// Sets the button provider for this BrowserView. Must be called before
// InitViews() which sets the ToolbarView as the default button provider.
void SetToolbarButtonProvider(ToolbarButtonProvider* provider);
ToolbarButtonProvider* toolbar_button_provider() {
return toolbar_button_provider_;
}
// Callback for listening for link-opening-from-gesture events (i.e. only
// those resulting from direct user action).
using OnLinkOpeningFromGestureCallback =
base::RepeatingCallback<void(WindowOpenDisposition)>;
using OnLinkOpeningFromGestureCallbackList =
base::RepeatingCallbackList<OnLinkOpeningFromGestureCallback::RunType>;
// Listens to the "link opened from gesture" event. Callback will be called
// when a link is opened from user interaction in the same browser window, but
// before the tabstrip is actually modified. Useful for doing certain types
// of animations (e.g. "flying link" animation in tablet mode).
base::CallbackListSubscription AddOnLinkOpeningFromGestureCallback(
OnLinkOpeningFromGestureCallback callback);
// Updates the variable keeping track of the borderless mode visibility, which
// together with the `window_management_permission_granted_` controls whether
// the title bar is shown or not.
void UpdateBorderlessModeEnabled();
// Returns true when an app's effective display mode is
// window-controls-overlay.
bool AppUsesWindowControlsOverlay() const;
// Returns true when an app's effective display mode is tabbed.
bool AppUsesTabbed() const;
// Returns true when an app's effective display mode is borderless.
bool AppUsesBorderlessMode() const;
// Returns whether any of the features enabling draggable regions is enabled.
bool AreDraggableRegionsEnabled() const;
// Returns true when the window controls overlay should be displayed instead
// of a full titlebar. This is only supported for desktop web apps.
bool IsWindowControlsOverlayEnabled() const;
// Enable or disable the window controls overlay and notify the browser frame
// view of the update.
void ToggleWindowControlsOverlayEnabled(base::OnceClosure done);
bool WidgetOwnedByAnchorContainsPoint(
const gfx::Point& point_in_browser_view_coords);
bool borderless_mode_enabled_for_testing() const {
return borderless_mode_enabled_;
}
bool window_management_permission_granted_for_testing() const {
return window_management_permission_granted_;
}
// Update the side panel's horizontal alignment when
// prefs::kSidePanelHorizontalAlignment is changed from the appearance
// settings page.
void UpdateSidePanelHorizontalAlignment();
void UpdateWebAppStatusIconsVisiblity();
// Getter for the `window.setResizable(bool)` state.
std::optional<bool> GetWebApiWindowResizable() const;
// Returns true if the browser is currently showing tabs in a split view.
bool IsInSplitView() const;
// Convenience method for fetching the element context for the window.
ui::ElementContext GetElementContext();
// BrowserWindow:
void Show() override;
void ShowInactive() override;
void Hide() override;
bool IsVisible() const override;
void SetBounds(const gfx::Rect& bounds) override;
void Close() override;
void Activate() override;
void Deactivate() override;
bool IsActive() const override;
void FlashFrame(bool flash) override;
ui::ZOrderLevel GetZOrderLevel() const override;
void SetZOrderLevel(ui::ZOrderLevel order) override;
gfx::NativeWindow GetNativeWindow() const override;
bool IsOnCurrentWorkspace() const override;
bool IsVisibleOnScreen() const override;
void SetTopControlsShownRatio(content::WebContents* web_contents,
float ratio) override;
bool DoBrowserControlsShrinkRendererSize(
const content::WebContents* contents) const override;
ui::NativeTheme* GetNativeTheme() override;
const ui::ThemeProvider* GetThemeProvider() const override;
const ui::ColorProvider* GetColorProvider() const override;
int GetTopControlsHeight() const override;
void SetTopControlsGestureScrollInProgress(bool in_progress) override;
std::vector<StatusBubble*> GetStatusBubbles() override;
void UpdateTitleBar() override;
void BookmarkBarStateChanged(
BookmarkBar::AnimateChangeType change_type) override;
void TemporarilyShowBookmarkBar(base::TimeDelta duration) override;
void UpdateDevTools(content::WebContents* inspected_web_contents) override;
bool CanDockDevTools() const override;
void UpdateLoadingAnimations(bool is_visible) override;
void SetStarredState(bool is_starred) override;
void OnActiveTabChanged(content::WebContents* old_contents,
content::WebContents* new_contents,
int index,
int reason) override;
void OnTabDetached(content::WebContents* contents, bool was_active) override;
void ZoomChangedForActiveTab(bool can_show_bubble) override;
gfx::Rect GetRestoredBounds() const override;
ui::mojom::WindowShowState GetRestoredState() const override;
gfx::Rect GetBounds() const override;
gfx::Size GetContentsSize() const override;
void SetContentsSize(const gfx::Size& size) override;
bool IsMaximized() const override;
bool IsMinimized() const override;
void Maximize() override;
void Minimize() override;
void Restore() override;
void OnWebApiWindowResizableChanged() override;
bool GetCanResize() override;
ui::mojom::WindowShowState GetWindowShowState() const override;
void EnterFullscreen(const url::Origin& origin,
ExclusiveAccessBubbleType bubble_type,
FullscreenTabParams fullscreen_tab_params) override;
void ExitFullscreen() override;
void UpdateExclusiveAccessBubble(
const ExclusiveAccessBubbleParams& params,
ExclusiveAccessBubbleHideCallback first_hide_callback) override;
bool IsExclusiveAccessBubbleDisplayed() const override;
void OnExclusiveAccessUserInput() override;
bool ShouldHideUIForFullscreen() const override;
bool IsFullscreen() const override;
bool IsFullscreenBubbleVisible() const override;
bool IsForceFullscreen() const override;
void SetForceFullscreen(bool force_fullscreen) override;
void UpdatePageActionIcon(PageActionIconType type) override;
autofill::AutofillBubbleHandler* GetAutofillBubbleHandler() override;
void ExecutePageActionIconForTesting(PageActionIconType type) override;
LocationBar* GetLocationBar() const override;
void SetFocusToLocationBar(bool is_user_initiated) override;
void UpdateReloadStopState(bool is_loading, bool force) override;
void UpdateToolbar(content::WebContents* contents) override;
bool UpdateToolbarSecurityState() override;
void UpdateCustomTabBarVisibility(bool visible, bool animate) override;
void SetDevToolsScrimVisibility(bool visible) override;
void ResetToolbarTabState(content::WebContents* contents) override;
void FocusToolbar() override;
ExtensionsContainer* GetExtensionsContainer() override;
void ToolbarSizeChanged(bool is_animating) override;
void TabDraggingStatusChanged(bool is_dragging) override;
void LinkOpeningFromGesture(WindowOpenDisposition disposition) override;
void FocusAppMenu() override;
void FocusBookmarksToolbar() override;
void FocusInactivePopupForAccessibility() override;
void RotatePaneFocus(bool forwards) override;
void FocusWebContentsPane() override;
bool IsBookmarkBarVisible() const override;
bool IsBookmarkBarAnimating() const override;
bool IsTabStripEditable() const override;
void SetTabStripNotEditableForTesting() override;
bool IsToolbarVisible() const override;
bool IsToolbarShowing() const override;
bool IsLocationBarVisible() const override;
bool IsBorderlessModeEnabled() const override;
void ShowChromeLabs() override;
views::WebView* GetContentsWebView() override;
BrowserView* AsBrowserView() override;
SharingDialog* ShowSharingDialog(content::WebContents* contents,
SharingDialogData data) override;
void ShowUpdateChromeDialog() override;
void ShowIntentPickerBubble(
std::vector<IntentPickerBubbleView::AppInfo> app_info,
bool show_stay_in_chrome,
bool show_remember_selection,
apps::IntentPickerBubbleType bubble_type,
const std::optional<url::Origin>& initiating_origin,
IntentPickerResponse callback) override;
void ShowBookmarkBubble(const GURL& url, bool already_bookmarked) override;
sharing_hub::ScreenshotCapturedBubble* ShowScreenshotCapturedBubble(
content::WebContents* contents,
const gfx::Image& image) override;
qrcode_generator::QRCodeGeneratorBubbleView* ShowQRCodeGeneratorBubble(
content::WebContents* contents,
const GURL& url,
bool show_back_button) override;
send_tab_to_self::SendTabToSelfBubbleView*
ShowSendTabToSelfDevicePickerBubble(content::WebContents* contents) override;
send_tab_to_self::SendTabToSelfBubbleView* ShowSendTabToSelfPromoBubble(
content::WebContents* contents,
bool show_signin_button) override;
#if BUILDFLAG(IS_CHROMEOS)
views::Button* GetSharingHubIconButton() override;
void ToggleMultitaskMenu() override;
#else
sharing_hub::SharingHubBubbleView* ShowSharingHubBubble(
share::ShareAttempt attempt) override;
#endif // BUILDFLAG(IS_CHROMEOS)
ShowTranslateBubbleResult ShowTranslateBubble(
content::WebContents* contents,
translate::TranslateStep step,
const std::string& source_language,
const std::string& target_language,
translate::TranslateErrors error_type,
bool is_user_gesture) override;
void StartPartialTranslate(const std::string& source_language,
const std::string& target_language,
const std::u16string& text_selection) override;
void ShowOneClickSigninConfirmation(
const std::u16string& email,
base::OnceCallback<void(bool)> confirmed_callback) override;
views::View* GetTopContainer() override;
views::View* GetLensOverlayView() override;
DownloadBubbleUIController* GetDownloadBubbleUIController() override;
void ConfirmBrowserCloseWithPendingDownloads(
int download_count,
Browser::DownloadCloseType dialog_type,
base::OnceCallback<void(bool)> callback) override;
void UserChangedTheme(BrowserThemeChangeType theme_change_type) override;
void ShowAppMenu() override;
content::KeyboardEventProcessingResult PreHandleKeyboardEvent(
const input::NativeWebKeyboardEvent& event) override;
void PreHandleDragUpdate(const content::DropData& drop_data,
const gfx::PointF& point) override;
void PreHandleDragExit() override;
void HandleDragEnded() override;
bool HandleKeyboardEvent(const input::NativeWebKeyboardEvent& event) override;
std::unique_ptr<FindBar> CreateFindBar() override;
web_modal::WebContentsModalDialogHost* GetWebContentsModalDialogHost()
override;
web_modal::WebContentsModalDialogHost* GetWebContentsModalDialogHostFor(
content::WebContents* web_contents) override;
void ShowAvatarBubbleFromAvatarButton(bool is_source_accelerator) override;
void MaybeShowProfileSwitchIPH() override;
void MaybeShowSupervisedUserProfileSignInIPH() override;
void ShowHatsDialog(
const std::string& site_id,
const std::optional<std::string>& hats_histogram_name,
const std::optional<uint64_t> hats_survey_ukm_id,
base::OnceClosure success_callback,
base::OnceClosure failure_callback,
const SurveyBitsData& product_specific_bits_data,
const SurveyStringData& product_specific_string_data) override;
ExclusiveAccessContext* GetExclusiveAccessContext() override;
std::string GetWorkspace() const override;
bool IsVisibleOnAllWorkspaces() const override;
void ShowEmojiPanel() override;
void ShowCaretBrowsingDialog() override;
std::unique_ptr<content::EyeDropper> OpenEyeDropper(
content::RenderFrameHost* frame,
content::EyeDropperListener* listener) override;
BookmarkBarView* GetBookmarkBarView() const;
LocationBarView* GetLocationBarView() const;
void ShowIncognitoClearBrowsingDataDialog() override;
void ShowIncognitoHistoryDisclaimerDialog() override;
bool IsTabModalPopupDeprecated() const override;
void SetIsTabModalPopupDeprecated(
bool is_tab_modal_popup_deprecated) override;
// TabStripModelObserver:
void OnTabStripModelChanged(
TabStripModel* tab_strip_model,
const TabStripModelChange& change,
const TabStripSelectionChange& selection) override;
void TabChangedAt(content::WebContents* contents,
int index,
TabChangeType change_type) override;
void OnSplitTabChanged(const SplitTabChange& change) override;
void TabStripEmpty() override;
void WillCloseAllTabs(TabStripModel* tab_strip_model) override;
void CloseAllTabsStopped(TabStripModel* tab_strip_model,
CloseAllStoppedReason reason) override;
// ui::AcceleratorProvider:
bool GetAcceleratorForCommandId(int command_id,
ui::Accelerator* accelerator) const override;
// views::WidgetDelegate:
bool CanResize() const override;
bool CanFullscreen() const override;
bool CanMaximize() const override;
bool CanActivate() const override;
std::u16string GetWindowTitle() const override;
std::u16string GetAccessibleWindowTitle() const override;
views::View* GetInitiallyFocusedView() override;
bool ShouldShowWindowTitle() const override;
bool ShouldShowWindowIcon() const override;
ui::ImageModel GetWindowAppIcon() override;
ui::ImageModel GetWindowIcon() override;
bool ExecuteWindowsCommand(int command_id) override;
std::string GetWindowName() const override;
bool ShouldSaveWindowPlacement() const override;
void SaveWindowPlacement(const gfx::Rect& bounds,
ui::mojom::WindowShowState show_state) override;
bool GetSavedWindowPlacement(
const views::Widget* widget,
gfx::Rect* bounds,
ui::mojom::WindowShowState* show_state) const override;
views::View* GetContentsView() override;
views::ClientView* CreateClientView(views::Widget* widget) override;
views::View* CreateOverlayView() override;
#if BUILDFLAG(IS_MAC)
views::View* CreateMacOverlayView();
#endif
void OnWindowBeginUserBoundsChange() override;
void OnWindowEndUserBoundsChange() override;
void OnWidgetMove() override;
views::Widget* GetWidget() override;
const views::Widget* GetWidget() const override;
void GetAccessiblePanes(std::vector<View*>* panes) override;
bool ShouldDescendIntoChildForEventHandling(
gfx::NativeView child,
const gfx::Point& location) override;
bool RotatePaneFocusFromView(views::View* focused_view,
bool forward,
bool enable_wrapping) override;
// views::WidgetObserver:
void OnWidgetDestroying(views::Widget* widget) override;
void OnWidgetActivationChanged(views::Widget* widget, bool active) override;
void OnWidgetBoundsChanged(views::Widget* widget,
const gfx::Rect& new_bounds) override;
void OnWidgetVisibilityChanged(views::Widget* widget, bool visible) override;
void OnWidgetShowStateChanged(views::Widget* widget) override;
void OnWidgetWindowModalVisibilityChanged(views::Widget* widget,
bool visible) override;
// content::WebContentsObserver:
void DidFirstVisuallyNonEmptyPaint() override;
void TitleWasSet(content::NavigationEntry* entry) override;
// views::ClientView:
views::CloseRequestResult OnWindowCloseRequested() override;
int NonClientHitTest(const gfx::Point& point) override;
gfx::Size GetMinimumSize() const override;
// infobars::InfoBarContainer::Delegate:
void InfoBarContainerStateChanged(bool is_animating) override;
// views::View:
void Layout(PassKey) override;
void OnGestureEvent(ui::GestureEvent* event) override;
void ViewHierarchyChanged(
const views::ViewHierarchyChangedDetails& details) override;
void AddedToWidget() override;
void RemovedFromWidget() override;
void PaintChildren(const views::PaintInfo& paint_info) override;
void OnThemeChanged() override;
bool GetDropFormats(int* formats,
std::set<ui::ClipboardFormatType>* format_types) override;
bool AreDropTypesRequired() override;
bool CanDrop(const ui::OSExchangeData& data) override;
void OnDragEntered(const ui::DropTargetEvent& event) override;
View* GetViewByElementId(ui::ElementIdentifier element_id) override;
const View* GetViewByElementId(
ui::ElementIdentifier element_id) const override;
// ui::AcceleratorTarget:
bool AcceleratorPressed(const ui::Accelerator& accelerator) override;
// ExclusiveAccessContext:
Profile* GetProfile() override;
void UpdateUIForTabFullscreen() override;
content::WebContents* GetWebContentsForExclusiveAccess() override;
bool CanUserEnterFullscreen() const override;
bool CanUserExitFullscreen() const override;
// ExclusiveAccessBubbleViewsContext:
ExclusiveAccessManager* GetExclusiveAccessManager() override;
ui::AcceleratorProvider* GetAcceleratorProvider() override;
gfx::NativeView GetBubbleParentView() const override;
gfx::Rect GetClientAreaBoundsInScreen() const override;
bool IsImmersiveModeEnabled() const override;
gfx::Rect GetTopContainerBoundsInScreen() override;
void DestroyAnyExclusiveAccessBubble() override;
// ImmersiveModeController::Observer:
void OnImmersiveRevealStarted() override;
void OnImmersiveRevealEnded() override;
void OnImmersiveFullscreenExited() override;
void OnImmersiveModeControllerDestroyed() override;
// webapps::AppBannerManager::Observer:
void OnInstallableWebAppStatusUpdated(
webapps::InstallableWebAppCheckResult result,
const std::optional<webapps::WebAppBannerData>& data) override;
// views::FocusChangeListener
void OnWillChangeFocus(View* focused_before, View* focused_now) override;
void OnDidChangeFocus(View* focused_before, View* focused_now) override;
// Creates an accessible tab label for screen readers that includes the tab
// status for the given tab index. This takes the form of
// "Page title - Tab state". The optional parameter `is_for_tab` can be set
// when getting the label for a tab (instead of a window). Titles for the
// window don't include less important messages like memory usage.
std::u16string GetAccessibleTabLabel(int index,
bool is_for_tab = false) const;
// Gets the string id to format a tab's accessible label if it is part of a
// split.
int GetAccessibleTabLabelFormatStringForSplit(
split_tabs::SplitTabLayout layout,
int tab_index_in_split) const;
// Gets the string id to format a tab's accessible label based on its tab
// alert.
int GetAccessibleTabLabelFormatStringForTabAlert(tabs::TabAlert alert) const;
// Testing interface:
views::View* GetContentsContainerForTest() { return contents_container_; }
views::View* GetSidePanelRoundedCornerForTesting() {
return side_panel_rounded_corner_;
}
// Returns all the NativeViewHosts attached to this BrowserView which should
// be transformed as part of the TopControlsSlide behavior with touch scroll
// gestures. These NativeViewHosts include the one hosting the active tab's\
// WebContents, and the one hosting the webui tabstrip contents (if the
// feature is enabled).
std::vector<views::NativeViewHost*> GetNativeViewHostsForTopControlsSlide();
using BrowserWindow::CreateTabSearchBubble;
void CreateTabSearchBubble(
tab_search::mojom::TabSearchSection section,
tab_search::mojom::TabOrganizationFeature organization_feature) override;
void CloseTabSearchBubble() override;
#if !BUILDFLAG(IS_CHROMEOS)
AccessibilityFocusHighlight* GetAccessibilityFocusHighlightForTesting() {
return accessibility_focus_highlight_.get();
}
#endif
// Returns the list of tab content's web views that is visible.
// It returns > 1 elements when there is a split view that is active.
std::vector<ContentsWebView*> GetAllVisibleContentsWebViews();
bool should_show_window_controls_overlay_toggle() const {
return should_show_window_controls_overlay_toggle_;
}
void SetLoadingAnimationStateChangeClosureForTesting(
base::OnceClosure closure);
WebAppFrameToolbarView* web_app_frame_toolbar_for_testing() {
return web_app_frame_toolbar();
}
// This value is used in a common calculation in FrameView
// subclasses. This must be added to the origin of the first painted pixel of
// FrameView to get the correct offset. See
// TopContainerBackground::PaintThemeCustomImage for details.
gfx::Point GetThemeOffsetFromBrowserView() const;
void UpdateAccessibleNameForAllTabs();
#if BUILDFLAG(ENTERPRISE_SCREENSHOT_PROTECTION)
void ApplyScreenshotSettings(bool allow);
#endif
// Clipboard commands.
void Cut();
void Copy();
void Paste();
// Returns a `TabDragHandler`, if any available, to handle a tab drag.
TabDragDelegate* GetTabDragDelegate(const gfx::Point& point_in_screen);
#if BUILDFLAG(IS_CHROMEOS)
// This is used only for SWA/PWA scenario.
void OnLockedForOnTaskUpdated();
bool IsLockedFullscreen() const;
#endif
protected:
// BrowserWindow:
void DeleteBrowserWindow() final;
private:
// Do not friend BrowserViewLayout. Use the BrowserViewLayoutDelegate
// interface to keep these two classes decoupled and testable.
friend class BrowserViewLayoutDelegateImplNew;
friend class BrowserViewLayoutDelegateImplOld;
friend class BrowserViewLayoutDelegateImplBrowsertest;
friend class TopControlsSlideControllerTest;
FRIEND_TEST_ALL_PREFIXES(BrowserViewTest, BrowserView);
FRIEND_TEST_ALL_PREFIXES(BrowserViewTest, AccessibleWindowTitle);
FRIEND_TEST_ALL_PREFIXES(PermissionChipUnitTest, AccessibleName);
class AccessibilityModeObserver;
// Sets or clears the flags to force showing bookmark bar.
void SetForceShowBookmarkBarFlag(BookmarkBarController::ForceShowFlag flag);
void ClearForceShowBookmarkBarFlag(BookmarkBarController::ForceShowFlag flag);
// Returns the state of the bookmark bar.
BookmarkBar::State bookmark_bar_state() const;
// Display the current active split view as a series of multiple side-by-side
// web contents.
void ShowSplitView(bool focus_active_view);
// Display only the current active tab's web contents, hiding any previous
// side-by-side display.
void HideSplitView();
// Update the index of the active split based on the active tab's web
// contents.
void UpdateActiveTabInSplitView();
// Updates the contents in the active split view.
void UpdateContentsInSplitView(
const std::vector<std::pair<tabs::TabInterface*, int>>& prev_tabs,
const std::vector<std::pair<tabs::TabInterface*, int>>& new_tabs);
// True if an activation from `old_contents` to `new_contents` happens between
// tabs that are already in a split-view configuration.
bool IsTabChangeInSplitView(content::WebContents* old_contents,
content::WebContents* new_contents);
void UpdateTabModalDialogHost();
// Updates stored focus for web contents that is being activated.
void MaybeUpdateStoredFocusForWebContents(content::WebContents*);
// Shared implementation by cut, copy and paste.
void CutCopyPaste(int command_id);
// If the browser is in immersive full screen mode, it will reveal the
// tabstrip for a short duration. This is useful for shortcuts that perform
// tab navigations and need to give users a visual clue as to what tabs are
// affected.
void RevealTabStripIfNeeded();
void OnVerticalTabStripStateChanged(
tabs::VerticalTabStripStateController* controller);
// Make sure the WebUI tab strip exists if it should.
void MaybeInitializeWebUITabStrip();
// Callback for the loading animation(s) associated with this view.
void LoadingAnimationTimerCallback();
void LoadingAnimationCallback(base::TimeTicks timestamp);
#if BUILDFLAG(IS_WIN)
// Creates the JumpList.
void CreateJumpList();
#endif
// Helper method, returns if we should show the IPHs anchored on the avatar
// toolbar.
bool ShouldShowAvatarToolbarIPH();
// Returns the frame view.
BrowserFrameView* GetFrameView();
const BrowserFrameView* GetFrameView() const;
// Returns the BrowserViewLayout.
BrowserViewLayout* GetBrowserViewLayout() const;
// Returns the ContentsLayoutManager.
ContentsLayoutManager* GetContentsLayoutManager() const;
// Prepare to show the Bookmark Bar for the specified WebContents.
// Returns true if the Bookmark Bar can be shown (i.e. it's supported for this
// Browser type) and there should be a subsequent re-layout to show it.
// |contents| can be null.
bool MaybeShowBookmarkBar(content::WebContents* contents);
// Prepare to show an Info Bar for the specified WebContents. Returns
// true if there is an Info Bar to show and one is supported for this Browser
// type, and there should be a subsequent re-layout to show it.
// |contents| can be null.
bool MaybeShowInfoBar(content::WebContents* contents);
// Prepare and update the split view for the specified WebContents. Returns
// true if split view is updated and needs a layout.
bool MaybeUpdateSplitView(content::WebContents* contents);
// Prepare and update devtools for the specified WebContents or any devtools
// in a split with the specified WebContents. Returns true if devtools is
// updated and needs a layout.
bool MaybeUpdateDevtools(content::WebContents* contents);
// Updates various optional child Views, e.g. Bookmarks Bar, Info Bar
// in response to a change notification from the specified
// |contents|. |contents| can be null. In this case, all optional UI will be
// removed.
void UpdateUIForContents(content::WebContents* contents);
// Returns the y coordinate of the client area.
int GetClientAreaTop();
// Invoked to prepare the transition of fullscreen state.
// If features::kAsyncFullscreenWindowState is disabled, this is invoked
// synchronously when requesting platform window state changes.
// If features::kAsyncFullscreenWindowState is enabled, this is invoked
// asynchronously when the platform window state change is observed.
// TODO(crbug.com/40276379): Deprecate the synchronous codepath.
void PrepareFullscreen(bool fullscreen);
// Invoked to update the necessary things when our fullscreen state changes
// to |fullscreen|. On Windows this is invoked immediately when we toggle the
// full screen node_data. On Linux changing the fullscreen node_data is async,
// so we
// ask the window to change its fullscreen node_data, then when we get
// notification that it succeeded this method is invoked.
// If the Window Placement experiment is enabled, fullscreen may be requested
// on a particular display. In that case, |display_id| is the display's id;
// otherwise, display::kInvalidDisplayId indicates no display is specified.
void ProcessFullscreen(bool fullscreen, int64_t display_id);
// Request the underlying platform to make the window fullscreen.
void RequestFullscreen(bool fullscreen, int64_t display_id);
void SynchronizeRenderWidgetHostVisualPropertiesForMainFrame();
void NotifyWidgetSizeConstraintsChanged();
// Copy the accelerator table from the app resources into something we can
// use.
void LoadAccelerators();
// Retrieves the command id for the specified Windows app command.
int GetCommandIDForAppCommandID(int app_command_id) const;
// Possibly records a user metrics action corresponding to the passed-in
// accelerator. Only implemented for Chrome OS, where we're interested in
// learning about how frequently the top-row keys are used.
void UpdateAcceleratorMetrics(const ui::Accelerator& accelerator,
int command_id);
// Shows the next app-modal dialog box, if there is one to be shown, or moves
// an existing showing one to the front.
void ActivateAppModalDialog() const;
// Retrieves the chrome command id associated with |accelerator|. The function
// returns false if |accelerator| is unknown. Otherwise |command_id| will be
// set to the chrome command id defined in //chrome/app/chrome_command_ids.h.
bool FindCommandIdForAccelerator(const ui::Accelerator& accelerator,
int* command_id) const;
// Updates AppBannerManager::Observer to observe |new_manager| exclusively.
void ObserveAppBannerManager(webapps::AppBannerManager* new_manager);
// Called by GetAccessibleWindowTitle, split out to make it testable.
std::u16string GetAccessibleWindowTitleForChannelAndProfile(
version_info::Channel,
Profile* profile) const;
// Reparents |top_container_| to be a child of |this| instead of
// |overlay_view_|.
void ReparentTopContainerForEndOfImmersive();
// Ensures that the correct focus order is set for child views, regardless of
// the actual child order.
void EnsureFocusOrder();
// Returns true when the window icon of this browser window can change based
// on the context. GetWindowIcon() method should return the same image if
// this returns false.
bool CanChangeWindowIcon() const;
// Searches for inactive bubbles anchored to elements in this browser view
// and activates them. It returns true if it succeeded activating a bubble or
// false otherwise.
bool ActivateFirstInactiveBubbleForAccessibility();
// Notifies that window bounds changed to extensions if needed.
void TryNotifyWindowBoundsChanged(const gfx::Rect& widget_bounds);
// Called when ui::TouchUiController changes the current touch mode.
void TouchModeChanged();
// Attempts to show in-product help for the reading list as moved into the
// side panel. Should be called when the IPH backend is initialized or
// whenever the touch mode changes.
void MaybeShowReadingListInSidePanelIPH();
// Attempts to show IPH promo for the tab search toolbar button.
void MaybeShowTabStripToolbarButtonIPH();
// Attempts showing the IPH promo listing benefits for signed-in users
// after the sync-to-signin migration.
void MaybeShowSignInBenefitsIPH();
void UpdateWindowControlsOverlayEnabled();
// Updates the visibility of the Window Controls Overlay toggle button.
void UpdateWindowControlsOverlayToggleVisible();
// Updates the variable keeping track of the Window Management permission,
// which together with borderless_mode_enabled_ controls whether the title bar
// is shown or not.
void UpdateWindowManagementPermission(content::PermissionResult result);
// Sets the callback which is called when the status of the Window Management
// permission changes.
void SetWindowManagementPermissionSubscriptionForBorderlessMode(
content::WebContents* web_contents);
WebAppFrameToolbarView* web_app_frame_toolbar();
const WebAppFrameToolbarView* web_app_frame_toolbar() const;
void PaintAsActiveChanged();
void FrameColorsChanged();
void UpdateAccessibleNameForRootView();
void UpdateAccessibleURLForRootView(const GURL& url);
// |allowed_without_policy| represents whether or not the browser is allowed
// to enter fullscreen, irrespective of policy. This is is necessary to
// prevent policy from incorrectly allowing the browser to enter fullscreen
// when it should not be able to.
void UpdateFullscreenAllowedFromPolicy(bool allowed_without_policy);
bool ShouldUseBrowserContentMinimumSize() const;
bool IsBrowserAWebApp() const;
// The BrowserWidget that owns this view.
std::unique_ptr<BrowserWidget> browser_widget_;
// The owning Browser object. `browser_` will outlive this.
const raw_ptr<Browser> browser_;
base::CallbackListSubscription chip_visibility_subscription_;
// BrowserView layout (LTR one is pictured here).
//
// --------------------------------------------------------------------
// | TopContainerView (top_container_) |
// | -------------------------------------------------------------- |
// | | Web App toolbar and title (web_app_frame_toolbar_) | |
// | |------------------------------------------------------------| |
// | | Tabs (tabstrip_) | |
// | |------------------------------------------------------------| |
// | | Navigation buttons, address bar, menu (toolbar_) | |
// | -------------------------------------------------------------- |
// |------------------------------------------------------------------|
// | Bookmarks (bookmark_bar_view_) |
// |------------------------------------------------------------------|
// | All infobars (infobar_container_) |
// |------------------------------------------------------------------|
// | Contents container (contents_container_) |
// | -------------------------------------------------------------- |
// | | contents_web_view_ (or multi_contents_view_ if defined) | |
// | -------------------------------------------------------------- |
// --------------------------------------------------------------------
// The view that manages the tab strip, toolbar, and sometimes the bookmark
// bar. Stacked top in the view hiearachy so it can be used to slide out
// the top views in immersive fullscreen.
raw_ptr<TopContainerView> top_container_ = nullptr;
// Menu button and page status icons. Only used by web-app windows.
raw_ptr<WebAppFrameToolbarView> web_app_frame_toolbar_ = nullptr;
// Normally the BrowserFrameView is responsible for rendering the title of a
// window when appropriate. However for web applications the title needs to be
// more integrated with other UI components part of BrowserView, so have a
// title Label for them here.
raw_ptr<views::Label> web_app_window_title_ = nullptr;
// The view that contains the tabstrip, new tab button, and grab handle space.
raw_ptr<TabStripRegionView> tab_strip_region_view_ = nullptr;
// the webui based tabstrip, when applicable. see https://crbug.com/989131.
raw_ptr<WebUITabStripContainerView> webui_tab_strip_ = nullptr;
// Allows us to react to changes in accessibility mode. Having an observer
// object allows for the browser to change mode if it enters or leaves
// accessibility mode.
std::unique_ptr<AccessibilityModeObserver> accessibility_mode_observer_;
// The Toolbar containing the navigation buttons, menus and the address bar.
raw_ptr<ToolbarView> toolbar_ = nullptr;
// The OverlayView for the widget, which is used to host `top_container_`
// during immersive reveal.
// On Aura, this view is owned by the browser frame. On mac, this view is
// owned by `overlay_widget_`.
views::ViewTracker overlay_view_tracker_;
#if BUILDFLAG(IS_MAC)
// Used when calling CreateMacOverlayView(). This widget owns `overlay_view_`.
// Its content NSView will be reparented to a NSToolbarFullScreenWindow
// during fullscreen.
raw_ptr<views::Widget, DanglingUntriaged> overlay_widget_ = nullptr;
// Also used when calling CreateMacOverlayView(). This widget will host the
// tabstrip contents. Its content NSView will be reparented to a separate
// section of the NSToolbarFullScreenWindow allowing for the tabs to live in
// the Titlebar.
raw_ptr<views::Widget, DanglingUntriaged> tab_overlay_widget_ = nullptr;
// The hosting view of TabStripRegionView during immersive fullscreen.
raw_ptr<views::View, DanglingUntriaged> tab_overlay_view_ = nullptr;
#endif
// The Bookmark Bar View for this window. Lazily created. May be null for
// non-tabbed browsers like popups. May not be visible.
std::unique_ptr<BookmarkBarView> bookmark_bar_view_;
std::unique_ptr<TabSearchBubbleHost> tab_search_bubble_host_;
// Separator between top container and contents.
// Note: when `SideBySide` feature is disabled, this separator is also
// used when not in `TopContainerOverlayView. Once the feature is fully
// rolled out, we can rely on `MultiContentsView` to manage the contents
// separator when not overlaid (i.e. no immersive fullscreen).
raw_ptr<views::View> top_container_separator_ = nullptr;
// Loading bar (part of top container for / WebUI tab strip).
raw_ptr<TopContainerLoadingBar> loading_bar_ = nullptr;
// The do-nothing view which controls the z-order of the find bar widget
// relative to views which paint into layers and views with an associated
// NativeView.
raw_ptr<View> find_bar_host_view_ = nullptr;
// The InfoBarContainerView that contains InfoBars for the current tab.
raw_ptr<InfoBarContainerView> infobar_container_ = nullptr;
// The view that contains all visible WebContents.
raw_ptr<MultiContentsView> multi_contents_view_ = nullptr;
// The view that contains the main views of the browser not added to top
// container (WebContents, SidePanel, DevTools, etc.).
// TODO(crbug.com/445446905): Eventually this should include all views other
// than the TabStripRegionView such as the Toolbar, BookmarksBar, and InfoBar.
raw_ptr<views::View> main_container_ = nullptr;
// The view that contains the Lens overlay. The Lens Overlay is a UI overlay
// that is shown on top of the web contents. It therefore must always have the
// same bounds as the contents_web_view_, but also be above the
// contents_web_view_.
raw_ptr<views::View> lens_overlay_view_ = nullptr;
// Handled by ContentsLayoutManager.
raw_ptr<views::View> contents_container_ = nullptr;
// The view that will replace |contents_container_| and manage devtools and
// contents positions as well as other content related features (i.e. contents
// scrim, ntp footer, etc). contents_container_view_ only exists if the split
// view feature is disabled.
raw_ptr<ContentsContainerView> contents_container_view_ = nullptr;
// The view responsible for housing the contents of the vertical tab strip.
raw_ptr<VerticalTabStripRegionView> vertical_tab_strip_container_ = nullptr;
// The side panel aligned to the left or the right side of the browser window
// depending on the kSidePanelHorizontalAlignment pref's value.
// Conceptually this member should exist if and only if the
// side_panel_coordinator is created.
raw_ptr<SidePanel> contents_height_side_panel_ = nullptr;
// These are only non-null when the `SideBySide` feature is disabled.
// Otherwise, `multi_contents_view_` will create its own separators.
raw_ptr<views::View> right_aligned_side_panel_separator_ = nullptr;
raw_ptr<views::View> left_aligned_side_panel_separator_ = nullptr;
raw_ptr<views::View> side_panel_rounded_corner_ = nullptr;
// Provides access to the toolbar buttons this browser view uses. Buttons may
// appear in a hosted app frame or in a tabbed UI toolbar.
raw_ptr<ToolbarButtonProvider> toolbar_button_provider_ = nullptr;
// The handler responsible for showing autofill bubbles.
std::unique_ptr<autofill::AutofillBubbleHandler> autofill_bubble_handler_;
// The scrim view that covers the browser window when a window-modal dialog is
// showing.
// This is currently not used on macOS where the platform draws a native
// scrim for window modals (NSWindow sheet).
raw_ptr<ScrimView> window_scrim_view_ = nullptr;
// A mapping between accelerators and command IDs.
std::map<ui::Accelerator, int> accelerator_table_;
// True if we have already been initialized.
bool initialized_ = false;
// True if (as of the last time it was checked) the frame type is native.
bool using_native_frame_ = true;
// True when in ProcessFullscreen(). The flag is used to avoid reentrance and
// to ignore requests to layout while in ProcessFullscreen() to reduce
// jankiness.
bool in_process_fullscreen_ = false;
std::unique_ptr<ExclusiveAccessBubbleViews> exclusive_access_bubble_;
// Tracks the task to asynchronously destroy the exclusive access bubble.
base::CancelableTaskTracker exclusive_access_bubble_cancelable_task_tracker_;
std::optional<base::CancelableTaskTracker::TaskId>
exclusive_access_bubble_destruction_task_id_;
// True when we do not want to allow exiting fullscreen, e.g. in Chrome OS
// Kiosk session.
bool force_fullscreen_ = false;
// The runner used for displaying tab-loading animations.
std::unique_ptr<gfx::AnimationRunner> loading_animation_;
// The timer used to update frames for tab-loading animations.
base::RepeatingTimer loading_animation_timer_;
// Closure invoked when the state of the loading animation changes.
base::OnceClosure loading_animation_state_change_closure_;
// Start timestamp for all throbbers. Set when the loading animation
// starts and used for all consecutive tabs (while any are loading) to keep
// throbbers in sync.
base::TimeTicks loading_animation_start_;
base::OneShotTimer temporary_bookmark_bar_timer_;
views::UnhandledKeyboardEventHandler unhandled_keyboard_event_handler_;
// Whether OnWidgetActivationChanged should RestoreFocus. If this is set and
// is true, OnWidgetActivationChanged will call RestoreFocus. This is set
// to true when not set in Show() so that RestoreFocus on activation only
// happens for very first Show() calls.
std::optional<bool> restore_focus_on_activation_;
// This is non-null on Chrome OS only.
std::unique_ptr<TopControlsSlideController> top_controls_slide_controller_;
// Used to allow a single layout operation once the top controls slide
// behavior starts. This needed since sliding the top controls and the page
// contents is done using layer transform. A layout operation while sliding is
// in progress might break the view, and will make sliding feel janky.
// A single layout is needed right before sliding begins. (See
// TopControlsSlideControllerChromeOS::OnBeginSliding()).
bool did_first_layout_while_top_controls_are_sliding_ = false;
base::CallbackListSubscription subscription_ =
ui::TouchUiController::Get()->RegisterCallback(
base::BindRepeating(&BrowserView::TouchModeChanged,
base::Unretained(this)));
// If the Window Placement experiment is enabled and fullscreen is requested
// on a particular display, this closure will be called after fullscreen is
// exited to restore the original pre-fullscreen bounds of the window.
base::OnceClosure restore_pre_fullscreen_bounds_callback_;
base::ScopedObservation<webapps::AppBannerManager,
webapps::AppBannerManager::Observer>
app_banner_manager_observation_{this};
base::ScopedObservation<views::FocusManager, views::FocusChangeListener>
focus_manager_observation_{this};
base::ScopedObservation<views::Widget, views::WidgetObserver>
widget_observation_{this};
bool interactive_resize_in_progress_ = false;
// The last bounds we notified about in TryNotifyWindowBoundsChanged().
gfx::Rect last_widget_bounds_;
#if !BUILDFLAG(IS_CHROMEOS)
std::unique_ptr<AccessibilityFocusHighlight> accessibility_focus_highlight_;
#endif
OnLinkOpeningFromGestureCallbackList link_opened_from_gesture_callbacks_;
#if BUILDFLAG(IS_CHROMEOS)
// |loading_animation_tracker_| is used to measure animation smoothness for
// tab loading animation.
std::optional<ui::ThroughputTracker> loading_animation_tracker_;
#endif
bool window_controls_overlay_enabled_ = false;
bool should_show_window_controls_overlay_toggle_ = false;
bool borderless_mode_enabled_ = false;
bool window_management_permission_granted_ = false;
std::optional<content::PermissionController::SubscriptionId>
window_management_subscription_id_;
// Caching the last value of `PageData::can_resize_` that has been notified to
// the WidgetObservers to avoid notifying them when nothing has changed.
std::optional<bool> cached_can_resize_from_web_api_;
base::CallbackListSubscription paint_as_active_subscription_;
PrefChangeRegistrar registrar_;
ui::OmniboxPopupCloser omnibox_popup_closer_{this};
base::CallbackListSubscription vertical_tab_subscription_;
mutable base::WeakPtrFactory<BrowserView> weak_ptr_factory_{this};
};
#endif // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_VIEW_H_