browser_view.h revision bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3
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/load_complete_listener.h" 25#include "ui/base/accelerators/accelerator.h" 26#include "ui/base/models/simple_menu_model.h" 27#include "ui/gfx/native_widget_types.h" 28#include "ui/gfx/sys_color_change_listener.h" 29#include "ui/views/controls/button/button.h" 30#include "ui/views/controls/single_split_view_listener.h" 31#include "ui/views/controls/webview/unhandled_keyboard_event_handler.h" 32#include "ui/views/widget/widget_delegate.h" 33#include "ui/views/widget/widget_observer.h" 34#include "ui/views/window/client_view.h" 35 36#if defined(OS_WIN) 37#include "chrome/browser/hang_monitor/hung_plugin_action.h" 38#include "chrome/browser/hang_monitor/hung_window_detector.h" 39#endif 40 41// NOTE: For more information about the objects and files in this directory, 42// view: http://dev.chromium.org/developers/design-documents/browser-window 43 44class BookmarkBarView; 45class Browser; 46class BrowserViewLayout; 47class ContentsContainer; 48class DownloadShelfView; 49class FullscreenExitBubbleViews; 50class InfoBarContainerView; 51class LocationBarView; 52class StatusBubbleViews; 53class SearchViewController; 54class TabStrip; 55class TabStripModel; 56class ToolbarView; 57class TopContainerView; 58 59#if defined(OS_WIN) 60class JumpList; 61#endif 62 63#if defined(USE_ASH) 64class BrowserLauncherItemController; 65#endif 66 67namespace autofill { 68class PasswordGenerator; 69} 70 71namespace content { 72class RenderWidgetHost; 73} 74 75namespace extensions { 76class Extension; 77} 78 79namespace views { 80class AccessiblePaneView; 81class ExternalFocusTracker; 82class WebView; 83} 84 85/////////////////////////////////////////////////////////////////////////////// 86// BrowserView 87// 88// A ClientView subclass that provides the contents of a browser window, 89// including the TabStrip, toolbars, download shelves, the content area etc. 90// 91class BrowserView : public BrowserWindow, 92 public BrowserWindowTesting, 93 public TabStripModelObserver, 94 public ui::AcceleratorProvider, 95 public views::WidgetDelegate, 96 public views::WidgetObserver, 97 public views::ClientView, 98 public ImmersiveModeController::Delegate, 99 public InfoBarContainer::Delegate, 100 public views::SingleSplitViewListener, 101 public gfx::SysColorChangeListener, 102 public LoadCompleteListener::Delegate, 103 public OmniboxPopupModelObserver { 104 public: 105 // The browser view's class name. 106 static const char kViewClassName[]; 107 108 BrowserView(); 109 virtual ~BrowserView(); 110 111 // Takes ownership of |browser|. 112 void Init(Browser* browser); 113 114 void set_frame(BrowserFrame* frame) { frame_ = frame; } 115 BrowserFrame* frame() const { return frame_; } 116 117 // Returns a pointer to the BrowserView* interface implementation (an 118 // instance of this object, typically) for a given native window, or NULL if 119 // there is no such association. 120 // 121 // Don't use this unless you only have a NativeWindow. In nearly all 122 // situations plumb through browser and use it. 123 static BrowserView* GetBrowserViewForNativeWindow(gfx::NativeWindow window); 124 125 // Returns the BrowserView used for the specified Browser. 126 static BrowserView* GetBrowserViewForBrowser(const Browser* browser); 127 128 // Returns a Browser instance of this view. 129 Browser* browser() { return browser_.get(); } 130 131 // Initializes (or re-initializes) the status bubble. We try to only create 132 // the bubble once and re-use it for the life of the browser, but certain 133 // events (such as changing enabling/disabling Aero on Win) can force a need 134 // to change some of the bubble's creation parameters. 135 void InitStatusBubble(); 136 137 // Returns the apparent bounds of the toolbar, in BrowserView coordinates. 138 // These differ from |toolbar_.bounds()| in that they match where the toolbar 139 // background image is drawn -- slightly outside the "true" bounds 140 // horizontally. Note that this returns the bounds for the toolbar area. 141 gfx::Rect GetToolbarBounds() const; 142 143 // Returns the bounds of the content area, in the coordinates of the 144 // BrowserView's parent. 145 gfx::Rect GetClientAreaBounds() const; 146 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 151 // window. 152 gfx::Rect GetFindBarBoundingBox() const; 153 154 // Returns the preferred height of the TabStrip. Used to position the OTR 155 // avatar icon. 156 int GetTabStripHeight() const; 157 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; 163 164 // Container for the tabstrip, toolbar, etc. 165 TopContainerView* top_container() { return top_container_; } 166 167 // Accessor for the TabStrip. 168 TabStrip* tabstrip() { return tabstrip_; } 169 170 // Accessor for the Toolbar. 171 ToolbarView* toolbar() { return toolbar_; } 172 173 // Bookmark bar may be NULL, for example for pop-ups. 174 BookmarkBarView* bookmark_bar() { return bookmark_bar_view_.get(); } 175 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_; } 182 183 // Accessor for the InfobarContainer. 184 InfoBarContainerView* infobar_container() { return infobar_container_; } 185 186 // Accessor for the FullscreenExitBubbleViews. 187 FullscreenExitBubbleViews* fullscreen_exit_bubble() { 188 return fullscreen_bubble_.get(); 189 } 190 191 // Returns true if various window components are visible. 192 bool IsTabStripVisible() const; 193 194 // Returns true if the profile associated with this Browser window is 195 // incognito. 196 bool IsOffTheRecord() 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 true if the profile associated with this Browser window is 203 // a guest session. 204 bool IsGuestSession() 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 from BookmarkBarView/DownloadShelfView during their show/hide 251 // animations. 252 void ToolbarSizeChanged(bool is_animating); 253 254#if defined(USE_ASH) 255 // Test support. 256 // Note: This is only needed to be BrowserLauncherItemController instead of 257 // LauncherItemController because of the "favicon_loader" member - to be more 258 // exact that member function is the only one being called. 259 // TODO(skuhne): Remove once per-app is default. 260 BrowserLauncherItemController* launcher_item_controller() const { 261 return launcher_item_controller_.get(); 262 } 263#endif 264 265 // Overridden from BrowserWindow: 266 virtual void Show() OVERRIDE; 267 virtual void ShowInactive() OVERRIDE; 268 virtual void Hide() OVERRIDE; 269 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; 270 virtual void Close() OVERRIDE; 271 virtual void Activate() OVERRIDE; 272 virtual void Deactivate() OVERRIDE; 273 virtual bool IsActive() const OVERRIDE; 274 virtual void FlashFrame(bool flash) OVERRIDE; 275 virtual bool IsAlwaysOnTop() const OVERRIDE; 276 virtual gfx::NativeWindow GetNativeWindow() OVERRIDE; 277 virtual BrowserWindowTesting* GetBrowserWindowTesting() OVERRIDE; 278 virtual StatusBubble* GetStatusBubble() OVERRIDE; 279 virtual void UpdateTitleBar() OVERRIDE; 280 virtual void BookmarkBarStateChanged( 281 BookmarkBar::AnimateChangeType change_type) OVERRIDE; 282 virtual void UpdateDevTools() OVERRIDE; 283 virtual void UpdateLoadingAnimations(bool should_animate) OVERRIDE; 284 virtual void SetStarredState(bool is_starred) 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, 311 bool should_restore_state) OVERRIDE; 312 virtual void FocusToolbar() OVERRIDE; 313 virtual void FocusAppMenu() OVERRIDE; 314 virtual void FocusBookmarksToolbar() OVERRIDE; 315 virtual void FocusInfobars() OVERRIDE; 316 virtual void RotatePaneFocus(bool forwards) OVERRIDE; 317 virtual void DestroyBrowser() OVERRIDE; 318 virtual bool IsBookmarkBarVisible() const OVERRIDE; 319 virtual bool IsBookmarkBarAnimating() const OVERRIDE; 320 virtual bool IsTabStripEditable() const OVERRIDE; 321 virtual bool IsToolbarVisible() const OVERRIDE; 322 virtual gfx::Rect GetRootWindowResizerRect() const OVERRIDE; 323 virtual void DisableInactiveFrame() OVERRIDE; 324 virtual void ConfirmAddSearchProvider(TemplateURL* template_url, 325 Profile* profile) OVERRIDE; 326 virtual void ToggleBookmarkBar() OVERRIDE; 327 virtual void ShowUpdateChromeDialog() OVERRIDE; 328 virtual void ShowBookmarkBubble(const GURL& url, 329 bool already_bookmarked) OVERRIDE; 330 virtual void ShowBookmarkPrompt() OVERRIDE; 331#if defined(ENABLE_ONE_CLICK_SIGNIN) 332 virtual void ShowOneClickSigninBubble( 333 OneClickSigninBubbleType type, 334 const string16& email, 335 const string16& error_message, 336 const StartSyncCallback& start_sync_callback) OVERRIDE; 337#endif 338 // TODO(beng): Not an override, move somewhere else. 339 void SetDownloadShelfVisible(bool visible); 340 virtual bool IsDownloadShelfVisible() const OVERRIDE; 341 virtual DownloadShelf* GetDownloadShelf() OVERRIDE; 342 virtual void ConfirmBrowserCloseWithPendingDownloads() OVERRIDE; 343 virtual void UserChangedTheme() OVERRIDE; 344 virtual int GetExtraRenderViewHeight() const OVERRIDE; 345 virtual void WebContentsFocused(content::WebContents* contents) OVERRIDE; 346 virtual void ShowWebsiteSettings(Profile* profile, 347 content::WebContents* web_contents, 348 const GURL& url, 349 const content::SSLStatus& ssl) OVERRIDE; 350 virtual void ShowAppMenu() OVERRIDE; 351 virtual bool PreHandleKeyboardEvent( 352 const content::NativeWebKeyboardEvent& event, 353 bool* is_keyboard_shortcut) OVERRIDE; 354 virtual void HandleKeyboardEvent( 355 const content::NativeWebKeyboardEvent& event) OVERRIDE; 356 virtual void ShowCreateChromeAppShortcutsDialog( 357 Profile*, const extensions::Extension* app) 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() OVERRIDE; 369 virtual void ShowPasswordGenerationBubble( 370 const gfx::Rect& rect, 371 const content::PasswordForm& form, 372 autofill::PasswordGenerator* password_generator) OVERRIDE; 373 virtual void OverscrollUpdate(int delta_y) OVERRIDE; 374 375 // Overridden from BrowserWindowTesting: 376 virtual BookmarkBarView* GetBookmarkBarView() const OVERRIDE; 377 virtual LocationBarView* GetLocationBarView() const OVERRIDE; 378 virtual views::View* GetTabContentsContainerView() const OVERRIDE; 379 virtual ToolbarView* GetToolbarView() const OVERRIDE; 380 381 // Overridden from TabStripModelObserver: 382 virtual void TabDetachedAt(content::WebContents* contents, 383 int index) OVERRIDE; 384 virtual void TabDeactivated(content::WebContents* contents) OVERRIDE; 385 virtual void ActiveTabChanged(content::WebContents* old_contents, 386 content::WebContents* new_contents, 387 int index, 388 int reason) 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 gfx::Rect* bounds, 412 ui::WindowShowState* show_state) const OVERRIDE; 413 virtual views::View* GetContentsView() OVERRIDE; 414 virtual views::ClientView* CreateClientView(views::Widget* widget) OVERRIDE; 415 virtual void OnWindowBeginUserBoundsChange() OVERRIDE; 416 virtual void OnWidgetMove() OVERRIDE; 417 virtual views::Widget* GetWidget() OVERRIDE; 418 virtual const views::Widget* GetWidget() const OVERRIDE; 419 virtual void GetAccessiblePanes(std::vector<View*>* panes) OVERRIDE; 420 421 // Overridden from views::WidgetObserver: 422 virtual void OnWidgetActivationChanged(views::Widget* widget, 423 bool active) OVERRIDE; 424 425 // Overridden from views::ClientView: 426 virtual bool CanClose() OVERRIDE; 427 virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE; 428 virtual gfx::Size GetMinimumSize() OVERRIDE; 429 430 // ImmersiveModeController::Delegate overrides: 431 virtual BookmarkBarView* GetBookmarkBar() OVERRIDE; 432 virtual FullscreenController* GetFullscreenController() OVERRIDE; 433 virtual void FullscreenStateChanged() OVERRIDE; 434 virtual void SetImmersiveStyle(bool immersive) OVERRIDE; 435 virtual content::WebContents* GetWebContents() OVERRIDE; 436 437 // InfoBarContainer::Delegate overrides 438 virtual SkColor GetInfoBarSeparatorColor() const OVERRIDE; 439 virtual void InfoBarContainerStateChanged(bool is_animating) OVERRIDE; 440 virtual bool DrawInfoBarArrows(int* x) const OVERRIDE; 441 442 // views::SingleSplitViewListener overrides: 443 virtual bool SplitHandleMoved(views::SingleSplitView* sender) OVERRIDE; 444 445 // gfx::SysColorChangeListener overrides: 446 virtual void OnSysColorChange() OVERRIDE; 447 448 // Overridden from views::View: 449 virtual const char* GetClassName() const OVERRIDE; 450 virtual void Layout() OVERRIDE; 451 virtual void PaintChildren(gfx::Canvas* canvas) OVERRIDE; 452 virtual void ViewHierarchyChanged( 453 const ViewHierarchyChangedDetails& details) OVERRIDE; 454 virtual void ChildPreferredSizeChanged(View* child) OVERRIDE; 455 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; 456 457 // Overridden from ui::AcceleratorTarget: 458 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; 459 460 // OmniboxPopupModelObserver overrides 461 virtual void OnOmniboxPopupShownOrHidden() OVERRIDE; 462 463 // Testing interface: 464 views::SingleSplitView* GetContentsSplitForTest() { return contents_split_; } 465 ContentsContainer* GetContentsContainerForTest() { 466 return contents_container_; 467 } 468 views::WebView* GetContentsWebViewForTest() { return contents_web_view_; } 469 470 private: 471 // Do not friend BrowserViewLayout. Use the BrowserViewLayoutDelegate 472 // interface to keep these two classes decoupled and testable. 473 friend class BrowserViewLayoutDelegateImpl; 474 FRIEND_TEST_ALL_PREFIXES(BrowserViewTest, BrowserView); 475 FRIEND_TEST_ALL_PREFIXES(BrowserViewsAccessibilityTest, 476 TestAboutChromeViewAccObj); 477 478 enum FullscreenType { 479 FOR_DESKTOP, 480 FOR_METRO 481 }; 482 483 // Appends to |toolbars| a pointer to each AccessiblePaneView that 484 // can be traversed using F6, in the order they should be traversed. 485 void GetAccessiblePanes(std::vector<views::AccessiblePaneView*>* panes); 486 487 // Constructs and initializes the child views. 488 void InitViews(); 489 490 // Callback for the loading animation(s) associated with this view. 491 void LoadingAnimationCallback(); 492 493 // LoadCompleteListener::Delegate implementation. Creates and initializes the 494 // |jumplist_| after the first page load. 495 virtual void OnLoadCompleted() OVERRIDE; 496 497 // Returns the BrowserViewLayout. 498 BrowserViewLayout* GetBrowserViewLayout() const; 499 500 // Layout the Status Bubble. 501 void LayoutStatusBubble(); 502 503 // Prepare to show the Bookmark Bar for the specified WebContents. 504 // Returns true if the Bookmark Bar can be shown (i.e. it's supported for this 505 // Browser type) and there should be a subsequent re-layout to show it. 506 // |contents| can be NULL. 507 bool MaybeShowBookmarkBar(content::WebContents* contents); 508 509 // Moves the bookmark bar view to the specified parent, which may be NULL, 510 // |this|, or |top_container_|. Ensures that |top_container_| stays in front 511 // of |bookmark_bar_view_|. 512 void SetBookmarkBarParent(views::View* new_parent); 513 514 // Prepare to show an Info Bar for the specified WebContents. Returns 515 // true if there is an Info Bar to show and one is supported for this Browser 516 // type, and there should be a subsequent re-layout to show it. 517 // |contents| can be NULL. 518 bool MaybeShowInfoBar(content::WebContents* contents); 519 520 // Updates devtools window for given contents. This method will show docked 521 // devtools window for inspected |web_contents| that has docked devtools 522 // and hide it for NULL or not inspected |web_contents|. It will also make 523 // sure devtools window size and position are restored for given tab. 524 void UpdateDevToolsForContents(content::WebContents* web_contents); 525 526 // Shows docked devtools. 527 void ShowDevToolsContainer(); 528 529 // Hides docked devtools. 530 void HideDevToolsContainer(); 531 532 // Reads split position from the current tab's devtools window and applies 533 // it to the devtools split. 534 void UpdateDevToolsSplitPosition(); 535 536 // Updates various optional child Views, e.g. Bookmarks Bar, Info Bar or the 537 // Download Shelf in response to a change notification from the specified 538 // |contents|. |contents| can be NULL. In this case, all optional UI will be 539 // removed. 540 void UpdateUIForContents(content::WebContents* contents); 541 542 // Invoked to update the necessary things when our fullscreen state changes 543 // to |fullscreen|. On Windows this is invoked immediately when we toggle the 544 // full screen state. On Linux changing the fullscreen state is async, so we 545 // ask the window to change its fullscreen state, then when we get 546 // notification that it succeeded this method is invoked. 547 // If |url| is not empty, it is the URL of the page that requested fullscreen 548 // (via the fullscreen JS API). 549 // |bubble_type| determines what should be shown in the fullscreen exit 550 // bubble. 551 void ProcessFullscreen(bool fullscreen, 552 FullscreenType fullscreen_type, 553 const GURL& url, 554 FullscreenExitBubbleType bubble_type); 555 556 // Returns whether immmersive fullscreen should replace fullscreen. This 557 // should only occur for "browser-fullscreen" for tabbed-typed windows (not 558 // for tab-fullscreen and not for app/popup type windows). 559 bool ShouldUseImmersiveFullscreenForUrl(const GURL& url) const; 560 561 // Copy the accelerator table from the app resources into something we can 562 // use. 563 void LoadAccelerators(); 564 565 // Retrieves the command id for the specified Windows app command. 566 int GetCommandIDForAppCommandID(int app_command_id) const; 567 568 // Initialize the hung plugin detector. 569 void InitHangMonitor(); 570 571 // Possibly records a user metrics action corresponding to the passed-in 572 // accelerator. Only implemented for Chrome OS, where we're interested in 573 // learning about how frequently the top-row keys are used. 574 void UpdateAcceleratorMetrics(const ui::Accelerator& accelerator, 575 int command_id); 576 577 // Create an icon for this window in the launcher (currently only for Ash). 578 void CreateLauncherIcon(); 579 580 // Calls |method| which is either RenderWidgetHost::Cut, ::Copy, or ::Paste, 581 // first trying the content WebContents, then the devtools WebContents, and 582 // lastly the Views::Textfield if one is focused. 583 // |windows_msg_id| is temporary until Win Aura is the default on Windows, 584 // since until then the omnibox doesn't use Views::Textfield. 585 void DoCutCopyPaste(void (content::RenderWidgetHost::*method)(), 586#if defined(OS_WIN) 587 int windows_msg_id, 588#endif 589 int command_id); 590 591 // Calls |method| which is either RenderWidgetHost::Cut, ::Copy, or ::Paste on 592 // the given WebContents, returning true if it consumed the event. 593 bool DoCutCopyPasteForWebContents( 594 content::WebContents* contents, 595 void (content::RenderWidgetHost::*method)()); 596 597 // Shows the next app-modal dialog box, if there is one to be shown, or moves 598 // an existing showing one to the front. 599 void ActivateAppModalDialog() const; 600 601 // Returns the max top arrow height for infobar. 602 int GetMaxTopInfoBarArrowHeight(); 603 604 // Last focused view that issued a tab traversal. 605 int last_focused_view_storage_id_; 606 607 // The BrowserFrame that hosts this view. 608 BrowserFrame* frame_; 609 610 // The Browser object we are associated with. 611 scoped_ptr<Browser> browser_; 612 613 // BrowserView layout (LTR one is pictured here). 614 // 615 // -------------------------------------------------------------------- 616 // | TopContainerView (top_container_) | 617 // | -------------------------------------------------------------- | 618 // | | Tabs (tabstrip_) | | 619 // | |------------------------------------------------------------| | 620 // | | Navigation buttons, address bar, menu (toolbar_) | | 621 // | -------------------------------------------------------------- | 622 // |------------------------------------------------------------------| 623 // | All infobars (infobar_container_) [1] | 624 // |------------------------------------------------------------------| 625 // | Bookmarks (bookmark_bar_view_) [1] | 626 // |------------------------------------------------------------------| 627 // | Debugger splitter (contents_split_) | 628 // | -------------------------------------------------------------- | 629 // | | Page content (contents_container_) | | 630 // | | -------------------------------------------------------- | | 631 // | | | contents_web_view_ | | | 632 // | | -------------------------------------------------------- | | 633 // | -------------------------------------------------------------- | 634 // | -------------------------------------------------------------- | 635 // | | Debugger (devtools_container_) | | 636 // | | | | 637 // | -------------------------------------------------------------- | 638 // |------------------------------------------------------------------| 639 // | Active downloads (download_shelf_) | 640 // -------------------------------------------------------------------- 641 // 642 // [1] The bookmark bar and info bar are swapped when on the new tab page. 643 // Additionally when the bookmark bar is detached, contents_container_ is 644 // positioned on top of the bar while the tab's contents are placed below 645 // the bar. This allows the find bar to always align with the top of 646 // contents_container_ regardless if there's bookmark or info bars. 647 648 // The view that manages the tab strip, toolbar, and sometimes the bookmark 649 // bar. Stacked top in the view hiearachy so it can be used to slide out 650 // the top views in immersive fullscreen. 651 TopContainerView* top_container_; 652 653 // The TabStrip. 654 TabStrip* tabstrip_; 655 656 // The Toolbar containing the navigation buttons, menus and the address bar. 657 ToolbarView* toolbar_; 658 659 // This button sits next to the tabs on the right hand side and it is used 660 // only in windows metro metro mode to allow the user to flip among browser 661 // windows. 662 views::Button* window_switcher_button_; 663 664 // The Bookmark Bar View for this window. Lazily created. May be NULL for 665 // non-tabbed browsers like popups. May not be visible. 666 scoped_ptr<BookmarkBarView> bookmark_bar_view_; 667 668 // The do-nothing view which controls the z-order of the find bar widget 669 // relative to views which paint into layers and views with an associated 670 // NativeView. 671 View* find_bar_host_view_; 672 673 // The download shelf view (view at the bottom of the page). 674 scoped_ptr<DownloadShelfView> download_shelf_; 675 676 // The InfoBarContainerView that contains InfoBars for the current tab. 677 InfoBarContainerView* infobar_container_; 678 679 // The view that contains the selected WebContents. 680 views::WebView* contents_web_view_; 681 682 // The view that contains devtools window for the selected WebContents. 683 views::WebView* devtools_container_; 684 685 // The view managing the |contents_web_view_|. 686 ContentsContainer* contents_container_; 687 688 // Split view containing the contents container and devtools container. 689 views::SingleSplitView* contents_split_; 690 691 // Side to dock devtools to. 692 DevToolsDockSide devtools_dock_side_; 693 694 // Docked devtools window instance. NULL when current tab is not inspected 695 // or is inspected with undocked version of DevToolsWindow. 696 DevToolsWindow* devtools_window_; 697 698 // Tracks and stores the last focused view which is not the 699 // devtools_container_ or any of its children. Used to restore focus once 700 // the devtools_container_ is hidden. 701 scoped_ptr<views::ExternalFocusTracker> devtools_focus_tracker_; 702 703 // The Status information bubble that appears at the bottom of the window. 704 scoped_ptr<StatusBubbleViews> status_bubble_; 705 706 // A mapping between accelerators and commands. 707 std::map<ui::Accelerator, int> accelerator_table_; 708 709 // True if we have already been initialized. 710 bool initialized_; 711 712 // True if we should ignore requests to layout. This is set while toggling 713 // fullscreen mode on and off to reduce jankiness. 714 bool ignore_layout_; 715 716 scoped_ptr<FullscreenExitBubbleViews> fullscreen_bubble_; 717 718#if defined(OS_WIN) && !defined(USE_AURA) 719 // This object is used to perform periodic actions in a worker 720 // thread. It is currently used to monitor hung plugin windows. 721 WorkerThreadTicker ticker_; 722 723 // This object is initialized with the frame window HWND. This 724 // object is also passed as a tick handler with the ticker_ object. 725 // It is used to periodically monitor for hung plugin windows 726 HungWindowDetector hung_window_detector_; 727 728 // This object is invoked by hung_window_detector_ when it detects a hung 729 // plugin window. 730 HungPluginAction hung_plugin_action_; 731 732 // Helper class to listen for completion of first page load. 733 scoped_ptr<LoadCompleteListener> load_complete_listener_; 734 735 // The custom JumpList for Windows 7. 736 scoped_refptr<JumpList> jumplist_; 737#endif 738 739#if defined(USE_ASH) 740 // Needs to be BrowserLauncerItemController for 741 // "BrowserActivationStateChanged" and "favicon_loader". 742 // TODO(skuhne): Remove once per-app is default. 743 scoped_ptr<BrowserLauncherItemController> launcher_item_controller_; 744#endif 745 746 // The timer used to update frames for the Loading Animation. 747 base::RepeatingTimer<BrowserView> loading_animation_timer_; 748 749 views::UnhandledKeyboardEventHandler unhandled_keyboard_event_handler_; 750 751 // Used to measure the loading spinner animation rate. 752 base::TimeTicks last_animation_time_; 753 754 // If this flag is set then SetFocusToLocationBar() will set focus to the 755 // location bar even if the browser window is not active. 756 bool force_location_bar_focus_; 757 758 scoped_ptr<ImmersiveModeController> immersive_mode_controller_; 759 760 gfx::ScopedSysColorChangeListener color_change_listener_; 761 762 mutable base::WeakPtrFactory<BrowserView> activate_modal_dialog_factory_; 763 764 DISALLOW_COPY_AND_ASSIGN(BrowserView); 765}; 766 767#endif // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_VIEW_H_ 768