browser_view.h revision f2477e01787aa58f445919b809d89e252beef54f
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 InfoBarContainer::Delegate, 96 public views::SingleSplitViewListener, 97 public gfx::SysColorChangeListener, 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 127 // Initializes (or re-initializes) the status bubble. We try to only create 128 // the bubble once and re-use it for the life of the browser, but certain 129 // events (such as changing enabling/disabling Aero on Win) can force a need 130 // to change some of the bubble's creation parameters. 131 void InitStatusBubble(); 132 133 // Returns the apparent bounds of the toolbar, in BrowserView coordinates. 134 // These differ from |toolbar_.bounds()| in that they match where the toolbar 135 // background image is drawn -- slightly outside the "true" bounds 136 // horizontally. Note that this returns the bounds for the toolbar area. 137 gfx::Rect GetToolbarBounds() const; 138 139 // Returns the constraining bounding box that should be used to lay out the 140 // FindBar within. This is _not_ the size of the find bar, just the bounding 141 // box it should be laid out within. The coordinate system of the returned 142 // rect is in the coordinate system of the frame, since the FindBar is a child 143 // window. 144 gfx::Rect GetFindBarBoundingBox() const; 145 146 // Returns the preferred height of the TabStrip. Used to position the OTR 147 // avatar icon. 148 int GetTabStripHeight() const; 149 150 // Takes some view's origin (relative to this BrowserView) and offsets it such 151 // that it can be used as the source origin for seamlessly tiling the toolbar 152 // background image over that view. 153 gfx::Point OffsetPointForToolbarBackgroundImage( 154 const gfx::Point& point) const; 155 156 // Container for the tabstrip, toolbar, etc. 157 TopContainerView* top_container() { return top_container_; } 158 159 // Accessor for the TabStrip. 160 TabStrip* tabstrip() { return tabstrip_; } 161 162 // Accessor for the Toolbar. 163 ToolbarView* toolbar() { return toolbar_; } 164 165 // Bookmark bar may be NULL, for example for pop-ups. 166 BookmarkBarView* bookmark_bar() { return bookmark_bar_view_.get(); } 167 168 // Returns the do-nothing view which controls the z-order of the find bar 169 // widget relative to views which paint into layers and views which have an 170 // associated NativeView. The presence / visibility of this view is not 171 // indicative of the visibility of the find bar widget or even whether 172 // FindBarController is initialized. 173 View* find_bar_host_view() { return find_bar_host_view_; } 174 175 // Accessor for the InfobarContainer. 176 InfoBarContainerView* infobar_container() { return infobar_container_; } 177 178 // Accessor for the FullscreenExitBubbleViews. 179 FullscreenExitBubbleViews* fullscreen_exit_bubble() { 180 return fullscreen_bubble_.get(); 181 } 182 183 // Returns true if various window components are visible. 184 bool IsTabStripVisible() const; 185 186 // Returns true if the profile associated with this Browser window is 187 // incognito. 188 bool IsOffTheRecord() const; 189 190 // Returns true if the profile associated with this Browser window is 191 // a guest session. 192 bool IsGuestSession() const; 193 194 // Returns true if the profile associated with this Browser window is 195 // not off the record or a guest session. 196 bool IsRegularOrGuestSession() const; 197 198 // Returns the resource ID to use for the OTR icon, which depends on 199 // which layout is being shown and whether we are full-screen. 200 int GetOTRIconResourceID() const; 201 202 // Returns the resource ID to use for the Guest icon, which may depend on 203 // which layout is being shown and whether we are full-screen. 204 int GetGuestIconResourceID() const; 205 206 // Returns true if the non-client view should render an avatar icon. 207 bool ShouldShowAvatar() const; 208 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 212 // otherwise. 213 bool GetAccelerator(int cmd_id, ui::Accelerator* accelerator); 214 215 // Returns true if the specificed |accelerator| is registered with this view. 216 bool IsAcceleratorRegistered(const ui::Accelerator& accelerator); 217 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; 225 226 // Retrieves the icon to use in the frame to indicate an OTR window. 227 gfx::ImageSkia GetOTRAvatarIcon() const; 228 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(); 233 } 234 235 // See ImmersiveModeController for description. 236 ImmersiveModeController* immersive_mode_controller() const { 237 return immersive_mode_controller_.get(); 238 } 239 240 // Restores the focused view. This is also used to set the initial focus 241 // when a new browser window is created. 242 void RestoreFocus(); 243 244 void SetWindowSwitcherButton(views::Button* button); 245 246 views::Button* window_switcher_button() { 247 return window_switcher_button_; 248 } 249 250 // Called after the widget's fullscreen state is changed without going through 251 // FullscreenController. This method does any processing which was skipped. 252 // Only exiting fullscreen in this way is currently supported. 253 void FullscreenStateChanged(); 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 SetTranslateIconToggled(bool is_lit) OVERRIDE; 281 virtual void OnActiveTabChanged(content::WebContents* old_contents, 282 content::WebContents* new_contents, 283 int index, 284 int reason) OVERRIDE; 285 virtual void ZoomChangedForActiveTab(bool can_show_bubble) OVERRIDE; 286 virtual gfx::Rect GetRestoredBounds() const OVERRIDE; 287 virtual ui::WindowShowState GetRestoredState() const OVERRIDE; 288 virtual gfx::Rect GetBounds() const OVERRIDE; 289 virtual bool IsMaximized() const OVERRIDE; 290 virtual bool IsMinimized() const OVERRIDE; 291 virtual void Maximize() OVERRIDE; 292 virtual void Minimize() OVERRIDE; 293 virtual void Restore() OVERRIDE; 294 virtual void EnterFullscreen( 295 const GURL& url, FullscreenExitBubbleType bubble_type) OVERRIDE; 296 virtual void ExitFullscreen() OVERRIDE; 297 virtual void UpdateFullscreenExitBubbleContent( 298 const GURL& url, 299 FullscreenExitBubbleType bubble_type) OVERRIDE; 300 virtual bool ShouldHideUIForFullscreen() const OVERRIDE; 301 virtual bool IsFullscreen() const OVERRIDE; 302 virtual bool IsFullscreenBubbleVisible() const OVERRIDE; 303#if defined(OS_WIN) 304 virtual void SetMetroSnapMode(bool enable) OVERRIDE; 305 virtual bool IsInMetroSnapMode() const OVERRIDE; 306#endif 307 virtual LocationBar* GetLocationBar() const OVERRIDE; 308 virtual void SetFocusToLocationBar(bool select_all) OVERRIDE; 309 virtual void UpdateReloadStopState(bool is_loading, bool force) OVERRIDE; 310 virtual void UpdateToolbar(content::WebContents* contents) OVERRIDE; 311 virtual void FocusToolbar() OVERRIDE; 312 virtual void FocusAppMenu() OVERRIDE; 313 virtual void FocusBookmarksToolbar() OVERRIDE; 314 virtual void FocusInfobars() OVERRIDE; 315 virtual void RotatePaneFocus(bool forwards) OVERRIDE; 316 virtual void DestroyBrowser() OVERRIDE; 317 virtual bool IsBookmarkBarVisible() const OVERRIDE; 318 virtual bool IsBookmarkBarAnimating() const OVERRIDE; 319 virtual bool IsTabStripEditable() const OVERRIDE; 320 virtual bool IsToolbarVisible() const OVERRIDE; 321 virtual gfx::Rect GetRootWindowResizerRect() const OVERRIDE; 322 virtual void DisableInactiveFrame() OVERRIDE; 323 virtual void ConfirmAddSearchProvider(TemplateURL* template_url, 324 Profile* profile) OVERRIDE; 325 virtual void ShowUpdateChromeDialog() OVERRIDE; 326 virtual void ShowBookmarkBubble(const GURL& url, 327 bool already_bookmarked) OVERRIDE; 328 virtual void ShowBookmarkPrompt() OVERRIDE; 329 virtual void ShowTranslateBubble( 330 content::WebContents* contents, 331 TranslateBubbleModel::ViewState view_state) OVERRIDE; 332#if defined(ENABLE_ONE_CLICK_SIGNIN) 333 virtual void ShowOneClickSigninBubble( 334 OneClickSigninBubbleType type, 335 const string16& email, 336 const string16& error_message, 337 const StartSyncCallback& start_sync_callback) OVERRIDE; 338#endif 339 // TODO(beng): Not an override, move somewhere else. 340 void SetDownloadShelfVisible(bool visible); 341 virtual bool IsDownloadShelfVisible() const OVERRIDE; 342 virtual DownloadShelf* GetDownloadShelf() OVERRIDE; 343 virtual void ConfirmBrowserCloseWithPendingDownloads( 344 int download_count, 345 Browser::DownloadClosePreventionType dialog_type, 346 bool app_modal, 347 const base::Callback<void(bool)>& callback) OVERRIDE; 348 virtual void UserChangedTheme() OVERRIDE; 349 virtual int GetExtraRenderViewHeight() const OVERRIDE; 350 virtual void WebContentsFocused(content::WebContents* contents) OVERRIDE; 351 virtual void ShowWebsiteSettings(Profile* profile, 352 content::WebContents* web_contents, 353 const GURL& url, 354 const content::SSLStatus& ssl) OVERRIDE; 355 virtual void ShowAppMenu() OVERRIDE; 356 virtual bool PreHandleKeyboardEvent( 357 const content::NativeWebKeyboardEvent& event, 358 bool* is_keyboard_shortcut) OVERRIDE; 359 virtual void HandleKeyboardEvent( 360 const content::NativeWebKeyboardEvent& event) OVERRIDE; 361 virtual void Cut() OVERRIDE; 362 virtual void Copy() OVERRIDE; 363 virtual void Paste() OVERRIDE; 364 virtual WindowOpenDisposition GetDispositionForPopupBounds( 365 const gfx::Rect& bounds) OVERRIDE; 366 virtual FindBar* CreateFindBar() OVERRIDE; 367 virtual web_modal::WebContentsModalDialogHost* 368 GetWebContentsModalDialogHost() OVERRIDE; 369 virtual void ShowAvatarBubble(content::WebContents* web_contents, 370 const gfx::Rect& rect) OVERRIDE; 371 virtual void ShowAvatarBubbleFromAvatarButton() OVERRIDE; 372 virtual void ShowPasswordGenerationBubble( 373 const gfx::Rect& rect, 374 const autofill::PasswordForm& form, 375 autofill::PasswordGenerator* password_generator) OVERRIDE; 376 virtual void OverscrollUpdate(int delta_y) OVERRIDE; 377 virtual int GetRenderViewHeightInsetWithDetachedBookmarkBar() 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 TabDetachedAt(content::WebContents* contents, 387 int index) OVERRIDE; 388 virtual void TabDeactivated(content::WebContents* contents) OVERRIDE; 389 virtual void TabStripEmpty() OVERRIDE; 390 391 // Overridden from ui::AcceleratorProvider: 392 virtual bool GetAcceleratorForCommandId(int command_id, 393 ui::Accelerator* accelerator) OVERRIDE; 394 395 // Overridden from views::WidgetDelegate: 396 virtual bool CanResize() const OVERRIDE; 397 virtual bool CanMaximize() const OVERRIDE; 398 virtual bool CanActivate() const OVERRIDE; 399 virtual string16 GetWindowTitle() const OVERRIDE; 400 virtual string16 GetAccessibleWindowTitle() const OVERRIDE; 401 virtual views::View* GetInitiallyFocusedView() OVERRIDE; 402 virtual bool ShouldShowWindowTitle() const OVERRIDE; 403 virtual gfx::ImageSkia GetWindowAppIcon() OVERRIDE; 404 virtual gfx::ImageSkia GetWindowIcon() OVERRIDE; 405 virtual bool ShouldShowWindowIcon() const OVERRIDE; 406 virtual bool ExecuteWindowsCommand(int command_id) OVERRIDE; 407 virtual std::string GetWindowName() const OVERRIDE; 408 virtual void SaveWindowPlacement(const gfx::Rect& bounds, 409 ui::WindowShowState show_state) OVERRIDE; 410 virtual bool GetSavedWindowPlacement( 411 const views::Widget* widget, 412 gfx::Rect* bounds, 413 ui::WindowShowState* show_state) const OVERRIDE; 414 virtual views::View* GetContentsView() OVERRIDE; 415 virtual views::ClientView* CreateClientView(views::Widget* widget) OVERRIDE; 416 virtual void OnWindowBeginUserBoundsChange() OVERRIDE; 417 virtual void OnWidgetMove() OVERRIDE; 418 virtual views::Widget* GetWidget() OVERRIDE; 419 virtual const views::Widget* GetWidget() const OVERRIDE; 420 virtual void GetAccessiblePanes(std::vector<View*>* panes) OVERRIDE; 421 422 // Overridden from views::WidgetObserver: 423 virtual void OnWidgetActivationChanged(views::Widget* widget, 424 bool active) OVERRIDE; 425 426 // Overridden from views::ClientView: 427 virtual bool CanClose() OVERRIDE; 428 virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE; 429 virtual gfx::Size GetMinimumSize() OVERRIDE; 430 431 // InfoBarContainer::Delegate overrides 432 virtual SkColor GetInfoBarSeparatorColor() const OVERRIDE; 433 virtual void InfoBarContainerStateChanged(bool is_animating) OVERRIDE; 434 virtual bool DrawInfoBarArrows(int* x) const OVERRIDE; 435 436 // views::SingleSplitViewListener overrides: 437 virtual bool SplitHandleMoved(views::SingleSplitView* sender) OVERRIDE; 438 439 // gfx::SysColorChangeListener overrides: 440 virtual void OnSysColorChange() OVERRIDE; 441 442 // Overridden from views::View: 443 virtual const char* GetClassName() const OVERRIDE; 444 virtual void Layout() OVERRIDE; 445 virtual void PaintChildren(gfx::Canvas* canvas) OVERRIDE; 446 virtual void ViewHierarchyChanged( 447 const ViewHierarchyChangedDetails& details) OVERRIDE; 448 virtual void ChildPreferredSizeChanged(View* child) OVERRIDE; 449 virtual void GetAccessibleState(ui::AccessibleViewState* state) 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::SingleSplitView* GetContentsSplitForTest() { return contents_split_; } 459 ContentsContainer* GetContentsContainerForTest() { 460 return contents_container_; 461 } 462 views::WebView* GetContentsWebViewForTest() { return contents_web_view_; } 463 464 private: 465 // Do not friend BrowserViewLayout. Use the BrowserViewLayoutDelegate 466 // interface to keep these two classes decoupled and testable. 467 friend class BrowserViewLayoutDelegateImpl; 468 FRIEND_TEST_ALL_PREFIXES(BrowserViewTest, BrowserView); 469 FRIEND_TEST_ALL_PREFIXES(BrowserViewsAccessibilityTest, 470 TestAboutChromeViewAccObj); 471 472 enum FullscreenType { 473 FOR_DESKTOP, 474 FOR_METRO 475 }; 476 477 // Appends to |toolbars| a pointer to each AccessiblePaneView that 478 // can be traversed using F6, in the order they should be traversed. 479 void GetAccessiblePanes(std::vector<views::AccessiblePaneView*>* panes); 480 481 // Constructs and initializes the child views. 482 void InitViews(); 483 484 // Callback for the loading animation(s) associated with this view. 485 void LoadingAnimationCallback(); 486 487 // LoadCompleteListener::Delegate implementation. Creates and initializes the 488 // |jumplist_| after the first page load. 489 virtual void OnLoadCompleted() OVERRIDE; 490 491 // Returns the BrowserViewLayout. 492 BrowserViewLayout* GetBrowserViewLayout() const; 493 494 // Layout the Status Bubble. 495 void LayoutStatusBubble(); 496 497 // Prepare to show the Bookmark Bar for the specified WebContents. 498 // Returns true if the Bookmark Bar can be shown (i.e. it's supported for this 499 // Browser type) and there should be a subsequent re-layout to show it. 500 // |contents| can be NULL. 501 bool MaybeShowBookmarkBar(content::WebContents* contents); 502 503 // Moves the bookmark bar view to the specified parent, which may be NULL, 504 // |this|, or |top_container_|. Ensures that |top_container_| stays in front 505 // of |bookmark_bar_view_|. 506 void SetBookmarkBarParent(views::View* new_parent); 507 508 // Prepare to show an Info Bar for the specified WebContents. Returns 509 // true if there is an Info Bar to show and one is supported for this Browser 510 // type, and there should be a subsequent re-layout to show it. 511 // |contents| can be NULL. 512 bool MaybeShowInfoBar(content::WebContents* contents); 513 514 // Updates devtools window for given contents. This method will show docked 515 // devtools window for inspected |web_contents| that has docked devtools 516 // and hide it for NULL or not inspected |web_contents|. It will also make 517 // sure devtools window size and position are restored for given tab. 518 void UpdateDevToolsForContents(content::WebContents* web_contents); 519 520 // Shows docked devtools. 521 void ShowDevToolsContainer(); 522 523 // Hides docked devtools. 524 void HideDevToolsContainer(); 525 526 // Reads split position from the current tab's devtools window and applies 527 // it to the devtools split. 528 void UpdateDevToolsSplitPosition(); 529 530 // Updates various optional child Views, e.g. Bookmarks Bar, Info Bar or the 531 // Download Shelf in response to a change notification from the specified 532 // |contents|. |contents| can be NULL. In this case, all optional UI will be 533 // removed. 534 void UpdateUIForContents(content::WebContents* contents); 535 536 // Invoked to update the necessary things when our fullscreen state changes 537 // to |fullscreen|. On Windows this is invoked immediately when we toggle the 538 // full screen state. On Linux changing the fullscreen state is async, so we 539 // ask the window to change its fullscreen state, then when we get 540 // notification that it succeeded this method is invoked. 541 // If |url| is not empty, it is the URL of the page that requested fullscreen 542 // (via the fullscreen JS API). 543 // |bubble_type| determines what should be shown in the fullscreen exit 544 // bubble. 545 void ProcessFullscreen(bool fullscreen, 546 FullscreenType fullscreen_type, 547 const GURL& url, 548 FullscreenExitBubbleType bubble_type); 549 550 // Returns whether immmersive fullscreen should replace fullscreen. This 551 // should only occur for "browser-fullscreen" for tabbed-typed windows (not 552 // for tab-fullscreen and not for app/popup type windows). 553 bool ShouldUseImmersiveFullscreenForUrl(const GURL& url) const; 554 555 // Copy the accelerator table from the app resources into something we can 556 // use. 557 void LoadAccelerators(); 558 559 // Retrieves the command id for the specified Windows app command. 560 int GetCommandIDForAppCommandID(int app_command_id) const; 561 562 // Initialize the hung plugin detector. 563 void InitHangMonitor(); 564 565 // Possibly records a user metrics action corresponding to the passed-in 566 // accelerator. Only implemented for Chrome OS, where we're interested in 567 // learning about how frequently the top-row keys are used. 568 void UpdateAcceleratorMetrics(const ui::Accelerator& accelerator, 569 int command_id); 570 571 // Calls |method| which is either RenderWidgetHost::Cut, ::Copy, or ::Paste, 572 // first trying the content WebContents, then the devtools WebContents, and 573 // lastly the Views::Textfield if one is focused. 574 void DoCutCopyPaste(void (content::RenderWidgetHost::*method)(), 575 int command_id); 576 577 // Calls |method| which is either RenderWidgetHost::Cut, ::Copy, or ::Paste on 578 // the given WebContents, returning true if it consumed the event. 579 bool DoCutCopyPasteForWebContents( 580 content::WebContents* contents, 581 void (content::RenderWidgetHost::*method)()); 582 583 // Shows the next app-modal dialog box, if there is one to be shown, or moves 584 // an existing showing one to the front. 585 void ActivateAppModalDialog() const; 586 587 // Returns the max top arrow height for infobar. 588 int GetMaxTopInfoBarArrowHeight(); 589 590 // Last focused view that issued a tab traversal. 591 int last_focused_view_storage_id_; 592 593 // The BrowserFrame that hosts this view. 594 BrowserFrame* frame_; 595 596 // The Browser object we are associated with. 597 scoped_ptr<Browser> browser_; 598 599 // BrowserView layout (LTR one is pictured here). 600 // 601 // -------------------------------------------------------------------- 602 // | TopContainerView (top_container_) | 603 // | -------------------------------------------------------------- | 604 // | | Tabs (tabstrip_) | | 605 // | |------------------------------------------------------------| | 606 // | | Navigation buttons, address bar, menu (toolbar_) | | 607 // | -------------------------------------------------------------- | 608 // |------------------------------------------------------------------| 609 // | All infobars (infobar_container_) [1] | 610 // |------------------------------------------------------------------| 611 // | Bookmarks (bookmark_bar_view_) [1] | 612 // |------------------------------------------------------------------| 613 // | Debugger splitter (contents_split_) | 614 // | -------------------------------------------------------------- | 615 // | | Page content (contents_container_) | | 616 // | | -------------------------------------------------------- | | 617 // | | | contents_web_view_ | | | 618 // | | -------------------------------------------------------- | | 619 // | -------------------------------------------------------------- | 620 // | -------------------------------------------------------------- | 621 // | | Debugger (devtools_container_) | | 622 // | | | | 623 // | -------------------------------------------------------------- | 624 // |------------------------------------------------------------------| 625 // | Active downloads (download_shelf_) | 626 // -------------------------------------------------------------------- 627 // 628 // [1] The bookmark bar and info bar are swapped when on the new tab page. 629 // Additionally when the bookmark bar is detached, contents_container_ is 630 // positioned on top of the bar while the tab's contents are placed below 631 // the bar. This allows the find bar to always align with the top of 632 // contents_container_ regardless if there's bookmark or info bars. 633 634 // The view that manages the tab strip, toolbar, and sometimes the bookmark 635 // bar. Stacked top in the view hiearachy so it can be used to slide out 636 // the top views in immersive fullscreen. 637 TopContainerView* top_container_; 638 639 // The TabStrip. 640 TabStrip* tabstrip_; 641 642 // The Toolbar containing the navigation buttons, menus and the address bar. 643 ToolbarView* toolbar_; 644 645 // This button sits next to the tabs on the right hand side and it is used 646 // only in windows metro metro mode to allow the user to flip among browser 647 // windows. 648 views::Button* window_switcher_button_; 649 650 // The Bookmark Bar View for this window. Lazily created. May be NULL for 651 // non-tabbed browsers like popups. May not be visible. 652 scoped_ptr<BookmarkBarView> bookmark_bar_view_; 653 654 // The do-nothing view which controls the z-order of the find bar widget 655 // relative to views which paint into layers and views with an associated 656 // NativeView. 657 View* find_bar_host_view_; 658 659 // The download shelf view (view at the bottom of the page). 660 scoped_ptr<DownloadShelfView> download_shelf_; 661 662 // The InfoBarContainerView that contains InfoBars for the current tab. 663 InfoBarContainerView* infobar_container_; 664 665 // The view that contains the selected WebContents. 666 views::WebView* contents_web_view_; 667 668 // The view that contains devtools window for the selected WebContents. 669 views::WebView* devtools_container_; 670 671 // The view managing the |contents_web_view_|. 672 ContentsContainer* contents_container_; 673 674 // Split view containing the contents container and devtools container. 675 views::SingleSplitView* contents_split_; 676 677 // Side to dock devtools to. 678 DevToolsDockSide devtools_dock_side_; 679 680 // Docked devtools window instance. NULL when current tab is not inspected 681 // or is inspected with undocked version of DevToolsWindow. 682 DevToolsWindow* devtools_window_; 683 684 // Tracks and stores the last focused view which is not the 685 // devtools_container_ or any of its children. Used to restore focus once 686 // the devtools_container_ is hidden. 687 scoped_ptr<views::ExternalFocusTracker> devtools_focus_tracker_; 688 689 // The Status information bubble that appears at the bottom of the window. 690 scoped_ptr<StatusBubbleViews> status_bubble_; 691 692 // A mapping between accelerators and commands. 693 std::map<ui::Accelerator, int> accelerator_table_; 694 695 // True if we have already been initialized. 696 bool initialized_; 697 698 // True when in ProcessFullscreen(). The flag is used to avoid reentrance and 699 // to ignore requests to layout while in ProcessFullscreen() to reduce 700 // jankiness. 701 bool in_process_fullscreen_; 702 703 scoped_ptr<FullscreenExitBubbleViews> fullscreen_bubble_; 704 705#if defined(OS_WIN) && !defined(USE_AURA) 706 // This object is used to perform periodic actions in a worker 707 // thread. It is currently used to monitor hung plugin windows. 708 WorkerThreadTicker ticker_; 709 710 // This object is initialized with the frame window HWND. This 711 // object is also passed as a tick handler with the ticker_ object. 712 // It is used to periodically monitor for hung plugin windows 713 HungWindowDetector hung_window_detector_; 714 715 // This object is invoked by hung_window_detector_ when it detects a hung 716 // plugin window. 717 HungPluginAction hung_plugin_action_; 718 719 // Helper class to listen for completion of first page load. 720 scoped_ptr<LoadCompleteListener> load_complete_listener_; 721 722 // The custom JumpList for Windows 7. 723 scoped_refptr<JumpList> jumplist_; 724#endif 725 726 // The timer used to update frames for the Loading Animation. 727 base::RepeatingTimer<BrowserView> loading_animation_timer_; 728 729 views::UnhandledKeyboardEventHandler unhandled_keyboard_event_handler_; 730 731 // Used to measure the loading spinner animation rate. 732 base::TimeTicks last_animation_time_; 733 734 // If this flag is set then SetFocusToLocationBar() will set focus to the 735 // location bar even if the browser window is not active. 736 bool force_location_bar_focus_; 737 738 scoped_ptr<ImmersiveModeController> immersive_mode_controller_; 739 740 scoped_ptr<ScrollEndEffectController> scroll_end_effect_controller_; 741 742 gfx::ScopedSysColorChangeListener color_change_listener_; 743 744 mutable base::WeakPtrFactory<BrowserView> activate_modal_dialog_factory_; 745 746 DISALLOW_COPY_AND_ASSIGN(BrowserView); 747}; 748 749#endif // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_VIEW_H_ 750