browser_view.h revision 1e9bf3e0803691d0a228da41fc608347b6db4340
1// Copyright (c) 2012 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_VIEW_H_
6#define CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_VIEW_H_
7
8#include <map>
9#include <string>
10#include <vector>
11
12#include "base/compiler_specific.h"
13#include "base/memory/scoped_ptr.h"
14#include "base/timer/timer.h"
15#include "build/build_config.h"
16#include "chrome/browser/devtools/devtools_window.h"
17#include "chrome/browser/infobars/infobar_container.h"
18#include "chrome/browser/ui/browser.h"
19#include "chrome/browser/ui/browser_window.h"
20#include "chrome/browser/ui/omnibox/omnibox_popup_model_observer.h"
21#include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
22#include "chrome/browser/ui/views/frame/browser_frame.h"
23#include "chrome/browser/ui/views/frame/immersive_mode_controller.h"
24#include "chrome/browser/ui/views/frame/scroll_end_effect_controller.h"
25#include "chrome/browser/ui/views/load_complete_listener.h"
26#include "ui/base/accelerators/accelerator.h"
27#include "ui/base/models/simple_menu_model.h"
28#include "ui/gfx/native_widget_types.h"
29#include "ui/gfx/sys_color_change_listener.h"
30#include "ui/views/controls/button/button.h"
31#include "ui/views/controls/single_split_view_listener.h"
32#include "ui/views/controls/webview/unhandled_keyboard_event_handler.h"
33#include "ui/views/widget/widget_delegate.h"
34#include "ui/views/widget/widget_observer.h"
35#include "ui/views/window/client_view.h"
36
37#if defined(OS_WIN)
38#include "chrome/browser/hang_monitor/hung_plugin_action.h"
39#include "chrome/browser/hang_monitor/hung_window_detector.h"
40#endif
41
42// NOTE: For more information about the objects and files in this directory,
43// view: http://dev.chromium.org/developers/design-documents/browser-window
44
45class BookmarkBarView;
46class Browser;
47class BrowserViewLayout;
48class ContentsContainer;
49class DownloadShelfView;
50class FullscreenExitBubbleViews;
51class InfoBarContainerView;
52class LocationBarView;
53class StatusBubbleViews;
54class SearchViewController;
55class TabStrip;
56class TabStripModel;
57class ToolbarView;
58class TopContainerView;
59
60#if defined(OS_WIN)
61class JumpList;
62#endif
63
64namespace autofill {
65class PasswordGenerator;
66}
67
68namespace content {
69class RenderWidgetHost;
70}
71
72namespace extensions {
73class Extension;
74}
75
76namespace views {
77class AccessiblePaneView;
78class ExternalFocusTracker;
79class WebView;
80}
81
82///////////////////////////////////////////////////////////////////////////////
83// BrowserView
84//
85//  A ClientView subclass that provides the contents of a browser window,
86//  including the TabStrip, toolbars, download shelves, the content area etc.
87//
88class BrowserView : public BrowserWindow,
89                    public BrowserWindowTesting,
90                    public TabStripModelObserver,
91                    public ui::AcceleratorProvider,
92                    public views::WidgetDelegate,
93                    public views::WidgetObserver,
94                    public views::ClientView,
95                    public ImmersiveModeController::Delegate,
96                    public InfoBarContainer::Delegate,
97                    public views::SingleSplitViewListener,
98                    public gfx::SysColorChangeListener,
99                    public LoadCompleteListener::Delegate,
100                    public OmniboxPopupModelObserver {
101 public:
102  // The browser view's class name.
103  static const char kViewClassName[];
104
105  BrowserView();
106  virtual ~BrowserView();
107
108  // Takes ownership of |browser|.
109  void Init(Browser* browser);
110
111  void set_frame(BrowserFrame* frame) { frame_ = frame; }
112  BrowserFrame* frame() const { return frame_; }
113
114  // Returns a pointer to the BrowserView* interface implementation (an
115  // instance of this object, typically) for a given native window, or NULL if
116  // there is no such association.
117  //
118  // Don't use this unless you only have a NativeWindow. In nearly all
119  // situations plumb through browser and use it.
120  static BrowserView* GetBrowserViewForNativeWindow(gfx::NativeWindow window);
121
122  // Returns the BrowserView used for the specified Browser.
123  static BrowserView* GetBrowserViewForBrowser(const Browser* browser);
124
125  // Returns a Browser instance of this view.
126  Browser* browser() { return browser_.get(); }
127
128  // Initializes (or re-initializes) the status bubble.  We try to only create
129  // the bubble once and re-use it for the life of the browser, but certain
130  // events (such as changing enabling/disabling Aero on Win) can force a need
131  // to change some of the bubble's creation parameters.
132  void InitStatusBubble();
133
134  // Returns the apparent bounds of the toolbar, in BrowserView coordinates.
135  // These differ from |toolbar_.bounds()| in that they match where the toolbar
136  // background image is drawn -- slightly outside the "true" bounds
137  // horizontally. Note that this returns the bounds for the toolbar area.
138  gfx::Rect GetToolbarBounds() const;
139
140  // Returns the bounds of the content area, in the coordinates of the
141  // BrowserView's parent.
142  gfx::Rect GetClientAreaBounds() const;
143
144  // Returns the constraining bounding box that should be used to lay out the
145  // FindBar within. This is _not_ the size of the find bar, just the bounding
146  // box it should be laid out within. The coordinate system of the returned
147  // rect is in the coordinate system of the frame, since the FindBar is a child
148  // window.
149  gfx::Rect GetFindBarBoundingBox() const;
150
151  // Returns the preferred height of the TabStrip. Used to position the OTR
152  // avatar icon.
153  int GetTabStripHeight() const;
154
155  // Takes some view's origin (relative to this BrowserView) and offsets it such
156  // that it can be used as the source origin for seamlessly tiling the toolbar
157  // background image over that view.
158  gfx::Point OffsetPointForToolbarBackgroundImage(
159      const gfx::Point& point) const;
160
161  // Container for the tabstrip, toolbar, etc.
162  TopContainerView* top_container() { return top_container_; }
163
164  // Accessor for the TabStrip.
165  TabStrip* tabstrip() { return tabstrip_; }
166
167  // Accessor for the Toolbar.
168  ToolbarView* toolbar() { return toolbar_; }
169
170  // Bookmark bar may be NULL, for example for pop-ups.
171  BookmarkBarView* bookmark_bar() { return bookmark_bar_view_.get(); }
172
173  // Returns the do-nothing view which controls the z-order of the find bar
174  // widget relative to views which paint into layers and views which have an
175  // associated NativeView. The presence / visibility of this view is not
176  // indicative of the visibility of the find bar widget or even whether
177  // FindBarController is initialized.
178  View* find_bar_host_view() { return find_bar_host_view_; }
179
180  // Accessor for the InfobarContainer.
181  InfoBarContainerView* infobar_container() { return infobar_container_; }
182
183  // Accessor for the FullscreenExitBubbleViews.
184  FullscreenExitBubbleViews* fullscreen_exit_bubble() {
185    return fullscreen_bubble_.get();
186  }
187
188  // Returns true if various window components are visible.
189  bool IsTabStripVisible() const;
190
191  // Returns true if the profile associated with this Browser window is
192  // incognito.
193  bool IsOffTheRecord() const;
194
195  // Returns true if the profile associated with this Browser window is
196  // a guest session.
197  bool IsGuestSession() const;
198
199  // Returns true if the profile associated with this Browser window is
200  // not off the record or a guest session.
201  bool IsRegularOrGuestSession() const;
202
203  // Returns the resource ID to use for the OTR icon, which depends on
204  // which layout is being shown and whether we are full-screen.
205  int GetOTRIconResourceID() const;
206
207  // Returns the resource ID to use for the Guest icon, which may depend on
208  // which layout is being shown and whether we are full-screen.
209  int GetGuestIconResourceID() const;
210
211  // Returns true if the non-client view should render an avatar icon.
212  bool ShouldShowAvatar() const;
213
214  // Provides the containing frame with the accelerator for the specified
215  // command id. This can be used to provide menu item shortcut hints etc.
216  // Returns true if an accelerator was found for the specified |cmd_id|, false
217  // otherwise.
218  bool GetAccelerator(int cmd_id, ui::Accelerator* accelerator);
219
220  // Returns true if the specificed |accelerator| is registered with this view.
221  bool IsAcceleratorRegistered(const ui::Accelerator& accelerator);
222
223  // Returns the active WebContents. Used by our NonClientView's
224  // TabIconView::TabContentsProvider implementations.
225  // TODO(beng): exposing this here is a bit bogus, since it's only used to
226  // determine loading state. It'd be nicer if we could change this to be
227  // bool IsSelectedTabLoading() const; or something like that. We could even
228  // move it to a WindowDelegate subclass.
229  content::WebContents* GetActiveWebContents() const;
230
231  // Retrieves the icon to use in the frame to indicate an OTR window.
232  gfx::ImageSkia GetOTRAvatarIcon() const;
233
234  // Returns true if the Browser object associated with this BrowserView is a
235  // tabbed-type window (i.e. a browser window, not an app or popup).
236  bool IsBrowserTypeNormal() const {
237    return browser_->is_type_tabbed();
238  }
239
240  // See ImmersiveModeController for description.
241  ImmersiveModeController* immersive_mode_controller() const {
242    return immersive_mode_controller_.get();
243  }
244
245  // Restores the focused view. This is also used to set the initial focus
246  // when a new browser window is created.
247  void RestoreFocus();
248
249  void SetWindowSwitcherButton(views::Button* button);
250
251  views::Button* window_switcher_button() {
252    return window_switcher_button_;
253  }
254
255  // Called from BookmarkBarView/DownloadShelfView during their show/hide
256  // animations.
257  void ToolbarSizeChanged(bool is_animating);
258
259  // Overridden from BrowserWindow:
260  virtual void Show() OVERRIDE;
261  virtual void ShowInactive() OVERRIDE;
262  virtual void Hide() OVERRIDE;
263  virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE;
264  virtual void Close() OVERRIDE;
265  virtual void Activate() OVERRIDE;
266  virtual void Deactivate() OVERRIDE;
267  virtual bool IsActive() const OVERRIDE;
268  virtual void FlashFrame(bool flash) OVERRIDE;
269  virtual bool IsAlwaysOnTop() const OVERRIDE;
270  virtual void SetAlwaysOnTop(bool always_on_top) OVERRIDE;
271  virtual gfx::NativeWindow GetNativeWindow() OVERRIDE;
272  virtual BrowserWindowTesting* GetBrowserWindowTesting() OVERRIDE;
273  virtual StatusBubble* GetStatusBubble() OVERRIDE;
274  virtual void UpdateTitleBar() OVERRIDE;
275  virtual void BookmarkBarStateChanged(
276      BookmarkBar::AnimateChangeType change_type) OVERRIDE;
277  virtual void UpdateDevTools() OVERRIDE;
278  virtual void UpdateLoadingAnimations(bool should_animate) OVERRIDE;
279  virtual void SetStarredState(bool is_starred) OVERRIDE;
280  virtual void OnActiveTabChanged(content::WebContents* old_contents,
281                                  content::WebContents* new_contents,
282                                  int index,
283                                  int reason) OVERRIDE;
284  virtual void ZoomChangedForActiveTab(bool can_show_bubble) OVERRIDE;
285  virtual gfx::Rect GetRestoredBounds() const OVERRIDE;
286  virtual ui::WindowShowState GetRestoredState() const OVERRIDE;
287  virtual gfx::Rect GetBounds() const OVERRIDE;
288  virtual bool IsMaximized() const OVERRIDE;
289  virtual bool IsMinimized() const OVERRIDE;
290  virtual void Maximize() OVERRIDE;
291  virtual void Minimize() OVERRIDE;
292  virtual void Restore() OVERRIDE;
293  virtual void EnterFullscreen(
294      const GURL& url, FullscreenExitBubbleType bubble_type) OVERRIDE;
295  virtual void ExitFullscreen() OVERRIDE;
296  virtual void UpdateFullscreenExitBubbleContent(
297      const GURL& url,
298      FullscreenExitBubbleType bubble_type) OVERRIDE;
299  virtual bool ShouldHideUIForFullscreen() const OVERRIDE;
300  virtual bool IsFullscreen() const OVERRIDE;
301  virtual bool IsFullscreenBubbleVisible() const OVERRIDE;
302#if defined(OS_WIN)
303  virtual void SetMetroSnapMode(bool enable) OVERRIDE;
304  virtual bool IsInMetroSnapMode() const OVERRIDE;
305#endif
306  virtual LocationBar* GetLocationBar() const OVERRIDE;
307  virtual void SetFocusToLocationBar(bool select_all) OVERRIDE;
308  virtual void UpdateReloadStopState(bool is_loading, bool force) OVERRIDE;
309  virtual void UpdateToolbar(content::WebContents* contents) OVERRIDE;
310  virtual void FocusToolbar() OVERRIDE;
311  virtual void FocusAppMenu() OVERRIDE;
312  virtual void FocusBookmarksToolbar() OVERRIDE;
313  virtual void FocusInfobars() OVERRIDE;
314  virtual void RotatePaneFocus(bool forwards) OVERRIDE;
315  virtual void DestroyBrowser() OVERRIDE;
316  virtual bool IsBookmarkBarVisible() const OVERRIDE;
317  virtual bool IsBookmarkBarAnimating() const OVERRIDE;
318  virtual bool IsTabStripEditable() const OVERRIDE;
319  virtual bool IsToolbarVisible() const OVERRIDE;
320  virtual gfx::Rect GetRootWindowResizerRect() const OVERRIDE;
321  virtual void DisableInactiveFrame() OVERRIDE;
322  virtual void ConfirmAddSearchProvider(TemplateURL* template_url,
323                                        Profile* profile) 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 ShowTranslateBubble(
329      content::WebContents* contents,
330      TranslateBubbleModel::ViewState view_state) OVERRIDE;
331#if defined(ENABLE_ONE_CLICK_SIGNIN)
332  virtual void ShowOneClickSigninBubble(
333      OneClickSigninBubbleType type,
334      const string16& email,
335      const string16& error_message,
336      const StartSyncCallback& start_sync_callback) OVERRIDE;
337#endif
338  // TODO(beng): Not an override, move somewhere else.
339  void SetDownloadShelfVisible(bool visible);
340  virtual bool IsDownloadShelfVisible() const OVERRIDE;
341  virtual DownloadShelf* GetDownloadShelf() OVERRIDE;
342  virtual void ConfirmBrowserCloseWithPendingDownloads(
343      int download_count,
344      Browser::DownloadClosePreventionType dialog_type,
345      bool app_modal,
346      const base::Callback<void(bool)>& callback) 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) OVERRIDE;
354  virtual void ShowAppMenu() OVERRIDE;
355  virtual bool PreHandleKeyboardEvent(
356      const content::NativeWebKeyboardEvent& event,
357      bool* is_keyboard_shortcut) OVERRIDE;
358  virtual void HandleKeyboardEvent(
359      const content::NativeWebKeyboardEvent& event) OVERRIDE;
360  virtual void Cut() OVERRIDE;
361  virtual void Copy() OVERRIDE;
362  virtual void Paste() OVERRIDE;
363  virtual WindowOpenDisposition GetDispositionForPopupBounds(
364      const gfx::Rect& bounds) OVERRIDE;
365  virtual FindBar* CreateFindBar() OVERRIDE;
366  virtual web_modal::WebContentsModalDialogHost*
367      GetWebContentsModalDialogHost() OVERRIDE;
368  virtual void ShowAvatarBubble(content::WebContents* web_contents,
369                                const gfx::Rect& rect) OVERRIDE;
370  virtual void ShowAvatarBubbleFromAvatarButton() OVERRIDE;
371  virtual void ShowPasswordGenerationBubble(
372      const gfx::Rect& rect,
373      const autofill::PasswordForm& form,
374      autofill::PasswordGenerator* password_generator) OVERRIDE;
375  virtual void OverscrollUpdate(int delta_y) OVERRIDE;
376  virtual int GetRenderViewHeightInsetWithDetachedBookmarkBar() OVERRIDE;
377
378  // Overridden from BrowserWindowTesting:
379  virtual BookmarkBarView* GetBookmarkBarView() const OVERRIDE;
380  virtual LocationBarView* GetLocationBarView() const OVERRIDE;
381  virtual views::View* GetTabContentsContainerView() const OVERRIDE;
382  virtual ToolbarView* GetToolbarView() const OVERRIDE;
383
384  // Overridden from TabStripModelObserver:
385  virtual void TabDetachedAt(content::WebContents* contents,
386                             int index) OVERRIDE;
387  virtual void TabDeactivated(content::WebContents* contents) 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 FullscreenController* GetFullscreenController() OVERRIDE;
431  virtual void FullscreenStateChanged() OVERRIDE;
432  virtual void SetImmersiveStyle(bool immersive) OVERRIDE;
433  virtual content::WebContents* GetWebContents() 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  // OmniboxPopupModelObserver overrides
459  virtual void OnOmniboxPopupShownOrHidden() OVERRIDE;
460
461  // Testing interface:
462  views::SingleSplitView* GetContentsSplitForTest() { return contents_split_; }
463  ContentsContainer* GetContentsContainerForTest() {
464    return contents_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  // Returns whether immmersive fullscreen should replace fullscreen. This
555  // should only occur for "browser-fullscreen" for tabbed-typed windows (not
556  // for tab-fullscreen and not for app/popup type windows).
557  bool ShouldUseImmersiveFullscreenForUrl(const GURL& url) const;
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  // Calls |method| which is either RenderWidgetHost::Cut, ::Copy, or ::Paste,
576  // first trying the content WebContents, then the devtools WebContents, and
577  // lastly the Views::Textfield if one is focused.
578  // |windows_msg_id| is temporary until Win Aura is the default on Windows,
579  // since until then the omnibox doesn't use Views::Textfield.
580  void DoCutCopyPaste(void (content::RenderWidgetHost::*method)(),
581#if defined(OS_WIN)
582                      int windows_msg_id,
583#endif
584                      int command_id);
585
586  // Calls |method| which is either RenderWidgetHost::Cut, ::Copy, or ::Paste on
587  // the given WebContents, returning true if it consumed the event.
588  bool DoCutCopyPasteForWebContents(
589      content::WebContents* contents,
590      void (content::RenderWidgetHost::*method)());
591
592  // Shows the next app-modal dialog box, if there is one to be shown, or moves
593  // an existing showing one to the front.
594  void ActivateAppModalDialog() const;
595
596  // Returns the max top arrow height for infobar.
597  int GetMaxTopInfoBarArrowHeight();
598
599  // Last focused view that issued a tab traversal.
600  int last_focused_view_storage_id_;
601
602  // The BrowserFrame that hosts this view.
603  BrowserFrame* frame_;
604
605  // The Browser object we are associated with.
606  scoped_ptr<Browser> browser_;
607
608  // BrowserView layout (LTR one is pictured here).
609  //
610  // --------------------------------------------------------------------
611  // | TopContainerView (top_container_)                                |
612  // |  --------------------------------------------------------------  |
613  // |  | Tabs (tabstrip_)                                           |  |
614  // |  |------------------------------------------------------------|  |
615  // |  | Navigation buttons, address bar, menu (toolbar_)           |  |
616  // |  --------------------------------------------------------------  |
617  // |------------------------------------------------------------------|
618  // | All infobars (infobar_container_) [1]                            |
619  // |------------------------------------------------------------------|
620  // | Bookmarks (bookmark_bar_view_) [1]                               |
621  // |------------------------------------------------------------------|
622  // | Debugger splitter (contents_split_)                              |
623  // |  --------------------------------------------------------------  |
624  // |  | Page content (contents_container_)                         |  |
625  // |  |  --------------------------------------------------------  |  |
626  // |  |  | contents_web_view_                                   |  |  |
627  // |  |  --------------------------------------------------------  |  |
628  // |  --------------------------------------------------------------  |
629  // |  --------------------------------------------------------------  |
630  // |  | Debugger (devtools_container_)                             |  |
631  // |  |                                                            |  |
632  // |  --------------------------------------------------------------  |
633  // |------------------------------------------------------------------|
634  // | Active downloads (download_shelf_)                               |
635  // --------------------------------------------------------------------
636  //
637  // [1] The bookmark bar and info bar are swapped when on the new tab page.
638  //     Additionally when the bookmark bar is detached, contents_container_ is
639  //     positioned on top of the bar while the tab's contents are placed below
640  //     the bar.  This allows the find bar to always align with the top of
641  //     contents_container_ regardless if there's bookmark or info bars.
642
643  // The view that manages the tab strip, toolbar, and sometimes the bookmark
644  // bar. Stacked top in the view hiearachy so it can be used to slide out
645  // the top views in immersive fullscreen.
646  TopContainerView* top_container_;
647
648  // The TabStrip.
649  TabStrip* tabstrip_;
650
651  // The Toolbar containing the navigation buttons, menus and the address bar.
652  ToolbarView* toolbar_;
653
654  // This button sits next to the tabs on the right hand side and it is used
655  // only in windows metro metro mode to allow the user to flip among browser
656  // windows.
657  views::Button* window_switcher_button_;
658
659  // The Bookmark Bar View for this window. Lazily created. May be NULL for
660  // non-tabbed browsers like popups. May not be visible.
661  scoped_ptr<BookmarkBarView> bookmark_bar_view_;
662
663  // The do-nothing view which controls the z-order of the find bar widget
664  // relative to views which paint into layers and views with an associated
665  // NativeView.
666  View* find_bar_host_view_;
667
668  // The download shelf view (view at the bottom of the page).
669  scoped_ptr<DownloadShelfView> download_shelf_;
670
671  // The InfoBarContainerView that contains InfoBars for the current tab.
672  InfoBarContainerView* infobar_container_;
673
674  // The view that contains the selected WebContents.
675  views::WebView* contents_web_view_;
676
677  // The view that contains devtools window for the selected WebContents.
678  views::WebView* devtools_container_;
679
680  // The view managing the |contents_web_view_|.
681  ContentsContainer* contents_container_;
682
683  // Split view containing the contents container and devtools container.
684  views::SingleSplitView* contents_split_;
685
686  // Side to dock devtools to.
687  DevToolsDockSide devtools_dock_side_;
688
689  // Docked devtools window instance. NULL when current tab is not inspected
690  // or is inspected with undocked version of DevToolsWindow.
691  DevToolsWindow* devtools_window_;
692
693  // Tracks and stores the last focused view which is not the
694  // devtools_container_ or any of its children. Used to restore focus once
695  // the devtools_container_ is hidden.
696  scoped_ptr<views::ExternalFocusTracker> devtools_focus_tracker_;
697
698  // The Status information bubble that appears at the bottom of the window.
699  scoped_ptr<StatusBubbleViews> status_bubble_;
700
701  // A mapping between accelerators and commands.
702  std::map<ui::Accelerator, int> accelerator_table_;
703
704  // True if we have already been initialized.
705  bool initialized_;
706
707  // True when in ProcessFullscreen(). The flag is used to avoid reentrance and
708  // to ignore requests to layout while in ProcessFullscreen() to reduce
709  // jankiness.
710  bool in_process_fullscreen_;
711
712  scoped_ptr<FullscreenExitBubbleViews> fullscreen_bubble_;
713
714#if defined(OS_WIN) && !defined(USE_AURA)
715  // This object is used to perform periodic actions in a worker
716  // thread. It is currently used to monitor hung plugin windows.
717  WorkerThreadTicker ticker_;
718
719  // This object is initialized with the frame window HWND. This
720  // object is also passed as a tick handler with the ticker_ object.
721  // It is used to periodically monitor for hung plugin windows
722  HungWindowDetector hung_window_detector_;
723
724  // This object is invoked by hung_window_detector_ when it detects a hung
725  // plugin window.
726  HungPluginAction hung_plugin_action_;
727
728  // Helper class to listen for completion of first page load.
729  scoped_ptr<LoadCompleteListener> load_complete_listener_;
730
731  // The custom JumpList for Windows 7.
732  scoped_refptr<JumpList> jumplist_;
733#endif
734
735  // The timer used to update frames for the Loading Animation.
736  base::RepeatingTimer<BrowserView> loading_animation_timer_;
737
738  views::UnhandledKeyboardEventHandler unhandled_keyboard_event_handler_;
739
740  // Used to measure the loading spinner animation rate.
741  base::TimeTicks last_animation_time_;
742
743  // If this flag is set then SetFocusToLocationBar() will set focus to the
744  // location bar even if the browser window is not active.
745  bool force_location_bar_focus_;
746
747  scoped_ptr<ImmersiveModeController> immersive_mode_controller_;
748
749  scoped_ptr<ScrollEndEffectController> scroll_end_effect_controller_;
750
751  gfx::ScopedSysColorChangeListener color_change_listener_;
752
753  mutable base::WeakPtrFactory<BrowserView> activate_modal_dialog_factory_;
754
755  DISALLOW_COPY_AND_ASSIGN(BrowserView);
756};
757
758#endif  // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_VIEW_H_
759