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