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