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