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