Home | History | Annotate | Download | only in frame
      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.
      4 
      5 #ifndef CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_VIEW_H_
      6 #define CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_VIEW_H_
      7 
      8 #include <map>
      9 #include <string>
     10 #include <vector>
     11 
     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/single_split_view_listener.h"
     32 #include "ui/views/controls/webview/unhandled_keyboard_event_handler.h"
     33 #include "ui/views/widget/widget_delegate.h"
     34 #include "ui/views/widget/widget_observer.h"
     35 #include "ui/views/window/client_view.h"
     36 
     37 #if defined(OS_WIN)
     38 #include "chrome/browser/hang_monitor/hung_plugin_action.h"
     39 #include "chrome/browser/hang_monitor/hung_window_detector.h"
     40 #endif
     41 
     42 // NOTE: For more information about the objects and files in this directory,
     43 // view: http://dev.chromium.org/developers/design-documents/browser-window
     44 
     45 class BookmarkBarView;
     46 class Browser;
     47 class BrowserViewLayout;
     48 class ContentsContainer;
     49 class DownloadShelfView;
     50 class FullscreenExitBubbleViews;
     51 class InfoBarContainerView;
     52 class LocationBarView;
     53 class StatusBubbleViews;
     54 class SearchViewController;
     55 class TabStrip;
     56 class TabStripModel;
     57 class ToolbarView;
     58 class TopContainerView;
     59 
     60 #if defined(OS_WIN)
     61 class JumpList;
     62 #endif
     63 
     64 #if defined(USE_ASH)
     65 class BrowserLauncherItemController;
     66 #endif
     67 
     68 namespace autofill {
     69 class PasswordGenerator;
     70 }
     71 
     72 namespace content {
     73 class RenderWidgetHost;
     74 }
     75 
     76 namespace extensions {
     77 class Extension;
     78 }
     79 
     80 namespace views {
     81 class AccessiblePaneView;
     82 class ExternalFocusTracker;
     83 class WebView;
     84 }
     85 
     86 ///////////////////////////////////////////////////////////////////////////////
     87 // BrowserView
     88 //
     89 //  A ClientView subclass that provides the contents of a browser window,
     90 //  including the TabStrip, toolbars, download shelves, the content area etc.
     91 //
     92 class BrowserView : public BrowserWindow,
     93                     public BrowserWindowTesting,
     94                     public TabStripModelObserver,
     95                     public ui::AcceleratorProvider,
     96                     public views::WidgetDelegate,
     97                     public views::WidgetObserver,
     98                     public views::ClientView,
     99                     public ImmersiveModeController::Delegate,
    100                     public InfoBarContainer::Delegate,
    101                     public views::SingleSplitViewListener,
    102                     public gfx::SysColorChangeListener,
    103                     public LoadCompleteListener::Delegate,
    104                     public OmniboxPopupModelObserver {
    105  public:
    106   // The browser view's class name.
    107   static const char kViewClassName[];
    108 
    109   BrowserView();
    110   virtual ~BrowserView();
    111 
    112   // Takes ownership of |browser|.
    113   void Init(Browser* browser);
    114 
    115   void set_frame(BrowserFrame* frame) { frame_ = frame; }
    116   BrowserFrame* frame() const { return frame_; }
    117 
    118   // Returns a pointer to the BrowserView* interface implementation (an
    119   // instance of this object, typically) for a given native window, or NULL if
    120   // there is no such association.
    121   //
    122   // Don't use this unless you only have a NativeWindow. In nearly all
    123   // situations plumb through browser and use it.
    124   static BrowserView* GetBrowserViewForNativeWindow(gfx::NativeWindow window);
    125 
    126   // Returns the BrowserView used for the specified Browser.
    127   static BrowserView* GetBrowserViewForBrowser(const Browser* browser);
    128 
    129   // Returns a Browser instance of this view.
    130   Browser* browser() { return browser_.get(); }
    131 
    132   // Initializes (or re-initializes) the status bubble.  We try to only create
    133   // the bubble once and re-use it for the life of the browser, but certain
    134   // events (such as changing enabling/disabling Aero on Win) can force a need
    135   // to change some of the bubble's creation parameters.
    136   void InitStatusBubble();
    137 
    138   // Returns the apparent bounds of the toolbar, in BrowserView coordinates.
    139   // These differ from |toolbar_.bounds()| in that they match where the toolbar
    140   // background image is drawn -- slightly outside the "true" bounds
    141   // horizontally. Note that this returns the bounds for the toolbar area.
    142   gfx::Rect GetToolbarBounds() const;
    143 
    144   // Returns the bounds of the content area, in the coordinates of the
    145   // BrowserView's parent.
    146   gfx::Rect GetClientAreaBounds() const;
    147 
    148   // Returns the constraining bounding box that should be used to lay out the
    149   // FindBar within. This is _not_ the size of the find bar, just the bounding
    150   // box it should be laid out within. The coordinate system of the returned
    151   // rect is in the coordinate system of the frame, since the FindBar is a child
    152   // window.
    153   gfx::Rect GetFindBarBoundingBox() const;
    154 
    155   // Returns the preferred height of the TabStrip. Used to position the OTR
    156   // avatar icon.
    157   int GetTabStripHeight() const;
    158 
    159   // Takes some view's origin (relative to this BrowserView) and offsets it such
    160   // that it can be used as the source origin for seamlessly tiling the toolbar
    161   // background image over that view.
    162   gfx::Point OffsetPointForToolbarBackgroundImage(
    163       const gfx::Point& point) const;
    164 
    165   // Container for the tabstrip, toolbar, etc.
    166   TopContainerView* top_container() { return top_container_; }
    167 
    168   // Accessor for the TabStrip.
    169   TabStrip* tabstrip() { return tabstrip_; }
    170 
    171   // Accessor for the Toolbar.
    172   ToolbarView* toolbar() { return toolbar_; }
    173 
    174   // Bookmark bar may be NULL, for example for pop-ups.
    175   BookmarkBarView* bookmark_bar() { return bookmark_bar_view_.get(); }
    176 
    177   // Returns the do-nothing view which controls the z-order of the find bar
    178   // widget relative to views which paint into layers and views which have an
    179   // associated NativeView. The presence / visibility of this view is not
    180   // indicative of the visibility of the find bar widget or even whether
    181   // FindBarController is initialized.
    182   View* find_bar_host_view() { return find_bar_host_view_; }
    183 
    184   // Accessor for the InfobarContainer.
    185   InfoBarContainerView* infobar_container() { return infobar_container_; }
    186 
    187   // Accessor for the FullscreenExitBubbleViews.
    188   FullscreenExitBubbleViews* fullscreen_exit_bubble() {
    189     return fullscreen_bubble_.get();
    190   }
    191 
    192   // Returns true if various window components are visible.
    193   bool IsTabStripVisible() const;
    194 
    195   // Returns true if the profile associated with this Browser window is
    196   // incognito.
    197   bool IsOffTheRecord() const;
    198 
    199   // Returns the resource ID to use for the OTR icon, which depends on
    200   // which layout is being shown and whether we are full-screen.
    201   int GetOTRIconResourceID() const;
    202 
    203   // Returns true if the profile associated with this Browser window is
    204   // a guest session.
    205   bool IsGuestSession() const;
    206 
    207   // Returns true if the non-client view should render an avatar icon.
    208   bool ShouldShowAvatar() const;
    209 
    210   // Provides the containing frame with the accelerator for the specified
    211   // command id. This can be used to provide menu item shortcut hints etc.
    212   // Returns true if an accelerator was found for the specified |cmd_id|, false
    213   // otherwise.
    214   bool GetAccelerator(int cmd_id, ui::Accelerator* accelerator);
    215 
    216   // Returns true if the specificed |accelerator| is registered with this view.
    217   bool IsAcceleratorRegistered(const ui::Accelerator& accelerator);
    218 
    219   // Returns the active WebContents. Used by our NonClientView's
    220   // TabIconView::TabContentsProvider implementations.
    221   // TODO(beng): exposing this here is a bit bogus, since it's only used to
    222   // determine loading state. It'd be nicer if we could change this to be
    223   // bool IsSelectedTabLoading() const; or something like that. We could even
    224   // move it to a WindowDelegate subclass.
    225   content::WebContents* GetActiveWebContents() const;
    226 
    227   // Retrieves the icon to use in the frame to indicate an OTR window.
    228   gfx::ImageSkia GetOTRAvatarIcon() const;
    229 
    230   // Returns true if the Browser object associated with this BrowserView is a
    231   // tabbed-type window (i.e. a browser window, not an app or popup).
    232   bool IsBrowserTypeNormal() const {
    233     return browser_->is_type_tabbed();
    234   }
    235 
    236   // See ImmersiveModeController for description.
    237   ImmersiveModeController* immersive_mode_controller() const {
    238     return immersive_mode_controller_.get();
    239   }
    240 
    241   // Restores the focused view. This is also used to set the initial focus
    242   // when a new browser window is created.
    243   void RestoreFocus();
    244 
    245   void SetWindowSwitcherButton(views::Button* button);
    246 
    247   views::Button* window_switcher_button() {
    248     return window_switcher_button_;
    249   }
    250 
    251   // Called from BookmarkBarView/DownloadShelfView during their show/hide
    252   // animations.
    253   void ToolbarSizeChanged(bool is_animating);
    254 
    255 #if defined(USE_ASH)
    256   // Test support.
    257   // Note: This is only needed to be BrowserLauncherItemController instead of
    258   // LauncherItemController because of the "favicon_loader" member - to be more
    259   // exact that member function is the only one being called.
    260   // TODO(skuhne): Remove once per-app is default.
    261   BrowserLauncherItemController* launcher_item_controller() const {
    262     return launcher_item_controller_.get();
    263   }
    264 #endif
    265 
    266   // Overridden from BrowserWindow:
    267   virtual void Show() OVERRIDE;
    268   virtual void ShowInactive() OVERRIDE;
    269   virtual void Hide() OVERRIDE;
    270   virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE;
    271   virtual void Close() OVERRIDE;
    272   virtual void Activate() OVERRIDE;
    273   virtual void Deactivate() OVERRIDE;
    274   virtual bool IsActive() const OVERRIDE;
    275   virtual void FlashFrame(bool flash) OVERRIDE;
    276   virtual bool IsAlwaysOnTop() const OVERRIDE;
    277   virtual gfx::NativeWindow GetNativeWindow() OVERRIDE;
    278   virtual BrowserWindowTesting* GetBrowserWindowTesting() OVERRIDE;
    279   virtual StatusBubble* GetStatusBubble() OVERRIDE;
    280   virtual void UpdateTitleBar() OVERRIDE;
    281   virtual void BookmarkBarStateChanged(
    282       BookmarkBar::AnimateChangeType change_type) OVERRIDE;
    283   virtual void UpdateDevTools() OVERRIDE;
    284   virtual void UpdateLoadingAnimations(bool should_animate) OVERRIDE;
    285   virtual void SetStarredState(bool is_starred) OVERRIDE;
    286   virtual void ZoomChangedForActiveTab(bool can_show_bubble) OVERRIDE;
    287   virtual gfx::Rect GetRestoredBounds() const OVERRIDE;
    288   virtual ui::WindowShowState GetRestoredState() const OVERRIDE;
    289   virtual gfx::Rect GetBounds() const OVERRIDE;
    290   virtual bool IsMaximized() const OVERRIDE;
    291   virtual bool IsMinimized() const OVERRIDE;
    292   virtual void Maximize() OVERRIDE;
    293   virtual void Minimize() OVERRIDE;
    294   virtual void Restore() OVERRIDE;
    295   virtual void EnterFullscreen(
    296       const GURL& url, FullscreenExitBubbleType bubble_type) OVERRIDE;
    297   virtual void ExitFullscreen() OVERRIDE;
    298   virtual void UpdateFullscreenExitBubbleContent(
    299       const GURL& url,
    300       FullscreenExitBubbleType bubble_type) OVERRIDE;
    301   virtual bool ShouldHideUIForFullscreen() const OVERRIDE;
    302   virtual bool IsFullscreen() const OVERRIDE;
    303   virtual bool IsFullscreenBubbleVisible() const OVERRIDE;
    304 #if defined(OS_WIN)
    305   virtual void SetMetroSnapMode(bool enable) OVERRIDE;
    306   virtual bool IsInMetroSnapMode() const OVERRIDE;
    307 #endif
    308   virtual LocationBar* GetLocationBar() const OVERRIDE;
    309   virtual void SetFocusToLocationBar(bool select_all) OVERRIDE;
    310   virtual void UpdateReloadStopState(bool is_loading, bool force) OVERRIDE;
    311   virtual void UpdateToolbar(content::WebContents* contents,
    312                              bool should_restore_state) OVERRIDE;
    313   virtual void FocusToolbar() OVERRIDE;
    314   virtual void FocusAppMenu() OVERRIDE;
    315   virtual void FocusBookmarksToolbar() OVERRIDE;
    316   virtual void FocusInfobars() OVERRIDE;
    317   virtual void RotatePaneFocus(bool forwards) OVERRIDE;
    318   virtual void DestroyBrowser() OVERRIDE;
    319   virtual bool IsBookmarkBarVisible() const OVERRIDE;
    320   virtual bool IsBookmarkBarAnimating() const OVERRIDE;
    321   virtual bool IsTabStripEditable() const OVERRIDE;
    322   virtual bool IsToolbarVisible() const OVERRIDE;
    323   virtual gfx::Rect GetRootWindowResizerRect() const OVERRIDE;
    324   virtual void DisableInactiveFrame() OVERRIDE;
    325   virtual void ConfirmAddSearchProvider(TemplateURL* template_url,
    326                                         Profile* profile) OVERRIDE;
    327   virtual void ToggleBookmarkBar() OVERRIDE;
    328   virtual void ShowUpdateChromeDialog() OVERRIDE;
    329   virtual void ShowBookmarkBubble(const GURL& url,
    330                                   bool already_bookmarked) OVERRIDE;
    331   virtual void ShowBookmarkPrompt() OVERRIDE;
    332 #if defined(ENABLE_ONE_CLICK_SIGNIN)
    333   virtual void ShowOneClickSigninBubble(
    334       OneClickSigninBubbleType type,
    335       const string16& email,
    336       const string16& error_message,
    337       const StartSyncCallback& start_sync_callback) OVERRIDE;
    338 #endif
    339   // TODO(beng): Not an override, move somewhere else.
    340   void SetDownloadShelfVisible(bool visible);
    341   virtual bool IsDownloadShelfVisible() const OVERRIDE;
    342   virtual DownloadShelf* GetDownloadShelf() OVERRIDE;
    343   virtual void ConfirmBrowserCloseWithPendingDownloads() OVERRIDE;
    344   virtual void UserChangedTheme() OVERRIDE;
    345   virtual int GetExtraRenderViewHeight() const OVERRIDE;
    346   virtual void WebContentsFocused(content::WebContents* contents) OVERRIDE;
    347   virtual void ShowWebsiteSettings(Profile* profile,
    348                                    content::WebContents* web_contents,
    349                                    const GURL& url,
    350                                    const content::SSLStatus& ssl) OVERRIDE;
    351   virtual void ShowAppMenu() OVERRIDE;
    352   virtual bool PreHandleKeyboardEvent(
    353       const content::NativeWebKeyboardEvent& event,
    354       bool* is_keyboard_shortcut) OVERRIDE;
    355   virtual void HandleKeyboardEvent(
    356       const content::NativeWebKeyboardEvent& event) OVERRIDE;
    357   virtual void ShowCreateChromeAppShortcutsDialog(
    358       Profile*, const extensions::Extension* app) 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 content::PasswordForm& form,
    373       autofill::PasswordGenerator* password_generator) OVERRIDE;
    374   virtual void OverscrollUpdate(int delta_y) OVERRIDE;
    375 
    376   // Overridden from BrowserWindowTesting:
    377   virtual BookmarkBarView* GetBookmarkBarView() const OVERRIDE;
    378   virtual LocationBarView* GetLocationBarView() const OVERRIDE;
    379   virtual views::View* GetTabContentsContainerView() const OVERRIDE;
    380   virtual ToolbarView* GetToolbarView() const OVERRIDE;
    381 
    382   // Overridden from TabStripModelObserver:
    383   virtual void TabDetachedAt(content::WebContents* contents,
    384                              int index) OVERRIDE;
    385   virtual void TabDeactivated(content::WebContents* contents) OVERRIDE;
    386   virtual void ActiveTabChanged(content::WebContents* old_contents,
    387                                 content::WebContents* new_contents,
    388                                 int index,
    389                                 int reason) OVERRIDE;
    390   virtual void TabStripEmpty() OVERRIDE;
    391 
    392   // Overridden from ui::AcceleratorProvider:
    393   virtual bool GetAcceleratorForCommandId(int command_id,
    394       ui::Accelerator* accelerator) OVERRIDE;
    395 
    396   // Overridden from views::WidgetDelegate:
    397   virtual bool CanResize() const OVERRIDE;
    398   virtual bool CanMaximize() const OVERRIDE;
    399   virtual bool CanActivate() const OVERRIDE;
    400   virtual string16 GetWindowTitle() const OVERRIDE;
    401   virtual string16 GetAccessibleWindowTitle() const OVERRIDE;
    402   virtual views::View* GetInitiallyFocusedView() OVERRIDE;
    403   virtual bool ShouldShowWindowTitle() const OVERRIDE;
    404   virtual gfx::ImageSkia GetWindowAppIcon() OVERRIDE;
    405   virtual gfx::ImageSkia GetWindowIcon() OVERRIDE;
    406   virtual bool ShouldShowWindowIcon() const OVERRIDE;
    407   virtual bool ExecuteWindowsCommand(int command_id) OVERRIDE;
    408   virtual std::string GetWindowName() const OVERRIDE;
    409   virtual void SaveWindowPlacement(const gfx::Rect& bounds,
    410                                    ui::WindowShowState show_state) OVERRIDE;
    411   virtual bool GetSavedWindowPlacement(
    412       gfx::Rect* bounds,
    413       ui::WindowShowState* show_state) const OVERRIDE;
    414   virtual views::View* GetContentsView() OVERRIDE;
    415   virtual views::ClientView* CreateClientView(views::Widget* widget) OVERRIDE;
    416   virtual void OnWindowBeginUserBoundsChange() OVERRIDE;
    417   virtual void OnWidgetMove() OVERRIDE;
    418   virtual views::Widget* GetWidget() OVERRIDE;
    419   virtual const views::Widget* GetWidget() const OVERRIDE;
    420   virtual void GetAccessiblePanes(std::vector<View*>* panes) OVERRIDE;
    421 
    422   // Overridden from views::WidgetObserver:
    423   virtual void OnWidgetActivationChanged(views::Widget* widget,
    424                                          bool active) OVERRIDE;
    425 
    426   // Overridden from views::ClientView:
    427   virtual bool CanClose() OVERRIDE;
    428   virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE;
    429   virtual gfx::Size GetMinimumSize() OVERRIDE;
    430 
    431   // ImmersiveModeController::Delegate overrides:
    432   virtual BookmarkBarView* GetBookmarkBar() OVERRIDE;
    433   virtual FullscreenController* GetFullscreenController() OVERRIDE;
    434   virtual void FullscreenStateChanged() OVERRIDE;
    435   virtual void SetImmersiveStyle(bool immersive) OVERRIDE;
    436   virtual content::WebContents* GetWebContents() OVERRIDE;
    437 
    438   // InfoBarContainer::Delegate overrides
    439   virtual SkColor GetInfoBarSeparatorColor() const OVERRIDE;
    440   virtual void InfoBarContainerStateChanged(bool is_animating) OVERRIDE;
    441   virtual bool DrawInfoBarArrows(int* x) const OVERRIDE;
    442 
    443   // views::SingleSplitViewListener overrides:
    444   virtual bool SplitHandleMoved(views::SingleSplitView* sender) OVERRIDE;
    445 
    446   // gfx::SysColorChangeListener overrides:
    447   virtual void OnSysColorChange() OVERRIDE;
    448 
    449   // Overridden from views::View:
    450   virtual const char* GetClassName() const OVERRIDE;
    451   virtual void Layout() OVERRIDE;
    452   virtual void PaintChildren(gfx::Canvas* canvas) OVERRIDE;
    453   virtual void ViewHierarchyChanged(
    454       const ViewHierarchyChangedDetails& details) OVERRIDE;
    455   virtual void ChildPreferredSizeChanged(View* child) OVERRIDE;
    456   virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
    457 
    458   // Overridden from ui::AcceleratorTarget:
    459   virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE;
    460 
    461   // OmniboxPopupModelObserver overrides
    462   virtual void OnOmniboxPopupShownOrHidden() OVERRIDE;
    463 
    464   // Testing interface:
    465   views::SingleSplitView* GetContentsSplitForTest() { return contents_split_; }
    466   ContentsContainer* GetContentsContainerForTest() {
    467     return contents_container_;
    468   }
    469   views::WebView* GetContentsWebViewForTest() { return contents_web_view_; }
    470 
    471  private:
    472   // Do not friend BrowserViewLayout. Use the BrowserViewLayoutDelegate
    473   // interface to keep these two classes decoupled and testable.
    474   friend class BrowserViewLayoutDelegateImpl;
    475   FRIEND_TEST_ALL_PREFIXES(BrowserViewTest, BrowserView);
    476   FRIEND_TEST_ALL_PREFIXES(BrowserViewsAccessibilityTest,
    477                            TestAboutChromeViewAccObj);
    478 
    479   enum FullscreenType {
    480     FOR_DESKTOP,
    481     FOR_METRO
    482   };
    483 
    484   // Appends to |toolbars| a pointer to each AccessiblePaneView that
    485   // can be traversed using F6, in the order they should be traversed.
    486   void GetAccessiblePanes(std::vector<views::AccessiblePaneView*>* panes);
    487 
    488   // Constructs and initializes the child views.
    489   void InitViews();
    490 
    491   // Callback for the loading animation(s) associated with this view.
    492   void LoadingAnimationCallback();
    493 
    494   // LoadCompleteListener::Delegate implementation. Creates and initializes the
    495   // |jumplist_| after the first page load.
    496   virtual void OnLoadCompleted() OVERRIDE;
    497 
    498   // Returns the BrowserViewLayout.
    499   BrowserViewLayout* GetBrowserViewLayout() const;
    500 
    501   // Layout the Status Bubble.
    502   void LayoutStatusBubble();
    503 
    504   // Prepare to show the Bookmark Bar for the specified WebContents.
    505   // Returns true if the Bookmark Bar can be shown (i.e. it's supported for this
    506   // Browser type) and there should be a subsequent re-layout to show it.
    507   // |contents| can be NULL.
    508   bool MaybeShowBookmarkBar(content::WebContents* contents);
    509 
    510   // Moves the bookmark bar view to the specified parent, which may be NULL,
    511   // |this|, or |top_container_|. Ensures that |top_container_| stays in front
    512   // of |bookmark_bar_view_|.
    513   void SetBookmarkBarParent(views::View* new_parent);
    514 
    515   // Prepare to show an Info Bar for the specified WebContents. Returns
    516   // true if there is an Info Bar to show and one is supported for this Browser
    517   // type, and there should be a subsequent re-layout to show it.
    518   // |contents| can be NULL.
    519   bool MaybeShowInfoBar(content::WebContents* contents);
    520 
    521   // Updates devtools window for given contents. This method will show docked
    522   // devtools window for inspected |web_contents| that has docked devtools
    523   // and hide it for NULL or not inspected |web_contents|. It will also make
    524   // sure devtools window size and position are restored for given tab.
    525   void UpdateDevToolsForContents(content::WebContents* web_contents);
    526 
    527   // Shows docked devtools.
    528   void ShowDevToolsContainer();
    529 
    530   // Hides docked devtools.
    531   void HideDevToolsContainer();
    532 
    533   // Reads split position from the current tab's devtools window and applies
    534   // it to the devtools split.
    535   void UpdateDevToolsSplitPosition();
    536 
    537   // Updates various optional child Views, e.g. Bookmarks Bar, Info Bar or the
    538   // Download Shelf in response to a change notification from the specified
    539   // |contents|. |contents| can be NULL. In this case, all optional UI will be
    540   // removed.
    541   void UpdateUIForContents(content::WebContents* contents);
    542 
    543   // Invoked to update the necessary things when our fullscreen state changes
    544   // to |fullscreen|. On Windows this is invoked immediately when we toggle the
    545   // full screen state. On Linux changing the fullscreen state is async, so we
    546   // ask the window to change its fullscreen state, then when we get
    547   // notification that it succeeded this method is invoked.
    548   // If |url| is not empty, it is the URL of the page that requested fullscreen
    549   // (via the fullscreen JS API).
    550   // |bubble_type| determines what should be shown in the fullscreen exit
    551   // bubble.
    552   void ProcessFullscreen(bool fullscreen,
    553                          FullscreenType fullscreen_type,
    554                          const GURL& url,
    555                          FullscreenExitBubbleType bubble_type);
    556 
    557   // Returns whether immmersive fullscreen should replace fullscreen. This
    558   // should only occur for "browser-fullscreen" for tabbed-typed windows (not
    559   // for tab-fullscreen and not for app/popup type windows).
    560   bool ShouldUseImmersiveFullscreenForUrl(const GURL& url) const;
    561 
    562   // Copy the accelerator table from the app resources into something we can
    563   // use.
    564   void LoadAccelerators();
    565 
    566   // Retrieves the command id for the specified Windows app command.
    567   int GetCommandIDForAppCommandID(int app_command_id) const;
    568 
    569   // Initialize the hung plugin detector.
    570   void InitHangMonitor();
    571 
    572   // Possibly records a user metrics action corresponding to the passed-in
    573   // accelerator.  Only implemented for Chrome OS, where we're interested in
    574   // learning about how frequently the top-row keys are used.
    575   void UpdateAcceleratorMetrics(const ui::Accelerator& accelerator,
    576                                 int command_id);
    577 
    578   // Create an icon for this window in the launcher (currently only for Ash).
    579   void CreateLauncherIcon();
    580 
    581   // Calls |method| which is either RenderWidgetHost::Cut, ::Copy, or ::Paste,
    582   // first trying the content WebContents, then the devtools WebContents, and
    583   // lastly the Views::Textfield if one is focused.
    584   // |windows_msg_id| is temporary until Win Aura is the default on Windows,
    585   // since until then the omnibox doesn't use Views::Textfield.
    586   void DoCutCopyPaste(void (content::RenderWidgetHost::*method)(),
    587 #if defined(OS_WIN)
    588                       int windows_msg_id,
    589 #endif
    590                       int command_id);
    591 
    592   // Calls |method| which is either RenderWidgetHost::Cut, ::Copy, or ::Paste on
    593   // the given WebContents, returning true if it consumed the event.
    594   bool DoCutCopyPasteForWebContents(
    595       content::WebContents* contents,
    596       void (content::RenderWidgetHost::*method)());
    597 
    598   // Shows the next app-modal dialog box, if there is one to be shown, or moves
    599   // an existing showing one to the front.
    600   void ActivateAppModalDialog() const;
    601 
    602   // Returns the max top arrow height for infobar.
    603   int GetMaxTopInfoBarArrowHeight();
    604 
    605   // Last focused view that issued a tab traversal.
    606   int last_focused_view_storage_id_;
    607 
    608   // The BrowserFrame that hosts this view.
    609   BrowserFrame* frame_;
    610 
    611   // The Browser object we are associated with.
    612   scoped_ptr<Browser> browser_;
    613 
    614   // BrowserView layout (LTR one is pictured here).
    615   //
    616   // --------------------------------------------------------------------
    617   // | TopContainerView (top_container_)                                |
    618   // |  --------------------------------------------------------------  |
    619   // |  | Tabs (tabstrip_)                                           |  |
    620   // |  |------------------------------------------------------------|  |
    621   // |  | Navigation buttons, address bar, menu (toolbar_)           |  |
    622   // |  --------------------------------------------------------------  |
    623   // |------------------------------------------------------------------|
    624   // | All infobars (infobar_container_) [1]                            |
    625   // |------------------------------------------------------------------|
    626   // | Bookmarks (bookmark_bar_view_) [1]                               |
    627   // |------------------------------------------------------------------|
    628   // | Debugger splitter (contents_split_)                              |
    629   // |  --------------------------------------------------------------  |
    630   // |  | Page content (contents_container_)                         |  |
    631   // |  |  --------------------------------------------------------  |  |
    632   // |  |  | contents_web_view_                                   |  |  |
    633   // |  |  --------------------------------------------------------  |  |
    634   // |  --------------------------------------------------------------  |
    635   // |  --------------------------------------------------------------  |
    636   // |  | Debugger (devtools_container_)                             |  |
    637   // |  |                                                            |  |
    638   // |  --------------------------------------------------------------  |
    639   // |------------------------------------------------------------------|
    640   // | Active downloads (download_shelf_)                               |
    641   // --------------------------------------------------------------------
    642   //
    643   // [1] The bookmark bar and info bar are swapped when on the new tab page.
    644   //     Additionally when the bookmark bar is detached, contents_container_ is
    645   //     positioned on top of the bar while the tab's contents are placed below
    646   //     the bar.  This allows the find bar to always align with the top of
    647   //     contents_container_ regardless if there's bookmark or info bars.
    648 
    649   // The view that manages the tab strip, toolbar, and sometimes the bookmark
    650   // bar. Stacked top in the view hiearachy so it can be used to slide out
    651   // the top views in immersive fullscreen.
    652   TopContainerView* top_container_;
    653 
    654   // The TabStrip.
    655   TabStrip* tabstrip_;
    656 
    657   // The Toolbar containing the navigation buttons, menus and the address bar.
    658   ToolbarView* toolbar_;
    659 
    660   // This button sits next to the tabs on the right hand side and it is used
    661   // only in windows metro metro mode to allow the user to flip among browser
    662   // windows.
    663   views::Button* window_switcher_button_;
    664 
    665   // The Bookmark Bar View for this window. Lazily created. May be NULL for
    666   // non-tabbed browsers like popups. May not be visible.
    667   scoped_ptr<BookmarkBarView> bookmark_bar_view_;
    668 
    669   // The do-nothing view which controls the z-order of the find bar widget
    670   // relative to views which paint into layers and views with an associated
    671   // NativeView.
    672   View* find_bar_host_view_;
    673 
    674   // The download shelf view (view at the bottom of the page).
    675   scoped_ptr<DownloadShelfView> download_shelf_;
    676 
    677   // The InfoBarContainerView that contains InfoBars for the current tab.
    678   InfoBarContainerView* infobar_container_;
    679 
    680   // The view that contains the selected WebContents.
    681   views::WebView* contents_web_view_;
    682 
    683   // The view that contains devtools window for the selected WebContents.
    684   views::WebView* devtools_container_;
    685 
    686   // The view managing the |contents_web_view_|.
    687   ContentsContainer* contents_container_;
    688 
    689   // Split view containing the contents container and devtools container.
    690   views::SingleSplitView* contents_split_;
    691 
    692   // Side to dock devtools to.
    693   DevToolsDockSide devtools_dock_side_;
    694 
    695   // Docked devtools window instance. NULL when current tab is not inspected
    696   // or is inspected with undocked version of DevToolsWindow.
    697   DevToolsWindow* devtools_window_;
    698 
    699   // Tracks and stores the last focused view which is not the
    700   // devtools_container_ or any of its children. Used to restore focus once
    701   // the devtools_container_ is hidden.
    702   scoped_ptr<views::ExternalFocusTracker> devtools_focus_tracker_;
    703 
    704   // The Status information bubble that appears at the bottom of the window.
    705   scoped_ptr<StatusBubbleViews> status_bubble_;
    706 
    707   // A mapping between accelerators and commands.
    708   std::map<ui::Accelerator, int> accelerator_table_;
    709 
    710   // True if we have already been initialized.
    711   bool initialized_;
    712 
    713   // True if we should ignore requests to layout.  This is set while toggling
    714   // fullscreen mode on and off to reduce jankiness.
    715   bool ignore_layout_;
    716 
    717   scoped_ptr<FullscreenExitBubbleViews> fullscreen_bubble_;
    718 
    719 #if defined(OS_WIN) && !defined(USE_AURA)
    720   // This object is used to perform periodic actions in a worker
    721   // thread. It is currently used to monitor hung plugin windows.
    722   WorkerThreadTicker ticker_;
    723 
    724   // This object is initialized with the frame window HWND. This
    725   // object is also passed as a tick handler with the ticker_ object.
    726   // It is used to periodically monitor for hung plugin windows
    727   HungWindowDetector hung_window_detector_;
    728 
    729   // This object is invoked by hung_window_detector_ when it detects a hung
    730   // plugin window.
    731   HungPluginAction hung_plugin_action_;
    732 
    733   // Helper class to listen for completion of first page load.
    734   scoped_ptr<LoadCompleteListener> load_complete_listener_;
    735 
    736   // The custom JumpList for Windows 7.
    737   scoped_refptr<JumpList> jumplist_;
    738 #endif
    739 
    740 #if defined(USE_ASH)
    741   // Needs to be BrowserLauncerItemController for
    742   // "BrowserActivationStateChanged" and "favicon_loader".
    743   // TODO(skuhne): Remove once per-app is default.
    744   scoped_ptr<BrowserLauncherItemController> launcher_item_controller_;
    745 #endif
    746 
    747   // The timer used to update frames for the Loading Animation.
    748   base::RepeatingTimer<BrowserView> loading_animation_timer_;
    749 
    750   views::UnhandledKeyboardEventHandler unhandled_keyboard_event_handler_;
    751 
    752   // Used to measure the loading spinner animation rate.
    753   base::TimeTicks last_animation_time_;
    754 
    755   // If this flag is set then SetFocusToLocationBar() will set focus to the
    756   // location bar even if the browser window is not active.
    757   bool force_location_bar_focus_;
    758 
    759   scoped_ptr<ImmersiveModeController> immersive_mode_controller_;
    760 
    761   scoped_ptr<ScrollEndEffectController> scroll_end_effect_controller_;
    762 
    763   gfx::ScopedSysColorChangeListener color_change_listener_;
    764 
    765   mutable base::WeakPtrFactory<BrowserView> activate_modal_dialog_factory_;
    766 
    767   DISALLOW_COPY_AND_ASSIGN(BrowserView);
    768 };
    769 
    770 #endif  // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_VIEW_H_
    771