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 45 class BookmarkBarView; 46 class Browser; 47 class BrowserViewLayout; 48 class ContentsContainer; 49 class DownloadShelfView; 50 class FullscreenExitBubbleViews; 51 class InfoBarContainerView; 52 class LocationBarView; 53 class StatusBubbleViews; 54 class SearchViewController; 55 class TabStrip; 56 class TabStripModel; 57 class ToolbarView; 58 class TopContainerView; 59 60 #if defined(OS_WIN) 61 class JumpList; 62 #endif 63 64 namespace autofill { 65 class PasswordGenerator; 66 } 67 68 namespace content { 69 class RenderWidgetHost; 70 } 71 72 namespace extensions { 73 class Extension; 74 } 75 76 namespace views { 77 class AccessiblePaneView; 78 class ExternalFocusTracker; 79 class 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 // 88 class 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, 332 TranslateErrors::Type error_type) OVERRIDE; 333 #if defined(ENABLE_ONE_CLICK_SIGNIN) 334 virtual void ShowOneClickSigninBubble( 335 OneClickSigninBubbleType type, 336 const base::string16& email, 337 const base::string16& error_message, 338 const StartSyncCallback& start_sync_callback) OVERRIDE; 339 #endif 340 // TODO(beng): Not an override, move somewhere else. 341 void SetDownloadShelfVisible(bool visible); 342 virtual bool IsDownloadShelfVisible() const OVERRIDE; 343 virtual DownloadShelf* GetDownloadShelf() OVERRIDE; 344 virtual void ConfirmBrowserCloseWithPendingDownloads( 345 int download_count, 346 Browser::DownloadClosePreventionType dialog_type, 347 bool app_modal, 348 const base::Callback<void(bool)>& callback) OVERRIDE; 349 virtual void UserChangedTheme() OVERRIDE; 350 virtual int GetExtraRenderViewHeight() const OVERRIDE; 351 virtual void WebContentsFocused(content::WebContents* contents) OVERRIDE; 352 virtual void ShowWebsiteSettings(Profile* profile, 353 content::WebContents* web_contents, 354 const GURL& url, 355 const content::SSLStatus& ssl) OVERRIDE; 356 virtual void ShowAppMenu() OVERRIDE; 357 virtual bool PreHandleKeyboardEvent( 358 const content::NativeWebKeyboardEvent& event, 359 bool* is_keyboard_shortcut) OVERRIDE; 360 virtual void HandleKeyboardEvent( 361 const content::NativeWebKeyboardEvent& event) OVERRIDE; 362 virtual void Cut() OVERRIDE; 363 virtual void Copy() OVERRIDE; 364 virtual void Paste() OVERRIDE; 365 virtual WindowOpenDisposition GetDispositionForPopupBounds( 366 const gfx::Rect& bounds) OVERRIDE; 367 virtual FindBar* CreateFindBar() OVERRIDE; 368 virtual web_modal::WebContentsModalDialogHost* 369 GetWebContentsModalDialogHost() OVERRIDE; 370 virtual void ShowAvatarBubble(content::WebContents* web_contents, 371 const gfx::Rect& rect) OVERRIDE; 372 virtual void ShowAvatarBubbleFromAvatarButton() OVERRIDE; 373 virtual void ShowPasswordGenerationBubble( 374 const gfx::Rect& rect, 375 const autofill::PasswordForm& form, 376 autofill::PasswordGenerator* password_generator) OVERRIDE; 377 virtual void OverscrollUpdate(int delta_y) OVERRIDE; 378 virtual int GetRenderViewHeightInsetWithDetachedBookmarkBar() OVERRIDE; 379 380 // Overridden from BrowserWindowTesting: 381 virtual BookmarkBarView* GetBookmarkBarView() const OVERRIDE; 382 virtual LocationBarView* GetLocationBarView() const OVERRIDE; 383 virtual views::View* GetTabContentsContainerView() const OVERRIDE; 384 virtual ToolbarView* GetToolbarView() const OVERRIDE; 385 386 // Overridden from TabStripModelObserver: 387 virtual void TabDetachedAt(content::WebContents* contents, 388 int index) OVERRIDE; 389 virtual void TabDeactivated(content::WebContents* contents) OVERRIDE; 390 virtual void TabStripEmpty() OVERRIDE; 391 392 // Overridden from ui::AcceleratorProvider: 393 virtual bool GetAcceleratorForCommandId(int command_id, 394 ui::Accelerator* accelerator) OVERRIDE; 395 396 // Overridden from views::WidgetDelegate: 397 virtual bool CanResize() const OVERRIDE; 398 virtual bool CanMaximize() const OVERRIDE; 399 virtual bool CanActivate() const OVERRIDE; 400 virtual base::string16 GetWindowTitle() const OVERRIDE; 401 virtual base::string16 GetAccessibleWindowTitle() const OVERRIDE; 402 virtual views::View* GetInitiallyFocusedView() OVERRIDE; 403 virtual bool ShouldShowWindowTitle() const OVERRIDE; 404 virtual gfx::ImageSkia GetWindowAppIcon() OVERRIDE; 405 virtual gfx::ImageSkia GetWindowIcon() OVERRIDE; 406 virtual bool ShouldShowWindowIcon() const OVERRIDE; 407 virtual bool ExecuteWindowsCommand(int command_id) OVERRIDE; 408 virtual std::string GetWindowName() const OVERRIDE; 409 virtual void SaveWindowPlacement(const gfx::Rect& bounds, 410 ui::WindowShowState show_state) OVERRIDE; 411 virtual bool GetSavedWindowPlacement( 412 const views::Widget* widget, 413 gfx::Rect* bounds, 414 ui::WindowShowState* show_state) const OVERRIDE; 415 virtual views::View* GetContentsView() OVERRIDE; 416 virtual views::ClientView* CreateClientView(views::Widget* widget) OVERRIDE; 417 virtual void OnWindowBeginUserBoundsChange() OVERRIDE; 418 virtual void OnWidgetMove() OVERRIDE; 419 virtual views::Widget* GetWidget() OVERRIDE; 420 virtual const views::Widget* GetWidget() const OVERRIDE; 421 virtual void GetAccessiblePanes(std::vector<View*>* panes) OVERRIDE; 422 423 // Overridden from views::WidgetObserver: 424 virtual void OnWidgetActivationChanged(views::Widget* widget, 425 bool active) OVERRIDE; 426 427 // Overridden from views::ClientView: 428 virtual bool CanClose() OVERRIDE; 429 virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE; 430 virtual gfx::Size GetMinimumSize() OVERRIDE; 431 432 // InfoBarContainer::Delegate overrides 433 virtual SkColor GetInfoBarSeparatorColor() const OVERRIDE; 434 virtual void InfoBarContainerStateChanged(bool is_animating) OVERRIDE; 435 virtual bool DrawInfoBarArrows(int* x) const OVERRIDE; 436 437 // views::SingleSplitViewListener overrides: 438 virtual bool SplitHandleMoved(views::SingleSplitView* sender) OVERRIDE; 439 440 // gfx::SysColorChangeListener overrides: 441 virtual void OnSysColorChange() OVERRIDE; 442 443 // Overridden from views::View: 444 virtual const char* GetClassName() const OVERRIDE; 445 virtual void Layout() OVERRIDE; 446 virtual void PaintChildren(gfx::Canvas* canvas) OVERRIDE; 447 virtual void ViewHierarchyChanged( 448 const ViewHierarchyChangedDetails& details) OVERRIDE; 449 virtual void ChildPreferredSizeChanged(View* child) OVERRIDE; 450 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; 451 452 // Overridden from ui::AcceleratorTarget: 453 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; 454 455 // OmniboxPopupModelObserver overrides 456 virtual void OnOmniboxPopupShownOrHidden() OVERRIDE; 457 458 // Testing interface: 459 views::SingleSplitView* GetContentsSplitForTest() { return contents_split_; } 460 ContentsContainer* GetContentsContainerForTest() { 461 return contents_container_; 462 } 463 views::WebView* GetContentsWebViewForTest() { return contents_web_view_; } 464 465 private: 466 // Do not friend BrowserViewLayout. Use the BrowserViewLayoutDelegate 467 // interface to keep these two classes decoupled and testable. 468 friend class BrowserViewLayoutDelegateImpl; 469 FRIEND_TEST_ALL_PREFIXES(BrowserViewTest, BrowserView); 470 FRIEND_TEST_ALL_PREFIXES(BrowserViewsAccessibilityTest, 471 TestAboutChromeViewAccObj); 472 473 enum FullscreenType { 474 FOR_DESKTOP, 475 FOR_METRO 476 }; 477 478 // Appends to |toolbars| a pointer to each AccessiblePaneView that 479 // can be traversed using F6, in the order they should be traversed. 480 void GetAccessiblePanes(std::vector<views::AccessiblePaneView*>* panes); 481 482 // Constructs and initializes the child views. 483 void InitViews(); 484 485 // Callback for the loading animation(s) associated with this view. 486 void LoadingAnimationCallback(); 487 488 // LoadCompleteListener::Delegate implementation. Creates and initializes the 489 // |jumplist_| after the first page load. 490 virtual void OnLoadCompleted() OVERRIDE; 491 492 // Returns the BrowserViewLayout. 493 BrowserViewLayout* GetBrowserViewLayout() const; 494 495 // Layout the Status Bubble. 496 void LayoutStatusBubble(); 497 498 // Prepare to show the Bookmark Bar for the specified WebContents. 499 // Returns true if the Bookmark Bar can be shown (i.e. it's supported for this 500 // Browser type) and there should be a subsequent re-layout to show it. 501 // |contents| can be NULL. 502 bool MaybeShowBookmarkBar(content::WebContents* contents); 503 504 // Moves the bookmark bar view to the specified parent, which may be NULL, 505 // |this|, or |top_container_|. Ensures that |top_container_| stays in front 506 // of |bookmark_bar_view_|. 507 void SetBookmarkBarParent(views::View* new_parent); 508 509 // Prepare to show an Info Bar for the specified WebContents. Returns 510 // true if there is an Info Bar to show and one is supported for this Browser 511 // type, and there should be a subsequent re-layout to show it. 512 // |contents| can be NULL. 513 bool MaybeShowInfoBar(content::WebContents* contents); 514 515 // Updates devtools window for given contents. This method will show docked 516 // devtools window for inspected |web_contents| that has docked devtools 517 // and hide it for NULL or not inspected |web_contents|. It will also make 518 // sure devtools window size and position are restored for given tab. 519 void UpdateDevToolsForContents(content::WebContents* web_contents); 520 521 // Shows docked devtools. 522 void ShowDevToolsContainer(); 523 524 // Hides docked devtools. 525 void HideDevToolsContainer(); 526 527 // Reads split position from the current tab's devtools window and applies 528 // it to the devtools split. 529 void UpdateDevToolsSplitPosition(); 530 531 // Updates various optional child Views, e.g. Bookmarks Bar, Info Bar or the 532 // Download Shelf in response to a change notification from the specified 533 // |contents|. |contents| can be NULL. In this case, all optional UI will be 534 // removed. 535 void UpdateUIForContents(content::WebContents* contents); 536 537 // Invoked to update the necessary things when our fullscreen state changes 538 // to |fullscreen|. On Windows this is invoked immediately when we toggle the 539 // full screen state. On Linux changing the fullscreen state is async, so we 540 // ask the window to change its fullscreen state, then when we get 541 // notification that it succeeded this method is invoked. 542 // If |url| is not empty, it is the URL of the page that requested fullscreen 543 // (via the fullscreen JS API). 544 // |bubble_type| determines what should be shown in the fullscreen exit 545 // bubble. 546 void ProcessFullscreen(bool fullscreen, 547 FullscreenType fullscreen_type, 548 const GURL& url, 549 FullscreenExitBubbleType bubble_type); 550 551 // Returns whether immmersive fullscreen should replace fullscreen. This 552 // should only occur for "browser-fullscreen" for tabbed-typed windows (not 553 // for tab-fullscreen and not for app/popup type windows). 554 bool ShouldUseImmersiveFullscreenForUrl(const GURL& url) const; 555 556 // Copy the accelerator table from the app resources into something we can 557 // use. 558 void LoadAccelerators(); 559 560 // Retrieves the command id for the specified Windows app command. 561 int GetCommandIDForAppCommandID(int app_command_id) const; 562 563 // Initialize the hung plugin detector. 564 void InitHangMonitor(); 565 566 // Possibly records a user metrics action corresponding to the passed-in 567 // accelerator. Only implemented for Chrome OS, where we're interested in 568 // learning about how frequently the top-row keys are used. 569 void UpdateAcceleratorMetrics(const ui::Accelerator& accelerator, 570 int command_id); 571 572 // Calls |method| which is either RenderWidgetHost::Cut, ::Copy, or ::Paste, 573 // first trying the content WebContents, then the devtools WebContents, and 574 // lastly the Views::Textfield if one is focused. 575 void DoCutCopyPaste(void (content::RenderWidgetHost::*method)(), 576 int command_id); 577 578 // Calls |method| which is either RenderWidgetHost::Cut, ::Copy, or ::Paste on 579 // the given WebContents, returning true if it consumed the event. 580 bool DoCutCopyPasteForWebContents( 581 content::WebContents* contents, 582 void (content::RenderWidgetHost::*method)()); 583 584 // Shows the next app-modal dialog box, if there is one to be shown, or moves 585 // an existing showing one to the front. 586 void ActivateAppModalDialog() const; 587 588 // Returns the max top arrow height for infobar. 589 int GetMaxTopInfoBarArrowHeight(); 590 591 // Last focused view that issued a tab traversal. 592 int last_focused_view_storage_id_; 593 594 // The BrowserFrame that hosts this view. 595 BrowserFrame* frame_; 596 597 // The Browser object we are associated with. 598 scoped_ptr<Browser> browser_; 599 600 // BrowserView layout (LTR one is pictured here). 601 // 602 // -------------------------------------------------------------------- 603 // | TopContainerView (top_container_) | 604 // | -------------------------------------------------------------- | 605 // | | Tabs (tabstrip_) | | 606 // | |------------------------------------------------------------| | 607 // | | Navigation buttons, address bar, menu (toolbar_) | | 608 // | -------------------------------------------------------------- | 609 // |------------------------------------------------------------------| 610 // | All infobars (infobar_container_) [1] | 611 // |------------------------------------------------------------------| 612 // | Bookmarks (bookmark_bar_view_) [1] | 613 // |------------------------------------------------------------------| 614 // | Debugger splitter (contents_split_) | 615 // | -------------------------------------------------------------- | 616 // | | Page content (contents_container_) | | 617 // | | -------------------------------------------------------- | | 618 // | | | contents_web_view_ | | | 619 // | | -------------------------------------------------------- | | 620 // | -------------------------------------------------------------- | 621 // | -------------------------------------------------------------- | 622 // | | Debugger (devtools_container_) | | 623 // | | | | 624 // | -------------------------------------------------------------- | 625 // |------------------------------------------------------------------| 626 // | Active downloads (download_shelf_) | 627 // -------------------------------------------------------------------- 628 // 629 // [1] The bookmark bar and info bar are swapped when on the new tab page. 630 // Additionally when the bookmark bar is detached, contents_container_ is 631 // positioned on top of the bar while the tab's contents are placed below 632 // the bar. This allows the find bar to always align with the top of 633 // contents_container_ regardless if there's bookmark or info bars. 634 635 // The view that manages the tab strip, toolbar, and sometimes the bookmark 636 // bar. Stacked top in the view hiearachy so it can be used to slide out 637 // the top views in immersive fullscreen. 638 TopContainerView* top_container_; 639 640 // The TabStrip. 641 TabStrip* tabstrip_; 642 643 // The Toolbar containing the navigation buttons, menus and the address bar. 644 ToolbarView* toolbar_; 645 646 // This button sits next to the tabs on the right hand side and it is used 647 // only in windows metro metro mode to allow the user to flip among browser 648 // windows. 649 views::Button* window_switcher_button_; 650 651 // The Bookmark Bar View for this window. Lazily created. May be NULL for 652 // non-tabbed browsers like popups. May not be visible. 653 scoped_ptr<BookmarkBarView> bookmark_bar_view_; 654 655 // The do-nothing view which controls the z-order of the find bar widget 656 // relative to views which paint into layers and views with an associated 657 // NativeView. 658 View* find_bar_host_view_; 659 660 // The download shelf view (view at the bottom of the page). 661 scoped_ptr<DownloadShelfView> download_shelf_; 662 663 // The InfoBarContainerView that contains InfoBars for the current tab. 664 InfoBarContainerView* infobar_container_; 665 666 // The view that contains the selected WebContents. 667 views::WebView* contents_web_view_; 668 669 // The view that contains devtools window for the selected WebContents. 670 views::WebView* devtools_container_; 671 672 // The view managing the |contents_web_view_|. 673 ContentsContainer* contents_container_; 674 675 // Split view containing the contents container and devtools container. 676 views::SingleSplitView* contents_split_; 677 678 // Side to dock devtools to. 679 DevToolsDockSide devtools_dock_side_; 680 681 // Docked devtools window instance. NULL when current tab is not inspected 682 // or is inspected with undocked version of DevToolsWindow. 683 DevToolsWindow* devtools_window_; 684 685 // Tracks and stores the last focused view which is not the 686 // devtools_container_ or any of its children. Used to restore focus once 687 // the devtools_container_ is hidden. 688 scoped_ptr<views::ExternalFocusTracker> devtools_focus_tracker_; 689 690 // The Status information bubble that appears at the bottom of the window. 691 scoped_ptr<StatusBubbleViews> status_bubble_; 692 693 // A mapping between accelerators and commands. 694 std::map<ui::Accelerator, int> accelerator_table_; 695 696 // True if we have already been initialized. 697 bool initialized_; 698 699 // True when in ProcessFullscreen(). The flag is used to avoid reentrance and 700 // to ignore requests to layout while in ProcessFullscreen() to reduce 701 // jankiness. 702 bool in_process_fullscreen_; 703 704 scoped_ptr<FullscreenExitBubbleViews> fullscreen_bubble_; 705 706 #if defined(OS_WIN) 707 // This object is used to perform periodic actions in a worker 708 // thread. It is currently used to monitor hung plugin windows. 709 WorkerThreadTicker ticker_; 710 711 // This object is initialized with the frame window HWND. This 712 // object is also passed as a tick handler with the ticker_ object. 713 // It is used to periodically monitor for hung plugin windows 714 HungWindowDetector hung_window_detector_; 715 716 // This object is invoked by hung_window_detector_ when it detects a hung 717 // plugin window. 718 HungPluginAction hung_plugin_action_; 719 720 // Helper class to listen for completion of first page load. 721 scoped_ptr<LoadCompleteListener> load_complete_listener_; 722 723 // The custom JumpList for Windows 7. 724 scoped_refptr<JumpList> jumplist_; 725 #endif 726 727 // The timer used to update frames for the Loading Animation. 728 base::RepeatingTimer<BrowserView> loading_animation_timer_; 729 730 views::UnhandledKeyboardEventHandler unhandled_keyboard_event_handler_; 731 732 // Used to measure the loading spinner animation rate. 733 base::TimeTicks last_animation_time_; 734 735 // If this flag is set then SetFocusToLocationBar() will set focus to the 736 // location bar even if the browser window is not active. 737 bool force_location_bar_focus_; 738 739 scoped_ptr<ImmersiveModeController> immersive_mode_controller_; 740 741 scoped_ptr<ScrollEndEffectController> scroll_end_effect_controller_; 742 743 gfx::ScopedSysColorChangeListener color_change_listener_; 744 745 mutable base::WeakPtrFactory<BrowserView> activate_modal_dialog_factory_; 746 747 DISALLOW_COPY_AND_ASSIGN(BrowserView); 748 }; 749 750 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_VIEW_H_ 751