browser_view.h revision 868fa2fe829687343ffae624259930155e16dbd8
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/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  // Returns the apparent bounds of the toolbar, in BrowserView coordinates.
132  // These differ from |toolbar_.bounds()| in that they match where the toolbar
133  // background image is drawn -- slightly outside the "true" bounds
134  // horizontally. Note that this returns the bounds for the toolbar area.
135  gfx::Rect GetToolbarBounds() const;
136
137  // Returns the bounds of the content area, in the coordinates of the
138  // BrowserView's parent.
139  gfx::Rect GetClientAreaBounds() const;
140
141  // Returns the constraining bounding box that should be used to lay out the
142  // FindBar within. This is _not_ the size of the find bar, just the bounding
143  // box it should be laid out within. The coordinate system of the returned
144  // rect is in the coordinate system of the frame, since the FindBar is a child
145  // window.
146  gfx::Rect GetFindBarBoundingBox() const;
147
148  // Returns the preferred height of the TabStrip. Used to position the OTR
149  // avatar icon.
150  int GetTabStripHeight() const;
151
152  // Takes some view's origin (relative to this BrowserView) and offsets it such
153  // that it can be used as the source origin for seamlessly tiling the toolbar
154  // background image over that view.
155  gfx::Point OffsetPointForToolbarBackgroundImage(
156      const gfx::Point& point) const;
157
158  // Container for the tabstrip, toolbar, etc.
159  TopContainerView* top_container() { return top_container_; }
160
161  // Accessor for the TabStrip.
162  TabStrip* tabstrip() { return tabstrip_; }
163
164  // Accessor for the Toolbar.
165  ToolbarView* toolbar() { return toolbar_; }
166
167  // Bookmark bar may be NULL, for example for pop-ups.
168  BookmarkBarView* bookmark_bar() { return bookmark_bar_view_.get(); }
169
170  // Returns the do-nothing view which controls the z-order of the find bar
171  // widget relative to views which paint into layers and views which have an
172  // associated NativeView. The presence / visibility of this view is not
173  // indicative of the visibility of the find bar widget or even whether
174  // FindBarController is initialized.
175  View* find_bar_host_view() { return find_bar_host_view_; }
176
177  // Accessor for the InfobarContainer.
178  InfoBarContainerView* infobar_container() { return infobar_container_; }
179
180  // Returns true if various window components are visible.
181  bool IsTabStripVisible() const;
182
183  // Returns true if the profile associated with this Browser window is
184  // incognito.
185  bool IsOffTheRecord() const;
186
187  // Returns the resource ID to use for the OTR icon, which depends on
188  // which layout is being shown and whether we are full-screen.
189  int GetOTRIconResourceID() const;
190
191  // Returns true if the profile associated with this Browser window is
192  // a guest session.
193  bool IsGuestSession() const;
194
195  // Returns true if the non-client view should render an avatar icon.
196  bool ShouldShowAvatar() const;
197
198  // Provides the containing frame with the accelerator for the specified
199  // command id. This can be used to provide menu item shortcut hints etc.
200  // Returns true if an accelerator was found for the specified |cmd_id|, false
201  // otherwise.
202  bool GetAccelerator(int cmd_id, ui::Accelerator* accelerator);
203
204  // Returns true if the specificed |accelerator| is registered with this view.
205  bool IsAcceleratorRegistered(const ui::Accelerator& accelerator);
206
207  // Returns the active WebContents. Used by our NonClientView's
208  // TabIconView::TabContentsProvider implementations.
209  // TODO(beng): exposing this here is a bit bogus, since it's only used to
210  // determine loading state. It'd be nicer if we could change this to be
211  // bool IsSelectedTabLoading() const; or something like that. We could even
212  // move it to a WindowDelegate subclass.
213  content::WebContents* GetActiveWebContents() const;
214
215  // Retrieves the icon to use in the frame to indicate an OTR window.
216  gfx::ImageSkia GetOTRAvatarIcon() const;
217
218  // Returns true if the Browser object associated with this BrowserView is a
219  // tabbed-type window (i.e. a browser window, not an app or popup).
220  bool IsBrowserTypeNormal() const {
221    return browser_->is_type_tabbed();
222  }
223
224  // Returns true if the specified point(BrowserView coordinates) is in
225  // in the window caption area of the browser window.
226  bool IsPositionInWindowCaption(const gfx::Point& point);
227
228  // See ImmersiveModeController for description.
229  ImmersiveModeController* immersive_mode_controller() const {
230    return immersive_mode_controller_.get();
231  }
232
233  // Restores the focused view. This is also used to set the initial focus
234  // when a new browser window is created.
235  void RestoreFocus();
236
237  void SetWindowSwitcherButton(views::Button* button);
238
239  views::Button* window_switcher_button() {
240    return window_switcher_button_;
241  }
242
243  // Called from BookmarkBarView/DownloadShelfView during their show/hide
244  // animations.
245  void ToolbarSizeChanged(bool is_animating);
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 web_modal::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  // ImmersiveModeController::Delegate overrides:
430  virtual BookmarkBarView* GetBookmarkBar() OVERRIDE;
431  virtual FullscreenController* GetFullscreenController() OVERRIDE;
432  virtual void FullscreenStateChanged() OVERRIDE;
433  virtual void SetImmersiveStyle(bool immersive) OVERRIDE;
434
435  // InfoBarContainer::Delegate overrides
436  virtual SkColor GetInfoBarSeparatorColor() const OVERRIDE;
437  virtual void InfoBarContainerStateChanged(bool is_animating) OVERRIDE;
438  virtual bool DrawInfoBarArrows(int* x) const OVERRIDE;
439
440  // views::SingleSplitViewListener overrides:
441  virtual bool SplitHandleMoved(views::SingleSplitView* sender) OVERRIDE;
442
443  // gfx::SysColorChangeListener overrides:
444  virtual void OnSysColorChange() OVERRIDE;
445
446  // Overridden from views::View:
447  virtual const char* GetClassName() const OVERRIDE;
448  virtual void Layout() OVERRIDE;
449  virtual void PaintChildren(gfx::Canvas* canvas) OVERRIDE;
450  virtual void ViewHierarchyChanged(
451      const ViewHierarchyChangedDetails& details) OVERRIDE;
452  virtual void ChildPreferredSizeChanged(View* child) OVERRIDE;
453  virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
454
455  // Overridden from ui::AcceleratorTarget:
456  virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE;
457
458  // Testing interface:
459  views::SingleSplitView* GetContentsSplitForTest() { return contents_split_; }
460  ContentsContainer* GetContentsContainerForTest() {
461    return contents_container_;
462  }
463  OverlayContainer* GetOverlayContainerForTest() {
464    return overlay_container_;
465  }
466  views::WebView* GetContentsWebViewForTest() { return contents_web_view_; }
467
468 private:
469  // Do not friend BrowserViewLayout. Use the BrowserViewLayoutDelegate
470  // interface to keep these two classes decoupled and testable.
471  friend class BrowserViewLayoutDelegateImpl;
472  FRIEND_TEST_ALL_PREFIXES(BrowserViewTest, BrowserView);
473  FRIEND_TEST_ALL_PREFIXES(BrowserViewsAccessibilityTest,
474                           TestAboutChromeViewAccObj);
475
476  enum FullscreenType {
477    FOR_DESKTOP,
478    FOR_METRO
479  };
480
481  // Appends to |toolbars| a pointer to each AccessiblePaneView that
482  // can be traversed using F6, in the order they should be traversed.
483  void GetAccessiblePanes(std::vector<views::AccessiblePaneView*>* panes);
484
485  // Constructs and initializes the child views.
486  void InitViews();
487
488  // Callback for the loading animation(s) associated with this view.
489  void LoadingAnimationCallback();
490
491  // LoadCompleteListener::Delegate implementation. Creates and initializes the
492  // |jumplist_| after the first page load.
493  virtual void OnLoadCompleted() OVERRIDE;
494
495  // Returns the BrowserViewLayout.
496  BrowserViewLayout* GetBrowserViewLayout() const;
497
498  // Layout the Status Bubble.
499  void LayoutStatusBubble();
500
501  // Prepare to show the Bookmark Bar for the specified WebContents.
502  // Returns true if the Bookmark Bar can be shown (i.e. it's supported for this
503  // Browser type) and there should be a subsequent re-layout to show it.
504  // |contents| can be NULL.
505  bool MaybeShowBookmarkBar(content::WebContents* contents);
506
507  // Moves the bookmark bar view to the specified parent, which may be NULL,
508  // |this|, or |top_container_|. Ensures that |top_container_| stays in front
509  // of |bookmark_bar_view_|.
510  void SetBookmarkBarParent(views::View* new_parent);
511
512  // Prepare to show an Info Bar for the specified WebContents. Returns
513  // true if there is an Info Bar to show and one is supported for this Browser
514  // type, and there should be a subsequent re-layout to show it.
515  // |contents| can be NULL.
516  bool MaybeShowInfoBar(content::WebContents* contents);
517
518  // Updates devtools window for given contents. This method will show docked
519  // devtools window for inspected |web_contents| that has docked devtools
520  // and hide it for NULL or not inspected |web_contents|. It will also make
521  // sure devtools window size and position are restored for given tab.
522  void UpdateDevToolsForContents(content::WebContents* web_contents);
523
524  // Shows docked devtools.
525  void ShowDevToolsContainer();
526
527  // Hides docked devtools.
528  void HideDevToolsContainer();
529
530  // Reads split position from the current tab's devtools window and applies
531  // it to the devtools split.
532  void UpdateDevToolsSplitPosition();
533
534  // Updates various optional child Views, e.g. Bookmarks Bar, Info Bar or the
535  // Download Shelf in response to a change notification from the specified
536  // |contents|. |contents| can be NULL. In this case, all optional UI will be
537  // removed.
538  void UpdateUIForContents(content::WebContents* contents);
539
540  // Invoked to update the necessary things when our fullscreen state changes
541  // to |fullscreen|. On Windows this is invoked immediately when we toggle the
542  // full screen state. On Linux changing the fullscreen state is async, so we
543  // ask the window to change its fullscreen state, then when we get
544  // notification that it succeeded this method is invoked.
545  // If |url| is not empty, it is the URL of the page that requested fullscreen
546  // (via the fullscreen JS API).
547  // |bubble_type| determines what should be shown in the fullscreen exit
548  // bubble.
549  void ProcessFullscreen(bool fullscreen,
550                         FullscreenType fullscreen_type,
551                         const GURL& url,
552                         FullscreenExitBubbleType bubble_type);
553
554  // Copy the accelerator table from the app resources into something we can
555  // use.
556  void LoadAccelerators();
557
558  // Retrieves the command id for the specified Windows app command.
559  int GetCommandIDForAppCommandID(int app_command_id) const;
560
561  // Initialize the hung plugin detector.
562  void InitHangMonitor();
563
564  // Possibly records a user metrics action corresponding to the passed-in
565  // accelerator.  Only implemented for Chrome OS, where we're interested in
566  // learning about how frequently the top-row keys are used.
567  void UpdateAcceleratorMetrics(const ui::Accelerator& accelerator,
568                                int command_id);
569
570  // Create an icon for this window in the launcher (currently only for Ash).
571  void CreateLauncherIcon();
572
573  // Calls |method| which is either RenderWidgetHost::Cut, ::Copy, or ::Paste,
574  // first trying the content WebContents, then the devtools WebContents, and
575  // lastly the Views::Textfield if one is focused.
576  // |windows_msg_id| is temporary until Win Aura is the default on Windows,
577  // since until then the omnibox doesn't use Views::Textfield.
578  void DoCutCopyPaste(void (content::RenderWidgetHost::*method)(),
579#if defined(OS_WIN)
580                      int windows_msg_id,
581#endif
582                      int command_id);
583
584  // Calls |method| which is either RenderWidgetHost::Cut, ::Copy, or ::Paste on
585  // the given WebContents, returning true if it consumed the event.
586  bool DoCutCopyPasteForWebContents(
587      content::WebContents* contents,
588      void (content::RenderWidgetHost::*method)());
589
590  // Shows the next app-modal dialog box, if there is one to be shown, or moves
591  // an existing showing one to the front.
592  void ActivateAppModalDialog() const;
593
594  // Called when overlay is committed, i.e. made the active contents, where
595  // the overlay is reparented from |overlay_container_| to
596  // |contents_container_|.
597  void MakeOverlayContentsActiveContents();
598
599  // Return the max top arrow height for infobar.
600  int GetMaxTopInfoBarArrowHeight();
601
602  // Last focused view that issued a tab traversal.
603  int last_focused_view_storage_id_;
604
605  // The BrowserFrame that hosts this view.
606  BrowserFrame* frame_;
607
608  // The Browser object we are associated with.
609  scoped_ptr<Browser> browser_;
610
611  // BrowserView layout (LTR one is pictured here).
612  //
613  // --------------------------------------------------------------------
614  // | TopContainerView (top_container_)                                |
615  // |  --------------------------------------------------------------  |
616  // |  | Tabs (tabstrip_)                                           |  |
617  // |  |------------------------------------------------------------|  |
618  // |  | Navigation buttons, address bar, menu (toolbar_)           |  |
619  // |  --------------------------------------------------------------  |
620  // |------------------------------------------------------------------|
621  // | OverlayContainer (overlay_container_) [1]                        |
622  // |  --------------------------------------------------------------  |
623  // |  | overlay_controller_->overlay_                              |  |
624  // |  |------------------------------------------------------------|  |
625  // |  | overlay drop shadow if overlay is partial-height           |  |
626  // |  --------------------------------------------------------------  |
627  // |------------------------------------------------------------------|
628  // | All infobars (infobar_container_) [2]                            |
629  // |------------------------------------------------------------------|
630  // | Bookmarks (bookmark_bar_view_) [2]                               |
631  // |------------------------------------------------------------------|
632  // | Debugger splitter (contents_split_)                              |
633  // |  --------------------------------------------------------------  |
634  // |  | Page content (contents_container_)                         |  |
635  // |  |  --------------------------------------------------------  |  |
636  // |  |  | contents_web_view_                                   |  |  |
637  // |  |  --------------------------------------------------------  |  |
638  // |  --------------------------------------------------------------  |
639  // |  --------------------------------------------------------------  |
640  // |  | Debugger (devtools_container_)                             |  |
641  // |  |                                                            |  |
642  // |  --------------------------------------------------------------  |
643  // |------------------------------------------------------------------|
644  // | Active downloads (download_shelf_)                               |
645  // --------------------------------------------------------------------
646  //
647  // [1] Overlay container is only visible when there's an overlay; it is
648  //     directly below the toolbar in the y-axis, and appears on top the
649  //     attached bookmark and/or info bars.
650  // [2] The bookmark bar and info bar are swapped when on the new tab page.
651  //     Additionally contents_container_ is positioned on top of the bookmark
652  //     bar when the bookmark bar is detached. This is done to allow the
653  //     overlay_controller_->overlay_ to appear over the bookmark bar.
654
655  // The view that manages the tab strip, toolbar, and sometimes the bookmark
656  // bar. Stacked second in the view hiearachy behind |overlay_container_|
657  // (refer to comments for |overlay_container_|) so it can be used to slide out
658  // the top views in immersive fullscreen.
659  TopContainerView* top_container_;
660
661  // The TabStrip.
662  TabStrip* tabstrip_;
663
664  // The Toolbar containing the navigation buttons, menus and the address bar.
665  ToolbarView* toolbar_;
666
667  // This button sits next to the tabs on the right hand side and it is used
668  // only in windows metro metro mode to allow the user to flip among browser
669  // windows.
670  views::Button* window_switcher_button_;
671
672  // The Bookmark Bar View for this window. Lazily created. May be NULL for
673  // non-tabbed browsers like popups. May not be visible.
674  scoped_ptr<BookmarkBarView> bookmark_bar_view_;
675
676  // The do-nothing view which controls the z-order of the find bar widget
677  // relative to views which paint into layers and views with an associated
678  // NativeView.
679  View* find_bar_host_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  scoped_ptr<ImmersiveModeController> immersive_mode_controller_;
772
773  gfx::ScopedSysColorChangeListener color_change_listener_;
774
775  scoped_ptr<InstantOverlayControllerViews> overlay_controller_;
776
777  mutable base::WeakPtrFactory<BrowserView> activate_modal_dialog_factory_;
778
779  DISALLOW_COPY_AND_ASSIGN(BrowserView);
780};
781
782#endif  // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_VIEW_H_
783