1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_VIEW_H_
12 #include "base/compiler_specific.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/timer/timer.h"
15 #include "build/build_config.h"
16 #include "chrome/browser/devtools/devtools_window.h"
17 #include "chrome/browser/ui/browser.h"
18 #include "chrome/browser/ui/browser_window.h"
19 #include "chrome/browser/ui/exclusive_access/exclusive_access_context.h"
20 #include "chrome/browser/ui/infobar_container_delegate.h"
21 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
22 #include "chrome/browser/ui/views/exclusive_access_bubble_views_context.h"
23 #include "chrome/browser/ui/views/frame/browser_frame.h"
24 #include "chrome/browser/ui/views/frame/contents_web_view.h"
25 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h"
26 #include "chrome/browser/ui/views/frame/web_contents_close_handler.h"
27 #include "chrome/browser/ui/views/load_complete_listener.h"
28 #include "components/omnibox/browser/omnibox_popup_model_observer.h"
29 #include "ui/base/accelerators/accelerator.h"
30 #include "ui/base/models/simple_menu_model.h"
31 #include "ui/gfx/native_widget_types.h"
32 #include "ui/views/controls/button/button.h"
33 #include "ui/views/controls/webview/unhandled_keyboard_event_handler.h"
34 #include "ui/views/widget/widget_delegate.h"
35 #include "ui/views/widget/widget_observer.h"
36 #include "ui/views/window/client_view.h"
39 #include "chrome/browser/hang_monitor/hung_plugin_action.h"
40 #include "chrome/browser/hang_monitor/hung_window_detector.h"
43 // NOTE: For more information about the objects and files in this directory,
44 // view: http://dev.chromium.org/developers/design-documents/browser-window
46 class BookmarkBarView
;
48 class BrowserViewLayout
;
49 class ContentsLayoutManager
;
50 class DownloadShelfView
;
51 class ExclusiveAccessBubbleViews
;
52 class InfoBarContainerView
;
53 class LocationBarView
;
54 class StatusBubbleViews
;
57 class TopContainerView
;
58 class WebContentsCloseHandler
;
64 namespace extensions
{
69 class AccessiblePaneView
;
70 class ExternalFocusTracker
;
74 ///////////////////////////////////////////////////////////////////////////////
77 // A ClientView subclass that provides the contents of a browser window,
78 // including the TabStrip, toolbars, download shelves, the content area etc.
80 class BrowserView
: public BrowserWindow
,
81 public TabStripModelObserver
,
82 public ui::AcceleratorProvider
,
83 public views::WidgetDelegate
,
84 public views::WidgetObserver
,
85 public views::ClientView
,
86 public InfoBarContainerDelegate
,
87 public LoadCompleteListener::Delegate
,
88 public OmniboxPopupModelObserver
,
89 public ExclusiveAccessContext
,
90 public ExclusiveAccessBubbleViewsContext
{
92 // The browser view's class name.
93 static const char kViewClassName
[];
96 ~BrowserView() override
;
98 // Takes ownership of |browser|.
99 void Init(Browser
* browser
);
101 void set_frame(BrowserFrame
* frame
) { frame_
= frame
; }
102 BrowserFrame
* frame() const { return frame_
; }
104 // Returns a pointer to the BrowserView* interface implementation (an
105 // instance of this object, typically) for a given native window, or null if
106 // there is no such association.
108 // Don't use this unless you only have a NativeWindow. In nearly all
109 // situations plumb through browser and use it.
110 static BrowserView
* GetBrowserViewForNativeWindow(gfx::NativeWindow window
);
112 // Returns the BrowserView used for the specified Browser.
113 static BrowserView
* GetBrowserViewForBrowser(const Browser
* browser
);
115 // Paints a 1 device-pixel-thick horizontal line (regardless of device scale
116 // factor) flush with the bottom of |bounds|.
117 static void Paint1pxHorizontalLine(
122 // Returns a Browser instance of this view.
123 Browser
* browser() { return browser_
.get(); }
124 const Browser
* browser() const { return browser_
.get(); }
126 // Initializes (or re-initializes) the status bubble. We try to only create
127 // the bubble once and re-use it for the life of the browser, but certain
128 // events (such as changing enabling/disabling Aero on Win) can force a need
129 // to change some of the bubble's creation parameters.
130 void InitStatusBubble();
132 // Returns the apparent bounds of the toolbar, in BrowserView coordinates.
133 // These differ from |toolbar_.bounds()| in that they match where the toolbar
134 // background image is drawn -- slightly outside the "true" bounds
135 // horizontally. Note that this returns the bounds for the toolbar area.
136 gfx::Rect
GetToolbarBounds() const;
138 // Returns the constraining bounding box that should be used to lay out the
139 // FindBar within. This is _not_ the size of the find bar, just the bounding
140 // box it should be laid out within. The coordinate system of the returned
141 // rect is in the coordinate system of the frame, since the FindBar is a child
143 gfx::Rect
GetFindBarBoundingBox() const;
145 // Returns the preferred height of the TabStrip. Used to position the OTR
147 int GetTabStripHeight() const;
149 // Takes some view's origin (relative to this BrowserView) and offsets it such
150 // that it can be used as the source origin for seamlessly tiling the toolbar
151 // background image over that view.
152 gfx::Point
OffsetPointForToolbarBackgroundImage(
153 const gfx::Point
& point
) const;
155 // Container for the tabstrip, toolbar, etc.
156 TopContainerView
* top_container() { return top_container_
; }
158 // Accessor for the TabStrip.
159 TabStrip
* tabstrip() { return tabstrip_
; }
161 // Accessor for the Toolbar.
162 ToolbarView
* toolbar() { return toolbar_
; }
164 // Bookmark bar may be null, for example for pop-ups.
165 BookmarkBarView
* bookmark_bar() { return bookmark_bar_view_
.get(); }
167 // Returns the do-nothing view which controls the z-order of the find bar
168 // widget relative to views which paint into layers and views which have an
169 // associated NativeView. The presence / visibility of this view is not
170 // indicative of the visibility of the find bar widget or even whether
171 // FindBarController is initialized.
172 View
* find_bar_host_view() { return find_bar_host_view_
; }
174 // Accessor for the InfobarContainer.
175 InfoBarContainerView
* infobar_container() { return infobar_container_
; }
177 // Accessor for the FullscreenExitBubbleViews.
178 ExclusiveAccessBubbleViews
* exclusive_access_bubble() {
179 return exclusive_access_bubble_
.get();
182 // Returns true if various window components are visible.
183 bool IsTabStripVisible() const;
185 // Returns true if the profile associated with this Browser window is
187 bool IsOffTheRecord() const;
189 // Returns true if the profile associated with this Browser window is
191 bool IsGuestSession() const;
193 // Returns true if the profile associated with this Browser window is
194 // not off the record or a guest session.
195 bool IsRegularOrGuestSession() const;
197 // Returns true if the non-client view should render an avatar icon.
198 bool ShouldShowAvatar() const;
200 // Provides the containing frame with the accelerator for the specified
201 // command id. This can be used to provide menu item shortcut hints etc.
202 // Returns true if an accelerator was found for the specified |cmd_id|, false
204 bool GetAccelerator(int cmd_id
, ui::Accelerator
* accelerator
) const;
206 // Returns true if the specificed |accelerator| is registered with this view.
207 bool IsAcceleratorRegistered(const ui::Accelerator
& accelerator
);
209 // Returns the active WebContents. Used by our NonClientView's
210 // TabIconView::TabContentsProvider implementations.
211 // TODO(beng): exposing this here is a bit bogus, since it's only used to
212 // determine loading state. It'd be nicer if we could change this to be
213 // bool IsSelectedTabLoading() const; or something like that. We could even
214 // move it to a WindowDelegate subclass.
215 content::WebContents
* GetActiveWebContents() const;
217 // Retrieves the icon to use in the frame to indicate an OTR window.
218 gfx::ImageSkia
GetOTRAvatarIcon() const;
220 // Returns true if the Browser object associated with this BrowserView is a
221 // tabbed-type window (i.e. a browser window, not an app or popup).
222 bool IsBrowserTypeNormal() const {
223 return browser_
->is_type_tabbed();
226 // See ImmersiveModeController for description.
227 ImmersiveModeController
* immersive_mode_controller() const {
228 return immersive_mode_controller_
.get();
231 // Returns true if the view has been initialized.
232 bool initialized() const { return initialized_
; }
234 // Restores the focused view. This is also used to set the initial focus
235 // when a new browser window is created.
238 // Called after the widget's fullscreen state is changed without going through
239 // FullscreenController. This method does any processing which was skipped.
240 // Only exiting fullscreen in this way is currently supported.
241 void FullscreenStateChanged();
243 // Overridden from BrowserWindow:
244 void Show() override
;
245 void ShowInactive() override
;
246 void Hide() override
;
247 void SetBounds(const gfx::Rect
& bounds
) override
;
248 void Close() override
;
249 void Activate() override
;
250 void Deactivate() override
;
251 bool IsActive() const override
;
252 void FlashFrame(bool flash
) override
;
253 bool IsAlwaysOnTop() const override
;
254 void SetAlwaysOnTop(bool always_on_top
) override
;
255 gfx::NativeWindow
GetNativeWindow() const override
;
256 StatusBubble
* GetStatusBubble() override
;
257 void UpdateTitleBar() override
;
258 void BookmarkBarStateChanged(
259 BookmarkBar::AnimateChangeType change_type
) override
;
260 void UpdateDevTools() override
;
261 void UpdateLoadingAnimations(bool should_animate
) override
;
262 void SetStarredState(bool is_starred
) override
;
263 void SetTranslateIconToggled(bool is_lit
) override
;
264 void OnActiveTabChanged(content::WebContents
* old_contents
,
265 content::WebContents
* new_contents
,
267 int reason
) override
;
268 void ZoomChangedForActiveTab(bool can_show_bubble
) override
;
269 gfx::Rect
GetRestoredBounds() const override
;
270 ui::WindowShowState
GetRestoredState() const override
;
271 gfx::Rect
GetBounds() const override
;
272 bool IsMaximized() const override
;
273 bool IsMinimized() const override
;
274 void Maximize() override
;
275 void Minimize() override
;
276 void Restore() override
;
277 void EnterFullscreen(const GURL
& url
,
278 ExclusiveAccessBubbleType bubble_type
,
279 bool with_toolbar
) override
;
280 void ExitFullscreen() override
;
281 void UpdateExclusiveAccessExitBubbleContent(
283 ExclusiveAccessBubbleType bubble_type
) override
;
284 bool ShouldHideUIForFullscreen() const override
;
285 bool IsFullscreen() const override
;
286 bool IsFullscreenBubbleVisible() const override
;
287 bool SupportsFullscreenWithToolbar() const override
;
288 void UpdateFullscreenWithToolbar(bool with_toolbar
) override
;
289 bool IsFullscreenWithToolbar() const override
;
291 void SetMetroSnapMode(bool enable
) override
;
292 bool IsInMetroSnapMode() const override
;
293 #endif // defined(OS_WIN)
294 LocationBar
* GetLocationBar() const override
;
295 void SetFocusToLocationBar(bool select_all
) override
;
296 void UpdateReloadStopState(bool is_loading
, bool force
) override
;
297 void UpdateToolbar(content::WebContents
* contents
) override
;
298 void ResetToolbarTabState(content::WebContents
* contents
) override
;
299 void FocusToolbar() override
;
300 ToolbarActionsBar
* GetToolbarActionsBar() override
;
301 void ToolbarSizeChanged(bool is_animating
) override
;
302 void FocusAppMenu() override
;
303 void FocusBookmarksToolbar() override
;
304 void FocusInfobars() override
;
305 void RotatePaneFocus(bool forwards
) override
;
306 void DestroyBrowser() override
;
307 bool IsBookmarkBarVisible() const override
;
308 bool IsBookmarkBarAnimating() const override
;
309 bool IsTabStripEditable() const override
;
310 bool IsToolbarVisible() const override
;
311 gfx::Rect
GetRootWindowResizerRect() const override
;
312 void ConfirmAddSearchProvider(TemplateURL
* template_url
,
313 Profile
* profile
) override
;
314 void ShowUpdateChromeDialog() override
;
315 void ShowBookmarkBubble(const GURL
& url
, bool already_bookmarked
) override
;
316 void ShowBookmarkAppBubble(
317 const WebApplicationInfo
& web_app_info
,
318 const ShowBookmarkAppBubbleCallback
& callback
) override
;
319 void ShowTranslateBubble(content::WebContents
* contents
,
320 translate::TranslateStep step
,
321 translate::TranslateErrors::Type error_type
,
322 bool is_user_gesture
) override
;
323 bool ShowSessionCrashedBubble() override
;
324 bool IsProfileResetBubbleSupported() const override
;
325 GlobalErrorBubbleViewBase
* ShowProfileResetBubble(
326 const base::WeakPtr
<ProfileResetGlobalError
>& global_error
) override
;
327 #if defined(ENABLE_ONE_CLICK_SIGNIN)
328 void ShowOneClickSigninBubble(
329 OneClickSigninBubbleType type
,
330 const base::string16
& email
,
331 const base::string16
& error_message
,
332 const StartSyncCallback
& start_sync_callback
) override
;
334 // TODO(beng): Not an override, move somewhere else.
335 void SetDownloadShelfVisible(bool visible
);
336 bool IsDownloadShelfVisible() const override
;
337 DownloadShelf
* GetDownloadShelf() override
;
338 void ConfirmBrowserCloseWithPendingDownloads(
340 Browser::DownloadClosePreventionType dialog_type
,
342 const base::Callback
<void(bool)>& callback
) override
;
343 void UserChangedTheme() override
;
344 void ShowWebsiteSettings(Profile
* profile
,
345 content::WebContents
* web_contents
,
347 const content::SSLStatus
& ssl
) override
;
348 void ShowAppMenu() override
;
349 bool PreHandleKeyboardEvent(const content::NativeWebKeyboardEvent
& event
,
350 bool* is_keyboard_shortcut
) override
;
351 void HandleKeyboardEvent(
352 const content::NativeWebKeyboardEvent
& event
) override
;
353 void CutCopyPaste(int command_id
) override
;
354 WindowOpenDisposition
GetDispositionForPopupBounds(
355 const gfx::Rect
& bounds
) override
;
356 FindBar
* CreateFindBar() override
;
357 web_modal::WebContentsModalDialogHost
* GetWebContentsModalDialogHost()
359 void ShowAvatarBubbleFromAvatarButton(
360 AvatarBubbleMode mode
,
361 const signin::ManageAccountsParams
& manage_accounts_params
) override
;
362 int GetRenderViewHeightInsetWithDetachedBookmarkBar() override
;
363 void ExecuteExtensionCommand(const extensions::Extension
* extension
,
364 const extensions::Command
& command
) override
;
365 ExclusiveAccessContext
* GetExclusiveAccessContext() override
;
367 BookmarkBarView
* GetBookmarkBarView() const;
368 LocationBarView
* GetLocationBarView() const;
369 views::View
* GetTabContentsContainerView() const;
370 ToolbarView
* GetToolbarView() const;
372 // Overridden from TabStripModelObserver:
373 void TabInsertedAt(content::WebContents
* contents
,
375 bool foreground
) override
;
376 void TabDetachedAt(content::WebContents
* contents
, int index
) override
;
377 void TabDeactivated(content::WebContents
* contents
) override
;
378 void TabStripEmpty() override
;
379 void WillCloseAllTabs() override
;
380 void CloseAllTabsCanceled() override
;
382 // Overridden from ui::AcceleratorProvider:
383 bool GetAcceleratorForCommandId(int command_id
,
384 ui::Accelerator
* accelerator
) override
;
386 // Overridden from views::WidgetDelegate:
387 bool CanResize() const override
;
388 bool CanMaximize() const override
;
389 bool CanMinimize() const override
;
390 bool CanActivate() const override
;
391 base::string16
GetWindowTitle() const override
;
392 base::string16
GetAccessibleWindowTitle() const override
;
393 views::View
* GetInitiallyFocusedView() override
;
394 bool ShouldShowWindowTitle() const override
;
395 gfx::ImageSkia
GetWindowAppIcon() override
;
396 gfx::ImageSkia
GetWindowIcon() override
;
397 bool ShouldShowWindowIcon() const override
;
398 bool ExecuteWindowsCommand(int command_id
) override
;
399 std::string
GetWindowName() const override
;
400 void SaveWindowPlacement(const gfx::Rect
& bounds
,
401 ui::WindowShowState show_state
) override
;
402 bool GetSavedWindowPlacement(const views::Widget
* widget
,
404 ui::WindowShowState
* show_state
) const override
;
405 views::View
* GetContentsView() override
;
406 views::ClientView
* CreateClientView(views::Widget
* widget
) override
;
407 void OnWindowBeginUserBoundsChange() override
;
408 void OnWidgetMove() override
;
409 views::Widget
* GetWidget() override
;
410 const views::Widget
* GetWidget() const override
;
411 void GetAccessiblePanes(std::vector
<View
*>* panes
) override
;
413 // Overridden from views::WidgetObserver:
414 void OnWidgetActivationChanged(views::Widget
* widget
, bool active
) override
;
416 // Overridden from views::ClientView:
417 bool CanClose() override
;
418 int NonClientHitTest(const gfx::Point
& point
) override
;
419 gfx::Size
GetMinimumSize() const override
;
421 // InfoBarContainerDelegate:
422 SkColor
GetInfoBarSeparatorColor() const override
;
423 void InfoBarContainerStateChanged(bool is_animating
) override
;
424 bool DrawInfoBarArrows(int* x
) const override
;
426 // Overridden from views::View:
427 const char* GetClassName() const override
;
428 void Layout() override
;
429 void PaintChildren(const ui::PaintContext
& context
) override
;
430 void ViewHierarchyChanged(
431 const ViewHierarchyChangedDetails
& details
) override
;
432 void ChildPreferredSizeChanged(View
* child
) override
;
433 void GetAccessibleState(ui::AXViewState
* state
) override
;
434 void OnNativeThemeChanged(const ui::NativeTheme
* theme
) override
;
436 // Overridden from ui::AcceleratorTarget:
437 bool AcceleratorPressed(const ui::Accelerator
& accelerator
) override
;
439 // OmniboxPopupModelObserver overrides
440 void OnOmniboxPopupShownOrHidden() override
;
442 // ExclusiveAccessContext overrides
443 Profile
* GetProfile() override
;
444 content::WebContents
* GetActiveWebContents() override
;
445 void HideDownloadShelf() override
;
446 void UnhideDownloadShelf() override
;
448 // ExclusiveAccessBubbleViewsContext overrides
449 ExclusiveAccessManager
* GetExclusiveAccessManager() override
;
450 bool IsImmersiveModeEnabled() override
;
451 views::Widget
* GetBubbleAssociatedWidget() override
;
452 gfx::Rect
GetTopContainerBoundsInScreen() override
;
454 // Testing interface:
455 views::View
* GetContentsContainerForTest() { return contents_container_
; }
456 views::WebView
* GetContentsWebViewForTest() { return contents_web_view_
; }
457 views::WebView
* GetDevToolsWebViewForTest() { return devtools_web_view_
; }
460 // Do not friend BrowserViewLayout. Use the BrowserViewLayoutDelegate
461 // interface to keep these two classes decoupled and testable.
462 friend class BrowserViewLayoutDelegateImpl
;
463 FRIEND_TEST_ALL_PREFIXES(BrowserViewTest
, BrowserView
);
464 FRIEND_TEST_ALL_PREFIXES(BrowserViewsAccessibilityTest
,
465 TestAboutChromeViewAccObj
);
467 enum FullscreenMode
{
469 METRO_SNAP_FULLSCREEN
472 // Appends to |toolbars| a pointer to each AccessiblePaneView that
473 // can be traversed using F6, in the order they should be traversed.
474 void GetAccessiblePanes(std::vector
<views::AccessiblePaneView
*>* panes
);
476 // Constructs and initializes the child views.
479 // Callback for the loading animation(s) associated with this view.
480 void LoadingAnimationCallback();
482 // LoadCompleteListener::Delegate implementation. Creates and initializes the
483 // |jumplist_| after the first page load.
484 void OnLoadCompleted() override
;
486 // Returns the BrowserViewLayout.
487 BrowserViewLayout
* GetBrowserViewLayout() const;
489 // Returns the ContentsLayoutManager.
490 ContentsLayoutManager
* GetContentsLayoutManager() const;
492 // Prepare to show the Bookmark Bar for the specified WebContents.
493 // Returns true if the Bookmark Bar can be shown (i.e. it's supported for this
494 // Browser type) and there should be a subsequent re-layout to show it.
495 // |contents| can be null.
496 bool MaybeShowBookmarkBar(content::WebContents
* contents
);
498 // Moves the bookmark bar view to the specified parent, which may be null,
499 // |this|, or |top_container_|. Ensures that |top_container_| stays in front
500 // of |bookmark_bar_view_|.
501 void SetBookmarkBarParent(views::View
* new_parent
);
503 // Prepare to show an Info Bar for the specified WebContents. Returns
504 // true if there is an Info Bar to show and one is supported for this Browser
505 // type, and there should be a subsequent re-layout to show it.
506 // |contents| can be null.
507 bool MaybeShowInfoBar(content::WebContents
* contents
);
509 // Updates devtools window for given contents. This method will show docked
510 // devtools window for inspected |web_contents| that has docked devtools
511 // and hide it for null or not inspected |web_contents|. It will also make
512 // sure devtools window size and position are restored for given tab.
513 // This method will not update actual DevTools WebContents, if not
514 // |update_devtools_web_contents|. In this case, manual update is required.
515 void UpdateDevToolsForContents(content::WebContents
* web_contents
,
516 bool update_devtools_web_contents
);
518 // Updates various optional child Views, e.g. Bookmarks Bar, Info Bar or the
519 // Download Shelf in response to a change notification from the specified
520 // |contents|. |contents| can be null. In this case, all optional UI will be
522 void UpdateUIForContents(content::WebContents
* contents
);
524 // Invoked to update the necessary things when our fullscreen state changes
525 // to |fullscreen|. On Windows this is invoked immediately when we toggle the
526 // full screen state. On Linux changing the fullscreen state is async, so we
527 // ask the window to change its fullscreen state, then when we get
528 // notification that it succeeded this method is invoked.
529 // If |url| is not empty, it is the URL of the page that requested fullscreen
530 // (via the fullscreen JS API).
531 // |bubble_type| determines what should be shown in the fullscreen exit
533 void ProcessFullscreen(bool fullscreen
,
536 ExclusiveAccessBubbleType bubble_type
);
538 // Returns whether immmersive fullscreen should replace fullscreen. This
539 // should only occur for "browser-fullscreen" for tabbed-typed windows (not
540 // for tab-fullscreen and not for app/popup type windows).
541 bool ShouldUseImmersiveFullscreenForUrl(const GURL
& url
) const;
543 // Copy the accelerator table from the app resources into something we can
545 void LoadAccelerators();
547 // Retrieves the command id for the specified Windows app command.
548 int GetCommandIDForAppCommandID(int app_command_id
) const;
550 // Initialize the hung plugin detector.
551 void InitHangMonitor();
553 // Possibly records a user metrics action corresponding to the passed-in
554 // accelerator. Only implemented for Chrome OS, where we're interested in
555 // learning about how frequently the top-row keys are used.
556 void UpdateAcceleratorMetrics(const ui::Accelerator
& accelerator
,
559 // Calls |method| which is either WebContents::Cut, ::Copy, or ::Paste on
560 // the given WebContents, returning true if it consumed the event.
561 bool DoCutCopyPasteForWebContents(
562 content::WebContents
* contents
,
563 void (content::WebContents::*method
)());
565 // Shows the next app-modal dialog box, if there is one to be shown, or moves
566 // an existing showing one to the front.
567 void ActivateAppModalDialog() const;
569 // Returns the max top arrow height for infobar.
570 int GetMaxTopInfoBarArrowHeight();
572 // Last focused view that issued a tab traversal.
573 int last_focused_view_storage_id_
;
575 // The BrowserFrame that hosts this view.
576 BrowserFrame
* frame_
;
578 // The Browser object we are associated with.
579 scoped_ptr
<Browser
> browser_
;
581 // BrowserView layout (LTR one is pictured here).
583 // --------------------------------------------------------------------
584 // | TopContainerView (top_container_) |
585 // | -------------------------------------------------------------- |
586 // | | Tabs (tabstrip_) | |
587 // | |------------------------------------------------------------| |
588 // | | Navigation buttons, address bar, menu (toolbar_) | |
589 // | -------------------------------------------------------------- |
590 // |------------------------------------------------------------------|
591 // | All infobars (infobar_container_) [1] |
592 // |------------------------------------------------------------------|
593 // | Bookmarks (bookmark_bar_view_) [1] |
594 // |------------------------------------------------------------------|
595 // | Contents container (contents_container_) |
596 // | -------------------------------------------------------------- |
597 // | | devtools_web_view_ | |
598 // | |------------------------------------------------------------| |
599 // | | contents_web_view_ | |
600 // | -------------------------------------------------------------- |
601 // |------------------------------------------------------------------|
602 // | Active downloads (download_shelf_) |
603 // --------------------------------------------------------------------
605 // [1] The bookmark bar and info bar are swapped when on the new tab page.
606 // Additionally when the bookmark bar is detached, contents_container_ is
607 // positioned on top of the bar while the tab's contents are placed below
608 // the bar. This allows the find bar to always align with the top of
609 // contents_container_ regardless if there's bookmark or info bars.
611 // The view that manages the tab strip, toolbar, and sometimes the bookmark
612 // bar. Stacked top in the view hiearachy so it can be used to slide out
613 // the top views in immersive fullscreen.
614 TopContainerView
* top_container_
;
619 // The Toolbar containing the navigation buttons, menus and the address bar.
620 ToolbarView
* toolbar_
;
622 // The Bookmark Bar View for this window. Lazily created. May be null for
623 // non-tabbed browsers like popups. May not be visible.
624 scoped_ptr
<BookmarkBarView
> bookmark_bar_view_
;
626 // The do-nothing view which controls the z-order of the find bar widget
627 // relative to views which paint into layers and views with an associated
629 View
* find_bar_host_view_
;
631 // The download shelf view (view at the bottom of the page).
632 scoped_ptr
<DownloadShelfView
> download_shelf_
;
634 // The InfoBarContainerView that contains InfoBars for the current tab.
635 InfoBarContainerView
* infobar_container_
;
637 // The view that contains the selected WebContents.
638 ContentsWebView
* contents_web_view_
;
640 // The view that contains devtools window for the selected WebContents.
641 views::WebView
* devtools_web_view_
;
643 // The view managing the devtools and contents positions.
644 // Handled by ContentsLayoutManager.
645 views::View
* contents_container_
;
647 // Tracks and stores the last focused view which is not the
648 // devtools_web_view_ or any of its children. Used to restore focus once
649 // the devtools_web_view_ is hidden.
650 scoped_ptr
<views::ExternalFocusTracker
> devtools_focus_tracker_
;
652 // The Status information bubble that appears at the bottom of the window.
653 scoped_ptr
<StatusBubbleViews
> status_bubble_
;
655 // A mapping between accelerators and commands.
656 std::map
<ui::Accelerator
, int> accelerator_table_
;
658 // True if we have already been initialized.
661 // True when in ProcessFullscreen(). The flag is used to avoid reentrance and
662 // to ignore requests to layout while in ProcessFullscreen() to reduce
664 bool in_process_fullscreen_
;
666 scoped_ptr
<ExclusiveAccessBubbleViews
> exclusive_access_bubble_
;
669 // This object is used to perform periodic actions in a worker
670 // thread. It is currently used to monitor hung plugin windows.
671 WorkerThreadTicker ticker_
;
673 // This object is initialized with the frame window HWND. This
674 // object is also passed as a tick handler with the ticker_ object.
675 // It is used to periodically monitor for hung plugin windows
676 HungWindowDetector hung_window_detector_
;
678 // This object is invoked by hung_window_detector_ when it detects a hung
680 HungPluginAction hung_plugin_action_
;
682 // Helper class to listen for completion of first page load.
683 scoped_ptr
<LoadCompleteListener
> load_complete_listener_
;
685 // The custom JumpList for Windows 7.
686 scoped_refptr
<JumpList
> jumplist_
;
689 // The timer used to update frames for the Loading Animation.
690 base::RepeatingTimer
<BrowserView
> loading_animation_timer_
;
692 views::UnhandledKeyboardEventHandler unhandled_keyboard_event_handler_
;
694 // Used to measure the loading spinner animation rate.
695 base::TimeTicks last_animation_time_
;
697 // If this flag is set then SetFocusToLocationBar() will set focus to the
698 // location bar even if the browser window is not active.
699 bool force_location_bar_focus_
;
701 scoped_ptr
<ImmersiveModeController
> immersive_mode_controller_
;
703 scoped_ptr
<WebContentsCloseHandler
> web_contents_close_handler_
;
705 mutable base::WeakPtrFactory
<BrowserView
> activate_modal_dialog_factory_
;
707 DISALLOW_COPY_AND_ASSIGN(BrowserView
);
710 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_VIEW_H_