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.
5 #ifndef CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_VIEW_H_
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/signin/signin_header_helper.h"
18 #include "chrome/browser/ui/browser.h"
19 #include "chrome/browser/ui/browser_window.h"
20 #include "chrome/browser/ui/browser_window_testing_views.h"
21 #include "chrome/browser/ui/omnibox/omnibox_popup_model_observer.h"
22 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
23 #include "chrome/browser/ui/views/frame/browser_frame.h"
24 #include "chrome/browser/ui/views/frame/contents_web_view.h"
25 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h"
26 #include "chrome/browser/ui/views/frame/scroll_end_effect_controller.h"
27 #include "chrome/browser/ui/views/frame/web_contents_close_handler.h"
28 #include "chrome/browser/ui/views/load_complete_listener.h"
29 #include "components/infobars/core/infobar_container.h"
30 #include "ui/base/accelerators/accelerator.h"
31 #include "ui/base/models/simple_menu_model.h"
32 #include "ui/gfx/native_widget_types.h"
33 #include "ui/views/controls/button/button.h"
34 #include "ui/views/controls/webview/unhandled_keyboard_event_handler.h"
35 #include "ui/views/widget/widget_delegate.h"
36 #include "ui/views/widget/widget_observer.h"
37 #include "ui/views/window/client_view.h"
40 #include "chrome/browser/hang_monitor/hung_plugin_action.h"
41 #include "chrome/browser/hang_monitor/hung_window_detector.h"
44 // NOTE: For more information about the objects and files in this directory,
45 // view: http://dev.chromium.org/developers/design-documents/browser-window
47 class BookmarkBarView;
49 class BrowserViewLayout;
50 class ContentsLayoutManager;
51 class DownloadShelfView;
52 class FullscreenExitBubbleViews;
53 class InfoBarContainerView;
54 class LocationBarView;
55 class PermissionBubbleViewViews;
56 class StatusBubbleViews;
57 class SearchViewController;
61 class TopContainerView;
62 class WebContentsCloseHandler;
69 class PasswordGenerator;
73 class RenderFrameHost;
76 namespace extensions {
81 class AccessiblePaneView;
82 class ExternalFocusTracker;
86 ///////////////////////////////////////////////////////////////////////////////
89 // A ClientView subclass that provides the contents of a browser window,
90 // including the TabStrip, toolbars, download shelves, the content area etc.
92 class 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 infobars::InfoBarContainer::Delegate,
100 public LoadCompleteListener::Delegate,
101 public OmniboxPopupModelObserver {
103 // The browser view's class name.
104 static const char kViewClassName[];
107 virtual ~BrowserView();
109 // Takes ownership of |browser|.
110 void Init(Browser* browser);
112 void set_frame(BrowserFrame* frame) { frame_ = frame; }
113 BrowserFrame* frame() const { return frame_; }
115 // Returns a pointer to the BrowserView* interface implementation (an
116 // instance of this object, typically) for a given native window, or NULL if
117 // there is no such association.
119 // Don't use this unless you only have a NativeWindow. In nearly all
120 // situations plumb through browser and use it.
121 static BrowserView* GetBrowserViewForNativeWindow(gfx::NativeWindow window);
123 // Returns the BrowserView used for the specified Browser.
124 static BrowserView* GetBrowserViewForBrowser(const Browser* browser);
126 // Returns a Browser instance of this view.
127 Browser* browser() { return browser_.get(); }
128 const Browser* browser() const { return browser_.get(); }
130 // Initializes (or re-initializes) the status bubble. We try to only create
131 // the bubble once and re-use it for the life of the browser, but certain
132 // events (such as changing enabling/disabling Aero on Win) can force a need
133 // to change some of the bubble's creation parameters.
134 void InitStatusBubble();
136 // Initializes the permission bubble view. This class is intended to be
137 // created once and then re-used for the life of the browser window. The
138 // bubbles it creates will be associated with a single visible tab.
139 void InitPermissionBubbleView();
141 // Returns the apparent bounds of the toolbar, in BrowserView coordinates.
142 // These differ from |toolbar_.bounds()| in that they match where the toolbar
143 // background image is drawn -- slightly outside the "true" bounds
144 // horizontally. Note that this returns the bounds for the toolbar area.
145 gfx::Rect GetToolbarBounds() const;
147 // Returns the constraining bounding box that should be used to lay out the
148 // FindBar within. This is _not_ the size of the find bar, just the bounding
149 // box it should be laid out within. The coordinate system of the returned
150 // rect is in the coordinate system of the frame, since the FindBar is a child
152 gfx::Rect GetFindBarBoundingBox() const;
154 // Returns the preferred height of the TabStrip. Used to position the OTR
156 int GetTabStripHeight() const;
158 // Takes some view's origin (relative to this BrowserView) and offsets it such
159 // that it can be used as the source origin for seamlessly tiling the toolbar
160 // background image over that view.
161 gfx::Point OffsetPointForToolbarBackgroundImage(
162 const gfx::Point& point) const;
164 // Container for the tabstrip, toolbar, etc.
165 TopContainerView* top_container() { return top_container_; }
167 // Accessor for the TabStrip.
168 TabStrip* tabstrip() { return tabstrip_; }
170 // Accessor for the Toolbar.
171 ToolbarView* toolbar() { return toolbar_; }
173 // Bookmark bar may be NULL, for example for pop-ups.
174 BookmarkBarView* bookmark_bar() { return bookmark_bar_view_.get(); }
176 // Returns the do-nothing view which controls the z-order of the find bar
177 // widget relative to views which paint into layers and views which have an
178 // associated NativeView. The presence / visibility of this view is not
179 // indicative of the visibility of the find bar widget or even whether
180 // FindBarController is initialized.
181 View* find_bar_host_view() { return find_bar_host_view_; }
183 // Accessor for the InfobarContainer.
184 InfoBarContainerView* infobar_container() { return infobar_container_; }
186 // Accessor for the FullscreenExitBubbleViews.
187 FullscreenExitBubbleViews* fullscreen_exit_bubble() {
188 return fullscreen_bubble_.get();
191 // Returns true if various window components are visible.
192 bool IsTabStripVisible() const;
194 // Returns true if the profile associated with this Browser window is
196 bool IsOffTheRecord() const;
198 // Returns true if the profile associated with this Browser window is
200 bool IsGuestSession() const;
202 // Returns true if the profile associated with this Browser window is
203 // not off the record or a guest session.
204 bool IsRegularOrGuestSession() const;
206 // Returns true if the non-client view should render an avatar icon.
207 bool ShouldShowAvatar() const;
209 // Provides the containing frame with the accelerator for the specified
210 // command id. This can be used to provide menu item shortcut hints etc.
211 // Returns true if an accelerator was found for the specified |cmd_id|, false
213 bool GetAccelerator(int cmd_id, ui::Accelerator* accelerator) const;
215 // Returns true if the specificed |accelerator| is registered with this view.
216 bool IsAcceleratorRegistered(const ui::Accelerator& accelerator);
218 // Returns the active WebContents. Used by our NonClientView's
219 // TabIconView::TabContentsProvider implementations.
220 // TODO(beng): exposing this here is a bit bogus, since it's only used to
221 // determine loading state. It'd be nicer if we could change this to be
222 // bool IsSelectedTabLoading() const; or something like that. We could even
223 // move it to a WindowDelegate subclass.
224 content::WebContents* GetActiveWebContents() const;
226 // Retrieves the icon to use in the frame to indicate an OTR window.
227 gfx::ImageSkia GetOTRAvatarIcon() const;
229 // Returns true if the Browser object associated with this BrowserView is a
230 // tabbed-type window (i.e. a browser window, not an app or popup).
231 bool IsBrowserTypeNormal() const {
232 return browser_->is_type_tabbed();
235 // See ImmersiveModeController for description.
236 ImmersiveModeController* immersive_mode_controller() const {
237 return immersive_mode_controller_.get();
240 // Restores the focused view. This is also used to set the initial focus
241 // when a new browser window is created.
244 // Called after the widget's fullscreen state is changed without going through
245 // FullscreenController. This method does any processing which was skipped.
246 // Only exiting fullscreen in this way is currently supported.
247 void FullscreenStateChanged();
249 // Called from BookmarkBarView/DownloadShelfView during their show/hide
251 void ToolbarSizeChanged(bool is_animating);
253 // Overridden from BrowserWindow:
254 virtual void Show() OVERRIDE;
255 virtual void ShowInactive() OVERRIDE;
256 virtual void Hide() OVERRIDE;
257 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE;
258 virtual void Close() OVERRIDE;
259 virtual void Activate() OVERRIDE;
260 virtual void Deactivate() OVERRIDE;
261 virtual bool IsActive() const OVERRIDE;
262 virtual void FlashFrame(bool flash) OVERRIDE;
263 virtual bool IsAlwaysOnTop() const OVERRIDE;
264 virtual void SetAlwaysOnTop(bool always_on_top) OVERRIDE;
265 virtual gfx::NativeWindow GetNativeWindow() OVERRIDE;
266 virtual BrowserWindowTesting* GetBrowserWindowTesting() OVERRIDE;
267 virtual StatusBubble* GetStatusBubble() OVERRIDE;
268 virtual void UpdateTitleBar() OVERRIDE;
269 virtual void BookmarkBarStateChanged(
270 BookmarkBar::AnimateChangeType change_type) OVERRIDE;
271 virtual void UpdateDevTools() OVERRIDE;
272 virtual void UpdateLoadingAnimations(bool should_animate) OVERRIDE;
273 virtual void SetStarredState(bool is_starred) OVERRIDE;
274 virtual void SetTranslateIconToggled(bool is_lit) OVERRIDE;
275 virtual void OnActiveTabChanged(content::WebContents* old_contents,
276 content::WebContents* new_contents,
278 int reason) OVERRIDE;
279 virtual void ZoomChangedForActiveTab(bool can_show_bubble) OVERRIDE;
280 virtual gfx::Rect GetRestoredBounds() const OVERRIDE;
281 virtual ui::WindowShowState GetRestoredState() const OVERRIDE;
282 virtual gfx::Rect GetBounds() const OVERRIDE;
283 virtual bool IsMaximized() const OVERRIDE;
284 virtual bool IsMinimized() const OVERRIDE;
285 virtual void Maximize() OVERRIDE;
286 virtual void Minimize() OVERRIDE;
287 virtual void Restore() OVERRIDE;
288 virtual void EnterFullscreen(
289 const GURL& url, FullscreenExitBubbleType bubble_type) OVERRIDE;
290 virtual void ExitFullscreen() OVERRIDE;
291 virtual void UpdateFullscreenExitBubbleContent(
293 FullscreenExitBubbleType bubble_type) OVERRIDE;
294 virtual bool ShouldHideUIForFullscreen() const OVERRIDE;
295 virtual bool IsFullscreen() const OVERRIDE;
296 virtual bool IsFullscreenBubbleVisible() const OVERRIDE;
298 virtual void SetMetroSnapMode(bool enable) OVERRIDE;
299 virtual bool IsInMetroSnapMode() const OVERRIDE;
301 virtual LocationBar* GetLocationBar() const OVERRIDE;
302 virtual void SetFocusToLocationBar(bool select_all) OVERRIDE;
303 virtual void UpdateReloadStopState(bool is_loading, bool force) OVERRIDE;
304 virtual void UpdateToolbar(content::WebContents* contents) OVERRIDE;
305 virtual void FocusToolbar() OVERRIDE;
306 virtual void FocusAppMenu() OVERRIDE;
307 virtual void FocusBookmarksToolbar() OVERRIDE;
308 virtual void FocusInfobars() OVERRIDE;
309 virtual void RotatePaneFocus(bool forwards) OVERRIDE;
310 virtual void DestroyBrowser() OVERRIDE;
311 virtual bool IsBookmarkBarVisible() const OVERRIDE;
312 virtual bool IsBookmarkBarAnimating() const OVERRIDE;
313 virtual bool IsTabStripEditable() const OVERRIDE;
314 virtual bool IsToolbarVisible() const OVERRIDE;
315 virtual gfx::Rect GetRootWindowResizerRect() const OVERRIDE;
316 virtual void ConfirmAddSearchProvider(TemplateURL* template_url,
317 Profile* profile) OVERRIDE;
318 virtual void ShowUpdateChromeDialog() OVERRIDE;
319 virtual void ShowBookmarkBubble(const GURL& url,
320 bool already_bookmarked) OVERRIDE;
321 virtual void ShowBookmarkAppBubble(
322 const WebApplicationInfo& web_app_info,
323 const std::string& extension_id) OVERRIDE;
324 virtual void ShowTranslateBubble(
325 content::WebContents* contents,
326 translate::TranslateStep step,
327 translate::TranslateErrors::Type error_type,
328 bool is_user_gesture) OVERRIDE;
329 #if defined(ENABLE_ONE_CLICK_SIGNIN)
330 virtual void ShowOneClickSigninBubble(
331 OneClickSigninBubbleType type,
332 const base::string16& email,
333 const base::string16& error_message,
334 const StartSyncCallback& start_sync_callback) OVERRIDE;
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(
342 Browser::DownloadClosePreventionType dialog_type,
344 const base::Callback<void(bool)>& callback) OVERRIDE;
345 virtual void UserChangedTheme() OVERRIDE;
346 virtual int GetExtraRenderViewHeight() const OVERRIDE;
347 virtual void WebContentsFocused(content::WebContents* contents) OVERRIDE;
348 virtual void ShowWebsiteSettings(Profile* profile,
349 content::WebContents* web_contents,
351 const content::SSLStatus& ssl) OVERRIDE;
352 virtual void ShowAppMenu() OVERRIDE;
353 virtual bool PreHandleKeyboardEvent(
354 const content::NativeWebKeyboardEvent& event,
355 bool* is_keyboard_shortcut) OVERRIDE;
356 virtual void HandleKeyboardEvent(
357 const content::NativeWebKeyboardEvent& event) OVERRIDE;
358 virtual void Cut() OVERRIDE;
359 virtual void Copy() OVERRIDE;
360 virtual void Paste() 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(AvatarBubbleMode mode,
369 const signin::ManageAccountsParams& manage_accounts_params) OVERRIDE;
370 virtual void ShowPasswordGenerationBubble(
371 const gfx::Rect& rect,
372 const autofill::PasswordForm& form,
373 autofill::PasswordGenerator* password_generator) OVERRIDE;
374 virtual void OverscrollUpdate(int delta_y) OVERRIDE;
375 virtual int GetRenderViewHeightInsetWithDetachedBookmarkBar() OVERRIDE;
376 virtual void ExecuteExtensionCommand(
377 const extensions::Extension* extension,
378 const extensions::Command& command) OVERRIDE;
379 virtual void ShowPageActionPopup(
380 const extensions::Extension* extension) OVERRIDE;
381 virtual void ShowBrowserActionPopup(
382 const extensions::Extension* extension) OVERRIDE;
384 // Overridden from BrowserWindowTesting:
385 virtual BookmarkBarView* GetBookmarkBarView() const OVERRIDE;
386 virtual LocationBarView* GetLocationBarView() const OVERRIDE;
387 virtual views::View* GetTabContentsContainerView() const OVERRIDE;
388 virtual ToolbarView* GetToolbarView() const OVERRIDE;
390 // Overridden from TabStripModelObserver:
391 virtual void TabInsertedAt(content::WebContents* contents,
393 bool foreground) OVERRIDE;
394 virtual void TabDetachedAt(content::WebContents* contents,
396 virtual void TabDeactivated(content::WebContents* contents) OVERRIDE;
397 virtual void TabStripEmpty() OVERRIDE;
398 virtual void WillCloseAllTabs() OVERRIDE;
399 virtual void CloseAllTabsCanceled() OVERRIDE;
401 // Overridden from ui::AcceleratorProvider:
402 virtual bool GetAcceleratorForCommandId(int command_id,
403 ui::Accelerator* accelerator) OVERRIDE;
405 // Overridden from views::WidgetDelegate:
406 virtual bool CanResize() const OVERRIDE;
407 virtual bool CanMaximize() const OVERRIDE;
408 virtual bool CanActivate() const OVERRIDE;
409 virtual base::string16 GetWindowTitle() const OVERRIDE;
410 virtual base::string16 GetAccessibleWindowTitle() const OVERRIDE;
411 virtual views::View* GetInitiallyFocusedView() OVERRIDE;
412 virtual bool ShouldShowWindowTitle() const OVERRIDE;
413 virtual gfx::ImageSkia GetWindowAppIcon() OVERRIDE;
414 virtual gfx::ImageSkia GetWindowIcon() OVERRIDE;
415 virtual bool ShouldShowWindowIcon() const OVERRIDE;
416 virtual bool ExecuteWindowsCommand(int command_id) OVERRIDE;
417 virtual std::string GetWindowName() const OVERRIDE;
418 virtual void SaveWindowPlacement(const gfx::Rect& bounds,
419 ui::WindowShowState show_state) OVERRIDE;
420 virtual bool GetSavedWindowPlacement(
421 const views::Widget* widget,
423 ui::WindowShowState* show_state) const OVERRIDE;
424 virtual views::View* GetContentsView() OVERRIDE;
425 virtual views::ClientView* CreateClientView(views::Widget* widget) OVERRIDE;
426 virtual void OnWindowBeginUserBoundsChange() OVERRIDE;
427 virtual void OnWidgetMove() OVERRIDE;
428 virtual views::Widget* GetWidget() OVERRIDE;
429 virtual const views::Widget* GetWidget() const OVERRIDE;
430 virtual void GetAccessiblePanes(std::vector<View*>* panes) OVERRIDE;
432 // Overridden from views::WidgetObserver:
433 virtual void OnWidgetActivationChanged(views::Widget* widget,
434 bool active) OVERRIDE;
436 // Overridden from views::ClientView:
437 virtual bool CanClose() OVERRIDE;
438 virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE;
439 virtual gfx::Size GetMinimumSize() const OVERRIDE;
441 // InfoBarContainer::Delegate overrides
442 virtual SkColor GetInfoBarSeparatorColor() const OVERRIDE;
443 virtual void InfoBarContainerStateChanged(bool is_animating) OVERRIDE;
444 virtual bool DrawInfoBarArrows(int* x) const OVERRIDE;
446 // Overridden from views::View:
447 virtual const char* GetClassName() const OVERRIDE;
448 virtual void Layout() OVERRIDE;
449 virtual void PaintChildren(gfx::Canvas* canvas,
450 const views::CullSet& cull_set) OVERRIDE;
451 virtual void ViewHierarchyChanged(
452 const ViewHierarchyChangedDetails& details) OVERRIDE;
453 virtual void ChildPreferredSizeChanged(View* child) OVERRIDE;
454 virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE;
455 virtual void OnNativeThemeChanged(const ui::NativeTheme* theme) OVERRIDE;
457 // Overridden from ui::AcceleratorTarget:
458 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE;
460 // OmniboxPopupModelObserver overrides
461 virtual void OnOmniboxPopupShownOrHidden() OVERRIDE;
463 // Testing interface:
464 views::View* GetContentsContainerForTest() { return contents_container_; }
465 views::WebView* GetContentsWebViewForTest() { return contents_web_view_; }
466 views::WebView* GetDevToolsWebViewForTest() { return devtools_web_view_; }
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);
476 enum FullscreenMode {
478 METRO_SNAP_FULLSCREEN
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);
485 // Constructs and initializes the child views.
488 // Callback for the loading animation(s) associated with this view.
489 void LoadingAnimationCallback();
491 // LoadCompleteListener::Delegate implementation. Creates and initializes the
492 // |jumplist_| after the first page load.
493 virtual void OnLoadCompleted() OVERRIDE;
495 // Returns the BrowserViewLayout.
496 BrowserViewLayout* GetBrowserViewLayout() const;
498 // Returns the ContentsLayoutManager.
499 ContentsLayoutManager* GetContentsLayoutManager() const;
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);
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);
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);
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 // This method will not update actual DevTools WebContents, if not
523 // |update_devtools_web_contents|. In this case, manual update is required.
524 void UpdateDevToolsForContents(content::WebContents* web_contents,
525 bool update_devtools_web_contents);
527 // Updates various optional child Views, e.g. Bookmarks Bar, Info Bar or the
528 // Download Shelf in response to a change notification from the specified
529 // |contents|. |contents| can be NULL. In this case, all optional UI will be
531 void UpdateUIForContents(content::WebContents* contents);
533 // Invoked to update the necessary things when our fullscreen state changes
534 // to |fullscreen|. On Windows this is invoked immediately when we toggle the
535 // full screen state. On Linux changing the fullscreen state is async, so we
536 // ask the window to change its fullscreen state, then when we get
537 // notification that it succeeded this method is invoked.
538 // If |url| is not empty, it is the URL of the page that requested fullscreen
539 // (via the fullscreen JS API).
540 // |bubble_type| determines what should be shown in the fullscreen exit
542 void ProcessFullscreen(bool fullscreen,
545 FullscreenExitBubbleType bubble_type);
547 // Returns whether immmersive fullscreen should replace fullscreen. This
548 // should only occur for "browser-fullscreen" for tabbed-typed windows (not
549 // for tab-fullscreen and not for app/popup type windows).
550 bool ShouldUseImmersiveFullscreenForUrl(const GURL& url) const;
552 // Copy the accelerator table from the app resources into something we can
554 void LoadAccelerators();
556 // Retrieves the command id for the specified Windows app command.
557 int GetCommandIDForAppCommandID(int app_command_id) const;
559 // Initialize the hung plugin detector.
560 void InitHangMonitor();
562 // Possibly records a user metrics action corresponding to the passed-in
563 // accelerator. Only implemented for Chrome OS, where we're interested in
564 // learning about how frequently the top-row keys are used.
565 void UpdateAcceleratorMetrics(const ui::Accelerator& accelerator,
568 // Calls |method| which is either WebContents::Cut, ::Copy, or ::Paste,
569 // first trying the content WebContents, then the devtools WebContents, and
570 // lastly the Views::Textfield if one is focused.
571 void DoCutCopyPaste(void (content::WebContents::*method)(),
574 // Calls |method| which is either WebContents::Cut, ::Copy, or ::Paste on
575 // the given WebContents, returning true if it consumed the event.
576 bool DoCutCopyPasteForWebContents(
577 content::WebContents* contents,
578 void (content::WebContents::*method)());
580 // Shows the next app-modal dialog box, if there is one to be shown, or moves
581 // an existing showing one to the front.
582 void ActivateAppModalDialog() const;
584 // Returns the max top arrow height for infobar.
585 int GetMaxTopInfoBarArrowHeight();
587 // Last focused view that issued a tab traversal.
588 int last_focused_view_storage_id_;
590 // The BrowserFrame that hosts this view.
591 BrowserFrame* frame_;
593 // The Browser object we are associated with.
594 scoped_ptr<Browser> browser_;
596 // BrowserView layout (LTR one is pictured here).
598 // --------------------------------------------------------------------
599 // | TopContainerView (top_container_) |
600 // | -------------------------------------------------------------- |
601 // | | Tabs (tabstrip_) | |
602 // | |------------------------------------------------------------| |
603 // | | Navigation buttons, address bar, menu (toolbar_) | |
604 // | -------------------------------------------------------------- |
605 // |------------------------------------------------------------------|
606 // | All infobars (infobar_container_) [1] |
607 // |------------------------------------------------------------------|
608 // | Bookmarks (bookmark_bar_view_) [1] |
609 // |------------------------------------------------------------------|
610 // | Contents container (contents_container_) |
611 // | -------------------------------------------------------------- |
612 // | | devtools_web_view_ | |
613 // | |------------------------------------------------------------| |
614 // | | contents_web_view_ | |
615 // | -------------------------------------------------------------- |
616 // |------------------------------------------------------------------|
617 // | Active downloads (download_shelf_) |
618 // --------------------------------------------------------------------
620 // [1] The bookmark bar and info bar are swapped when on the new tab page.
621 // Additionally when the bookmark bar is detached, contents_container_ is
622 // positioned on top of the bar while the tab's contents are placed below
623 // the bar. This allows the find bar to always align with the top of
624 // contents_container_ regardless if there's bookmark or info bars.
626 // The view that manages the tab strip, toolbar, and sometimes the bookmark
627 // bar. Stacked top in the view hiearachy so it can be used to slide out
628 // the top views in immersive fullscreen.
629 TopContainerView* top_container_;
634 // The Toolbar containing the navigation buttons, menus and the address bar.
635 ToolbarView* toolbar_;
637 // The Bookmark Bar View for this window. Lazily created. May be NULL for
638 // non-tabbed browsers like popups. May not be visible.
639 scoped_ptr<BookmarkBarView> bookmark_bar_view_;
641 // The do-nothing view which controls the z-order of the find bar widget
642 // relative to views which paint into layers and views with an associated
644 View* find_bar_host_view_;
646 // The download shelf view (view at the bottom of the page).
647 scoped_ptr<DownloadShelfView> download_shelf_;
649 // The InfoBarContainerView that contains InfoBars for the current tab.
650 InfoBarContainerView* infobar_container_;
652 // The view that contains the selected WebContents.
653 ContentsWebView* contents_web_view_;
655 // The view that contains devtools window for the selected WebContents.
656 views::WebView* devtools_web_view_;
658 // The view managing the devtools and contents positions.
659 // Handled by ContentsLayoutManager.
660 views::View* contents_container_;
662 // Tracks and stores the last focused view which is not the
663 // devtools_web_view_ or any of its children. Used to restore focus once
664 // the devtools_web_view_ is hidden.
665 scoped_ptr<views::ExternalFocusTracker> devtools_focus_tracker_;
667 // The Status information bubble that appears at the bottom of the window.
668 scoped_ptr<StatusBubbleViews> status_bubble_;
670 // The permission bubble view is the toolkit-specific implementation of the
671 // interface used by the manager to display permissions bubbles.
672 scoped_ptr<PermissionBubbleViewViews> permission_bubble_view_;
674 // A mapping between accelerators and commands.
675 std::map<ui::Accelerator, int> accelerator_table_;
677 // True if we have already been initialized.
680 // True when in ProcessFullscreen(). The flag is used to avoid reentrance and
681 // to ignore requests to layout while in ProcessFullscreen() to reduce
683 bool in_process_fullscreen_;
685 scoped_ptr<FullscreenExitBubbleViews> fullscreen_bubble_;
688 // This object is used to perform periodic actions in a worker
689 // thread. It is currently used to monitor hung plugin windows.
690 WorkerThreadTicker ticker_;
692 // This object is initialized with the frame window HWND. This
693 // object is also passed as a tick handler with the ticker_ object.
694 // It is used to periodically monitor for hung plugin windows
695 HungWindowDetector hung_window_detector_;
697 // This object is invoked by hung_window_detector_ when it detects a hung
699 HungPluginAction hung_plugin_action_;
701 // Helper class to listen for completion of first page load.
702 scoped_ptr<LoadCompleteListener> load_complete_listener_;
704 // The custom JumpList for Windows 7.
705 scoped_refptr<JumpList> jumplist_;
708 // The timer used to update frames for the Loading Animation.
709 base::RepeatingTimer<BrowserView> loading_animation_timer_;
711 views::UnhandledKeyboardEventHandler unhandled_keyboard_event_handler_;
713 // Used to measure the loading spinner animation rate.
714 base::TimeTicks last_animation_time_;
716 // If this flag is set then SetFocusToLocationBar() will set focus to the
717 // location bar even if the browser window is not active.
718 bool force_location_bar_focus_;
720 scoped_ptr<ImmersiveModeController> immersive_mode_controller_;
722 scoped_ptr<ScrollEndEffectController> scroll_end_effect_controller_;
724 scoped_ptr<WebContentsCloseHandler> web_contents_close_handler_;
726 mutable base::WeakPtrFactory<BrowserView> activate_modal_dialog_factory_;
728 DISALLOW_COPY_AND_ASSIGN(BrowserView);
731 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_VIEW_H_