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/infobars/infobar_container.h"
18 #include "chrome/browser/ui/browser.h"
19 #include "chrome/browser/ui/browser_window.h"
20 #include "chrome/browser/ui/omnibox/omnibox_popup_model_observer.h"
21 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
22 #include "chrome/browser/ui/views/frame/browser_frame.h"
23 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h"
24 #include "chrome/browser/ui/views/frame/scroll_end_effect_controller.h"
25 #include "chrome/browser/ui/views/load_complete_listener.h"
26 #include "ui/base/accelerators/accelerator.h"
27 #include "ui/base/models/simple_menu_model.h"
28 #include "ui/gfx/native_widget_types.h"
29 #include "ui/gfx/sys_color_change_listener.h"
30 #include "ui/views/controls/button/button.h"
31 #include "ui/views/controls/webview/unhandled_keyboard_event_handler.h"
32 #include "ui/views/widget/widget_delegate.h"
33 #include "ui/views/widget/widget_observer.h"
34 #include "ui/views/window/client_view.h"
37 #include "chrome/browser/hang_monitor/hung_plugin_action.h"
38 #include "chrome/browser/hang_monitor/hung_window_detector.h"
41 // NOTE: For more information about the objects and files in this directory,
42 // view: http://dev.chromium.org/developers/design-documents/browser-window
44 class BookmarkBarView
;
46 class BrowserViewLayout
;
47 class ContentsLayoutManager
;
48 class DownloadShelfView
;
49 class FullscreenExitBubbleViews
;
50 class InfoBarContainerView
;
51 class LocationBarView
;
52 class StatusBubbleViews
;
53 class SearchViewController
;
57 class TopContainerView
;
64 class PasswordGenerator
;
68 class RenderWidgetHost
;
71 namespace extensions
{
76 class AccessiblePaneView
;
77 class ExternalFocusTracker
;
81 ///////////////////////////////////////////////////////////////////////////////
84 // A ClientView subclass that provides the contents of a browser window,
85 // including the TabStrip, toolbars, download shelves, the content area etc.
87 class BrowserView
: public BrowserWindow
,
88 public BrowserWindowTesting
,
89 public TabStripModelObserver
,
90 public ui::AcceleratorProvider
,
91 public views::WidgetDelegate
,
92 public views::WidgetObserver
,
93 public views::ClientView
,
94 public InfoBarContainer::Delegate
,
95 public gfx::SysColorChangeListener
,
96 public LoadCompleteListener::Delegate
,
97 public OmniboxPopupModelObserver
{
99 // The browser view's class name.
100 static const char kViewClassName
[];
103 virtual ~BrowserView();
105 // Takes ownership of |browser|.
106 void Init(Browser
* browser
);
108 void set_frame(BrowserFrame
* frame
) { frame_
= frame
; }
109 BrowserFrame
* frame() const { return frame_
; }
111 // Returns a pointer to the BrowserView* interface implementation (an
112 // instance of this object, typically) for a given native window, or NULL if
113 // there is no such association.
115 // Don't use this unless you only have a NativeWindow. In nearly all
116 // situations plumb through browser and use it.
117 static BrowserView
* GetBrowserViewForNativeWindow(gfx::NativeWindow window
);
119 // Returns the BrowserView used for the specified Browser.
120 static BrowserView
* GetBrowserViewForBrowser(const Browser
* browser
);
122 // Returns a Browser instance of this view.
123 Browser
* browser() { return browser_
.get(); }
125 // Initializes (or re-initializes) the status bubble. We try to only create
126 // the bubble once and re-use it for the life of the browser, but certain
127 // events (such as changing enabling/disabling Aero on Win) can force a need
128 // to change some of the bubble's creation parameters.
129 void InitStatusBubble();
131 // Returns the apparent bounds of the toolbar, in BrowserView coordinates.
132 // These differ from |toolbar_.bounds()| in that they match where the toolbar
133 // background image is drawn -- slightly outside the "true" bounds
134 // horizontally. Note that this returns the bounds for the toolbar area.
135 gfx::Rect
GetToolbarBounds() const;
137 // Returns the constraining bounding box that should be used to lay out the
138 // FindBar within. This is _not_ the size of the find bar, just the bounding
139 // box it should be laid out within. The coordinate system of the returned
140 // rect is in the coordinate system of the frame, since the FindBar is a child
142 gfx::Rect
GetFindBarBoundingBox() const;
144 // Returns the preferred height of the TabStrip. Used to position the OTR
146 int GetTabStripHeight() const;
148 // Takes some view's origin (relative to this BrowserView) and offsets it such
149 // that it can be used as the source origin for seamlessly tiling the toolbar
150 // background image over that view.
151 gfx::Point
OffsetPointForToolbarBackgroundImage(
152 const gfx::Point
& point
) const;
154 // Container for the tabstrip, toolbar, etc.
155 TopContainerView
* top_container() { return top_container_
; }
157 // Accessor for the TabStrip.
158 TabStrip
* tabstrip() { return tabstrip_
; }
160 // Accessor for the Toolbar.
161 ToolbarView
* toolbar() { return toolbar_
; }
163 // Bookmark bar may be NULL, for example for pop-ups.
164 BookmarkBarView
* bookmark_bar() { return bookmark_bar_view_
.get(); }
166 // Returns the do-nothing view which controls the z-order of the find bar
167 // widget relative to views which paint into layers and views which have an
168 // associated NativeView. The presence / visibility of this view is not
169 // indicative of the visibility of the find bar widget or even whether
170 // FindBarController is initialized.
171 View
* find_bar_host_view() { return find_bar_host_view_
; }
173 // Accessor for the InfobarContainer.
174 InfoBarContainerView
* infobar_container() { return infobar_container_
; }
176 // Accessor for the FullscreenExitBubbleViews.
177 FullscreenExitBubbleViews
* fullscreen_exit_bubble() {
178 return fullscreen_bubble_
.get();
181 // Returns true if various window components are visible.
182 bool IsTabStripVisible() const;
184 // Returns true if the profile associated with this Browser window is
186 bool IsOffTheRecord() const;
188 // Returns true if the profile associated with this Browser window is
190 bool IsGuestSession() const;
192 // Returns true if the profile associated with this Browser window is
193 // not off the record or a guest session.
194 bool IsRegularOrGuestSession() const;
196 // Returns the resource ID to use for the OTR icon, which depends on
197 // which layout is being shown and whether we are full-screen.
198 int GetOTRIconResourceID() const;
200 // Returns the resource ID to use for the Guest icon, which may depend on
201 // which layout is being shown and whether we are full-screen.
202 int GetGuestIconResourceID() const;
204 // Returns true if the non-client view should render an avatar icon.
205 bool ShouldShowAvatar() const;
207 // Provides the containing frame with the accelerator for the specified
208 // command id. This can be used to provide menu item shortcut hints etc.
209 // Returns true if an accelerator was found for the specified |cmd_id|, false
211 bool GetAccelerator(int cmd_id
, ui::Accelerator
* accelerator
);
213 // Returns true if the specificed |accelerator| is registered with this view.
214 bool IsAcceleratorRegistered(const ui::Accelerator
& accelerator
);
216 // Returns the active WebContents. Used by our NonClientView's
217 // TabIconView::TabContentsProvider implementations.
218 // TODO(beng): exposing this here is a bit bogus, since it's only used to
219 // determine loading state. It'd be nicer if we could change this to be
220 // bool IsSelectedTabLoading() const; or something like that. We could even
221 // move it to a WindowDelegate subclass.
222 content::WebContents
* GetActiveWebContents() const;
224 // Retrieves the icon to use in the frame to indicate an OTR window.
225 gfx::ImageSkia
GetOTRAvatarIcon() const;
227 // Returns true if the Browser object associated with this BrowserView is a
228 // tabbed-type window (i.e. a browser window, not an app or popup).
229 bool IsBrowserTypeNormal() const {
230 return browser_
->is_type_tabbed();
233 // See ImmersiveModeController for description.
234 ImmersiveModeController
* immersive_mode_controller() const {
235 return immersive_mode_controller_
.get();
238 // Restores the focused view. This is also used to set the initial focus
239 // when a new browser window is created.
242 void SetWindowSwitcherButton(views::Button
* button
);
244 views::Button
* window_switcher_button() {
245 return window_switcher_button_
;
248 // Called after the widget's fullscreen state is changed without going through
249 // FullscreenController. This method does any processing which was skipped.
250 // Only exiting fullscreen in this way is currently supported.
251 void FullscreenStateChanged();
253 // Called from BookmarkBarView/DownloadShelfView during their show/hide
255 void ToolbarSizeChanged(bool is_animating
);
257 // Overridden from BrowserWindow:
258 virtual void Show() OVERRIDE
;
259 virtual void ShowInactive() OVERRIDE
;
260 virtual void Hide() OVERRIDE
;
261 virtual void SetBounds(const gfx::Rect
& bounds
) OVERRIDE
;
262 virtual void Close() OVERRIDE
;
263 virtual void Activate() OVERRIDE
;
264 virtual void Deactivate() OVERRIDE
;
265 virtual bool IsActive() const OVERRIDE
;
266 virtual void FlashFrame(bool flash
) OVERRIDE
;
267 virtual bool IsAlwaysOnTop() const OVERRIDE
;
268 virtual void SetAlwaysOnTop(bool always_on_top
) OVERRIDE
;
269 virtual gfx::NativeWindow
GetNativeWindow() OVERRIDE
;
270 virtual BrowserWindowTesting
* GetBrowserWindowTesting() OVERRIDE
;
271 virtual StatusBubble
* GetStatusBubble() OVERRIDE
;
272 virtual void UpdateTitleBar() OVERRIDE
;
273 virtual void BookmarkBarStateChanged(
274 BookmarkBar::AnimateChangeType change_type
) OVERRIDE
;
275 virtual void UpdateDevTools() OVERRIDE
;
276 virtual void UpdateLoadingAnimations(bool should_animate
) OVERRIDE
;
277 virtual void SetStarredState(bool is_starred
) OVERRIDE
;
278 virtual void SetTranslateIconToggled(bool is_lit
) OVERRIDE
;
279 virtual void OnActiveTabChanged(content::WebContents
* old_contents
,
280 content::WebContents
* new_contents
,
282 int reason
) OVERRIDE
;
283 virtual void ZoomChangedForActiveTab(bool can_show_bubble
) OVERRIDE
;
284 virtual gfx::Rect
GetRestoredBounds() const OVERRIDE
;
285 virtual ui::WindowShowState
GetRestoredState() const OVERRIDE
;
286 virtual gfx::Rect
GetBounds() const OVERRIDE
;
287 virtual bool IsMaximized() const OVERRIDE
;
288 virtual bool IsMinimized() const OVERRIDE
;
289 virtual void Maximize() OVERRIDE
;
290 virtual void Minimize() OVERRIDE
;
291 virtual void Restore() OVERRIDE
;
292 virtual void EnterFullscreen(
293 const GURL
& url
, FullscreenExitBubbleType bubble_type
) OVERRIDE
;
294 virtual void ExitFullscreen() OVERRIDE
;
295 virtual void UpdateFullscreenExitBubbleContent(
297 FullscreenExitBubbleType bubble_type
) OVERRIDE
;
298 virtual bool ShouldHideUIForFullscreen() const OVERRIDE
;
299 virtual bool IsFullscreen() const OVERRIDE
;
300 virtual bool IsFullscreenBubbleVisible() const OVERRIDE
;
302 virtual void SetMetroSnapMode(bool enable
) OVERRIDE
;
303 virtual bool IsInMetroSnapMode() const OVERRIDE
;
305 virtual LocationBar
* GetLocationBar() const OVERRIDE
;
306 virtual void SetFocusToLocationBar(bool select_all
) OVERRIDE
;
307 virtual void UpdateReloadStopState(bool is_loading
, bool force
) OVERRIDE
;
308 virtual void UpdateToolbar(content::WebContents
* contents
) OVERRIDE
;
309 virtual void FocusToolbar() OVERRIDE
;
310 virtual void FocusAppMenu() OVERRIDE
;
311 virtual void FocusBookmarksToolbar() OVERRIDE
;
312 virtual void FocusInfobars() OVERRIDE
;
313 virtual void RotatePaneFocus(bool forwards
) OVERRIDE
;
314 virtual void DestroyBrowser() OVERRIDE
;
315 virtual bool IsBookmarkBarVisible() const OVERRIDE
;
316 virtual bool IsBookmarkBarAnimating() const OVERRIDE
;
317 virtual bool IsTabStripEditable() const OVERRIDE
;
318 virtual bool IsToolbarVisible() const OVERRIDE
;
319 virtual gfx::Rect
GetRootWindowResizerRect() const OVERRIDE
;
320 virtual void ConfirmAddSearchProvider(TemplateURL
* template_url
,
321 Profile
* profile
) OVERRIDE
;
322 virtual void ShowUpdateChromeDialog() OVERRIDE
;
323 virtual void ShowBookmarkBubble(const GURL
& url
,
324 bool already_bookmarked
) OVERRIDE
;
325 virtual void ShowBookmarkPrompt() OVERRIDE
;
326 virtual void ShowTranslateBubble(
327 content::WebContents
* contents
,
328 TranslateBubbleModel::ViewState view_state
,
329 TranslateErrors::Type error_type
) OVERRIDE
;
330 #if defined(ENABLE_ONE_CLICK_SIGNIN)
331 virtual void ShowOneClickSigninBubble(
332 OneClickSigninBubbleType type
,
333 const base::string16
& email
,
334 const base::string16
& error_message
,
335 const StartSyncCallback
& start_sync_callback
) OVERRIDE
;
337 // TODO(beng): Not an override, move somewhere else.
338 void SetDownloadShelfVisible(bool visible
);
339 virtual bool IsDownloadShelfVisible() const OVERRIDE
;
340 virtual DownloadShelf
* GetDownloadShelf() OVERRIDE
;
341 virtual void ConfirmBrowserCloseWithPendingDownloads(
343 Browser::DownloadClosePreventionType dialog_type
,
345 const base::Callback
<void(bool)>& callback
) OVERRIDE
;
346 virtual void UserChangedTheme() OVERRIDE
;
347 virtual int GetExtraRenderViewHeight() const OVERRIDE
;
348 virtual void WebContentsFocused(content::WebContents
* contents
) OVERRIDE
;
349 virtual void ShowWebsiteSettings(Profile
* profile
,
350 content::WebContents
* web_contents
,
352 const content::SSLStatus
& ssl
) OVERRIDE
;
353 virtual void ShowAppMenu() OVERRIDE
;
354 virtual bool PreHandleKeyboardEvent(
355 const content::NativeWebKeyboardEvent
& event
,
356 bool* is_keyboard_shortcut
) OVERRIDE
;
357 virtual void HandleKeyboardEvent(
358 const content::NativeWebKeyboardEvent
& event
) OVERRIDE
;
359 virtual void Cut() OVERRIDE
;
360 virtual void Copy() OVERRIDE
;
361 virtual void Paste() OVERRIDE
;
362 virtual WindowOpenDisposition
GetDispositionForPopupBounds(
363 const gfx::Rect
& bounds
) OVERRIDE
;
364 virtual FindBar
* CreateFindBar() OVERRIDE
;
365 virtual web_modal::WebContentsModalDialogHost
*
366 GetWebContentsModalDialogHost() OVERRIDE
;
367 virtual void ShowAvatarBubble(content::WebContents
* web_contents
,
368 const gfx::Rect
& rect
) OVERRIDE
;
369 virtual void ShowAvatarBubbleFromAvatarButton() OVERRIDE
;
370 virtual void ShowPasswordGenerationBubble(
371 const gfx::Rect
& rect
,
372 const autofill::PasswordForm
& form
,
373 autofill::PasswordGenerator
* password_generator
) OVERRIDE
;
374 virtual void OverscrollUpdate(int delta_y
) OVERRIDE
;
375 virtual int GetRenderViewHeightInsetWithDetachedBookmarkBar() OVERRIDE
;
377 // Overridden from BrowserWindowTesting:
378 virtual BookmarkBarView
* GetBookmarkBarView() const OVERRIDE
;
379 virtual LocationBarView
* GetLocationBarView() const OVERRIDE
;
380 virtual views::View
* GetTabContentsContainerView() const OVERRIDE
;
381 virtual ToolbarView
* GetToolbarView() const OVERRIDE
;
383 // Overridden from TabStripModelObserver:
384 virtual void TabDetachedAt(content::WebContents
* contents
,
386 virtual void TabDeactivated(content::WebContents
* contents
) OVERRIDE
;
387 virtual void TabStripEmpty() OVERRIDE
;
389 // Overridden from ui::AcceleratorProvider:
390 virtual bool GetAcceleratorForCommandId(int command_id
,
391 ui::Accelerator
* accelerator
) OVERRIDE
;
393 // Overridden from views::WidgetDelegate:
394 virtual bool CanResize() const OVERRIDE
;
395 virtual bool CanMaximize() const OVERRIDE
;
396 virtual bool CanActivate() const OVERRIDE
;
397 virtual base::string16
GetWindowTitle() const OVERRIDE
;
398 virtual base::string16
GetAccessibleWindowTitle() const OVERRIDE
;
399 virtual views::View
* GetInitiallyFocusedView() OVERRIDE
;
400 virtual bool ShouldShowWindowTitle() const OVERRIDE
;
401 virtual gfx::ImageSkia
GetWindowAppIcon() OVERRIDE
;
402 virtual gfx::ImageSkia
GetWindowIcon() OVERRIDE
;
403 virtual bool ShouldShowWindowIcon() const OVERRIDE
;
404 virtual bool ExecuteWindowsCommand(int command_id
) OVERRIDE
;
405 virtual std::string
GetWindowName() const OVERRIDE
;
406 virtual void SaveWindowPlacement(const gfx::Rect
& bounds
,
407 ui::WindowShowState show_state
) OVERRIDE
;
408 virtual bool GetSavedWindowPlacement(
409 const views::Widget
* widget
,
411 ui::WindowShowState
* show_state
) const OVERRIDE
;
412 virtual views::View
* GetContentsView() OVERRIDE
;
413 virtual views::ClientView
* CreateClientView(views::Widget
* widget
) OVERRIDE
;
414 virtual void OnWindowBeginUserBoundsChange() OVERRIDE
;
415 virtual void OnWidgetMove() OVERRIDE
;
416 virtual views::Widget
* GetWidget() OVERRIDE
;
417 virtual const views::Widget
* GetWidget() const OVERRIDE
;
418 virtual void GetAccessiblePanes(std::vector
<View
*>* panes
) OVERRIDE
;
420 // Overridden from views::WidgetObserver:
421 virtual void OnWidgetActivationChanged(views::Widget
* widget
,
422 bool active
) OVERRIDE
;
424 // Overridden from views::ClientView:
425 virtual bool CanClose() OVERRIDE
;
426 virtual int NonClientHitTest(const gfx::Point
& point
) OVERRIDE
;
427 virtual gfx::Size
GetMinimumSize() OVERRIDE
;
429 // InfoBarContainer::Delegate overrides
430 virtual SkColor
GetInfoBarSeparatorColor() const OVERRIDE
;
431 virtual void InfoBarContainerStateChanged(bool is_animating
) OVERRIDE
;
432 virtual bool DrawInfoBarArrows(int* x
) const OVERRIDE
;
434 // gfx::SysColorChangeListener overrides:
435 virtual void OnSysColorChange() OVERRIDE
;
437 // Overridden from views::View:
438 virtual const char* GetClassName() const OVERRIDE
;
439 virtual void Layout() OVERRIDE
;
440 virtual void PaintChildren(gfx::Canvas
* canvas
) OVERRIDE
;
441 virtual void ViewHierarchyChanged(
442 const ViewHierarchyChangedDetails
& details
) OVERRIDE
;
443 virtual void ChildPreferredSizeChanged(View
* child
) OVERRIDE
;
444 virtual void GetAccessibleState(ui::AccessibleViewState
* state
) OVERRIDE
;
446 // Overridden from ui::AcceleratorTarget:
447 virtual bool AcceleratorPressed(const ui::Accelerator
& accelerator
) OVERRIDE
;
449 // OmniboxPopupModelObserver overrides
450 virtual void OnOmniboxPopupShownOrHidden() OVERRIDE
;
452 // Testing interface:
453 views::View
* GetContentsContainerForTest() { return contents_container_
; }
454 views::WebView
* GetContentsWebViewForTest() { return contents_web_view_
; }
455 views::WebView
* GetDevToolsWebViewForTest() { return devtools_web_view_
; }
458 // Do not friend BrowserViewLayout. Use the BrowserViewLayoutDelegate
459 // interface to keep these two classes decoupled and testable.
460 friend class BrowserViewLayoutDelegateImpl
;
461 FRIEND_TEST_ALL_PREFIXES(BrowserViewTest
, BrowserView
);
462 FRIEND_TEST_ALL_PREFIXES(BrowserViewsAccessibilityTest
,
463 TestAboutChromeViewAccObj
);
465 enum FullscreenType
{
470 // Appends to |toolbars| a pointer to each AccessiblePaneView that
471 // can be traversed using F6, in the order they should be traversed.
472 void GetAccessiblePanes(std::vector
<views::AccessiblePaneView
*>* panes
);
474 // Constructs and initializes the child views.
477 // Callback for the loading animation(s) associated with this view.
478 void LoadingAnimationCallback();
480 // LoadCompleteListener::Delegate implementation. Creates and initializes the
481 // |jumplist_| after the first page load.
482 virtual void OnLoadCompleted() OVERRIDE
;
484 // Returns the BrowserViewLayout.
485 BrowserViewLayout
* GetBrowserViewLayout() const;
487 // Returns the ContentsLayoutManager.
488 ContentsLayoutManager
* GetContentsLayoutManager() const;
490 // Layout the Status Bubble.
491 void LayoutStatusBubble();
493 // Prepare to show the Bookmark Bar for the specified WebContents.
494 // Returns true if the Bookmark Bar can be shown (i.e. it's supported for this
495 // Browser type) and there should be a subsequent re-layout to show it.
496 // |contents| can be NULL.
497 bool MaybeShowBookmarkBar(content::WebContents
* contents
);
499 // Moves the bookmark bar view to the specified parent, which may be NULL,
500 // |this|, or |top_container_|. Ensures that |top_container_| stays in front
501 // of |bookmark_bar_view_|.
502 void SetBookmarkBarParent(views::View
* new_parent
);
504 // Prepare to show an Info Bar for the specified WebContents. Returns
505 // true if there is an Info Bar to show and one is supported for this Browser
506 // type, and there should be a subsequent re-layout to show it.
507 // |contents| can be NULL.
508 bool MaybeShowInfoBar(content::WebContents
* contents
);
510 // Updates devtools window for given contents. This method will show docked
511 // devtools window for inspected |web_contents| that has docked devtools
512 // and hide it for NULL or not inspected |web_contents|. It will also make
513 // sure devtools window size and position are restored for given tab.
514 // This method will not update actual DevTools WebContents, if not
515 // |update_devtools_web_contents|. In this case, manual update is required.
516 void UpdateDevToolsForContents(content::WebContents
* web_contents
,
517 bool update_devtools_web_contents
);
519 // Updates various optional child Views, e.g. Bookmarks Bar, Info Bar or the
520 // Download Shelf in response to a change notification from the specified
521 // |contents|. |contents| can be NULL. In this case, all optional UI will be
523 void UpdateUIForContents(content::WebContents
* contents
);
525 // Invoked to update the necessary things when our fullscreen state changes
526 // to |fullscreen|. On Windows this is invoked immediately when we toggle the
527 // full screen state. On Linux changing the fullscreen state is async, so we
528 // ask the window to change its fullscreen state, then when we get
529 // notification that it succeeded this method is invoked.
530 // If |url| is not empty, it is the URL of the page that requested fullscreen
531 // (via the fullscreen JS API).
532 // |bubble_type| determines what should be shown in the fullscreen exit
534 void ProcessFullscreen(bool fullscreen
,
535 FullscreenType fullscreen_type
,
537 FullscreenExitBubbleType bubble_type
);
539 // Returns whether immmersive fullscreen should replace fullscreen. This
540 // should only occur for "browser-fullscreen" for tabbed-typed windows (not
541 // for tab-fullscreen and not for app/popup type windows).
542 bool ShouldUseImmersiveFullscreenForUrl(const GURL
& url
) const;
544 // Copy the accelerator table from the app resources into something we can
546 void LoadAccelerators();
548 // Retrieves the command id for the specified Windows app command.
549 int GetCommandIDForAppCommandID(int app_command_id
) const;
551 // Initialize the hung plugin detector.
552 void InitHangMonitor();
554 // Possibly records a user metrics action corresponding to the passed-in
555 // accelerator. Only implemented for Chrome OS, where we're interested in
556 // learning about how frequently the top-row keys are used.
557 void UpdateAcceleratorMetrics(const ui::Accelerator
& accelerator
,
560 // Calls |method| which is either RenderWidgetHost::Cut, ::Copy, or ::Paste,
561 // first trying the content WebContents, then the devtools WebContents, and
562 // lastly the Views::Textfield if one is focused.
563 void DoCutCopyPaste(void (content::RenderWidgetHost::*method
)(),
566 // Calls |method| which is either RenderWidgetHost::Cut, ::Copy, or ::Paste on
567 // the given WebContents, returning true if it consumed the event.
568 bool DoCutCopyPasteForWebContents(
569 content::WebContents
* contents
,
570 void (content::RenderWidgetHost::*method
)());
572 // Shows the next app-modal dialog box, if there is one to be shown, or moves
573 // an existing showing one to the front.
574 void ActivateAppModalDialog() const;
576 // Returns the max top arrow height for infobar.
577 int GetMaxTopInfoBarArrowHeight();
579 // Last focused view that issued a tab traversal.
580 int last_focused_view_storage_id_
;
582 // The BrowserFrame that hosts this view.
583 BrowserFrame
* frame_
;
585 // The Browser object we are associated with.
586 scoped_ptr
<Browser
> browser_
;
588 // BrowserView layout (LTR one is pictured here).
590 // --------------------------------------------------------------------
591 // | TopContainerView (top_container_) |
592 // | -------------------------------------------------------------- |
593 // | | Tabs (tabstrip_) | |
594 // | |------------------------------------------------------------| |
595 // | | Navigation buttons, address bar, menu (toolbar_) | |
596 // | -------------------------------------------------------------- |
597 // |------------------------------------------------------------------|
598 // | All infobars (infobar_container_) [1] |
599 // |------------------------------------------------------------------|
600 // | Bookmarks (bookmark_bar_view_) [1] |
601 // |------------------------------------------------------------------|
602 // | Contents container (contents_container_) |
603 // | -------------------------------------------------------------- |
604 // | | devtools_web_view_ | |
605 // | |------------------------------------------------------------| |
606 // | | contents_web_view_ | |
607 // | -------------------------------------------------------------- |
608 // |------------------------------------------------------------------|
609 // | Active downloads (download_shelf_) |
610 // --------------------------------------------------------------------
612 // [1] The bookmark bar and info bar are swapped when on the new tab page.
613 // Additionally when the bookmark bar is detached, contents_container_ is
614 // positioned on top of the bar while the tab's contents are placed below
615 // the bar. This allows the find bar to always align with the top of
616 // contents_container_ regardless if there's bookmark or info bars.
618 // The view that manages the tab strip, toolbar, and sometimes the bookmark
619 // bar. Stacked top in the view hiearachy so it can be used to slide out
620 // the top views in immersive fullscreen.
621 TopContainerView
* top_container_
;
626 // The Toolbar containing the navigation buttons, menus and the address bar.
627 ToolbarView
* toolbar_
;
629 // This button sits next to the tabs on the right hand side and it is used
630 // only in windows metro metro mode to allow the user to flip among browser
632 views::Button
* window_switcher_button_
;
634 // The Bookmark Bar View for this window. Lazily created. May be NULL for
635 // non-tabbed browsers like popups. May not be visible.
636 scoped_ptr
<BookmarkBarView
> bookmark_bar_view_
;
638 // The do-nothing view which controls the z-order of the find bar widget
639 // relative to views which paint into layers and views with an associated
641 View
* find_bar_host_view_
;
643 // The download shelf view (view at the bottom of the page).
644 scoped_ptr
<DownloadShelfView
> download_shelf_
;
646 // The InfoBarContainerView that contains InfoBars for the current tab.
647 InfoBarContainerView
* infobar_container_
;
649 // The view that contains the selected WebContents.
650 views::WebView
* contents_web_view_
;
652 // The view that contains devtools window for the selected WebContents.
653 views::WebView
* devtools_web_view_
;
655 // The view managing the devtools and contents positions.
656 // Handled by ContentsLayoutManager.
657 views::View
* contents_container_
;
659 // Docked devtools window instance. NULL when current tab is not inspected
660 // or is inspected with undocked version of DevToolsWindow.
661 DevToolsWindow
* devtools_window_
;
663 // Tracks and stores the last focused view which is not the
664 // devtools_web_view_ or any of its children. Used to restore focus once
665 // the devtools_web_view_ is hidden.
666 scoped_ptr
<views::ExternalFocusTracker
> devtools_focus_tracker_
;
668 // The Status information bubble that appears at the bottom of the window.
669 scoped_ptr
<StatusBubbleViews
> status_bubble_
;
671 // A mapping between accelerators and commands.
672 std::map
<ui::Accelerator
, int> accelerator_table_
;
674 // True if we have already been initialized.
677 // True when in ProcessFullscreen(). The flag is used to avoid reentrance and
678 // to ignore requests to layout while in ProcessFullscreen() to reduce
680 bool in_process_fullscreen_
;
682 scoped_ptr
<FullscreenExitBubbleViews
> fullscreen_bubble_
;
685 // This object is used to perform periodic actions in a worker
686 // thread. It is currently used to monitor hung plugin windows.
687 WorkerThreadTicker ticker_
;
689 // This object is initialized with the frame window HWND. This
690 // object is also passed as a tick handler with the ticker_ object.
691 // It is used to periodically monitor for hung plugin windows
692 HungWindowDetector hung_window_detector_
;
694 // This object is invoked by hung_window_detector_ when it detects a hung
696 HungPluginAction hung_plugin_action_
;
698 // Helper class to listen for completion of first page load.
699 scoped_ptr
<LoadCompleteListener
> load_complete_listener_
;
701 // The custom JumpList for Windows 7.
702 scoped_refptr
<JumpList
> jumplist_
;
705 // The timer used to update frames for the Loading Animation.
706 base::RepeatingTimer
<BrowserView
> loading_animation_timer_
;
708 views::UnhandledKeyboardEventHandler unhandled_keyboard_event_handler_
;
710 // Used to measure the loading spinner animation rate.
711 base::TimeTicks last_animation_time_
;
713 // If this flag is set then SetFocusToLocationBar() will set focus to the
714 // location bar even if the browser window is not active.
715 bool force_location_bar_focus_
;
717 scoped_ptr
<ImmersiveModeController
> immersive_mode_controller_
;
719 scoped_ptr
<ScrollEndEffectController
> scroll_end_effect_controller_
;
721 gfx::ScopedSysColorChangeListener color_change_listener_
;
723 mutable base::WeakPtrFactory
<BrowserView
> activate_modal_dialog_factory_
;
725 DISALLOW_COPY_AND_ASSIGN(BrowserView
);
728 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_VIEW_H_