browser_view.h revision 2a99a7e74a7f215066514fe81d2bfa6639d9eddd
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.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/tabs/tab_strip_model_observer.h" 21#include "chrome/browser/ui/views/frame/browser_frame.h" 22#include "chrome/browser/ui/views/load_complete_listener.h" 23#include "chrome/browser/ui/views/unhandled_keyboard_event_handler.h" 24#include "ui/base/accelerators/accelerator.h" 25#include "ui/base/models/simple_menu_model.h" 26#include "ui/gfx/native_widget_types.h" 27#include "ui/gfx/sys_color_change_listener.h" 28#include "ui/views/controls/button/button.h" 29#include "ui/views/controls/single_split_view_listener.h" 30#include "ui/views/widget/widget_delegate.h" 31#include "ui/views/widget/widget_observer.h" 32#include "ui/views/window/client_view.h" 33 34#if defined(OS_WIN) 35#include "chrome/browser/hang_monitor/hung_plugin_action.h" 36#include "chrome/browser/hang_monitor/hung_window_detector.h" 37#endif 38 39// NOTE: For more information about the objects and files in this directory, 40// view: http://dev.chromium.org/developers/design-documents/browser-window 41 42class BookmarkBarView; 43class Browser; 44class BrowserViewLayout; 45class ContentsContainer; 46class DownloadShelfView; 47class FullscreenExitBubbleViews; 48class ImmersiveModeController; 49class InfoBarContainerView; 50class InstantOverlayControllerViews; 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 InfoBarContainer::Delegate, 99 public views::SingleSplitViewListener, 100 public gfx::SysColorChangeListener, 101 public LoadCompleteListener::Delegate { 102 public: 103 // The browser view's class name. 104 static const char kViewClassName[]; 105 106 explicit BrowserView(Browser* browser); 107 virtual ~BrowserView(); 108 109 void set_frame(BrowserFrame* frame) { frame_ = frame; } 110 BrowserFrame* frame() const { return frame_; } 111 112 // Returns a pointer to the BrowserView* interface implementation (an 113 // instance of this object, typically) for a given native window, or NULL if 114 // there is no such association. 115 // 116 // Don't use this unless you only have a NativeWindow. In nearly all 117 // situations plumb through browser and use it. 118 static BrowserView* GetBrowserViewForNativeWindow(gfx::NativeWindow window); 119 120 // Returns the BrowserView used for the specified Browser. 121 static BrowserView* GetBrowserViewForBrowser(const Browser* browser); 122 123 // Returns a Browser instance of this view. 124 Browser* browser() { return browser_.get(); } 125 126 // Returns the apparent bounds of the toolbar, in BrowserView coordinates. 127 // These differ from |toolbar_.bounds()| in that they match where the toolbar 128 // background image is drawn -- slightly outside the "true" bounds 129 // horizontally. Note that this returns the bounds for the toolbar area. 130 virtual gfx::Rect GetToolbarBounds() const; 131 132 // Returns the bounds of the content area, in the coordinates of the 133 // BrowserView's parent. 134 gfx::Rect GetClientAreaBounds() const; 135 136 // Returns the constraining bounding box that should be used to lay out the 137 // FindBar within. This is _not_ the size of the find bar, just the bounding 138 // box it should be laid out within. The coordinate system of the returned 139 // rect is in the coordinate system of the frame, since the FindBar is a child 140 // window. 141 gfx::Rect GetFindBarBoundingBox() const; 142 143 // Returns the preferred height of the TabStrip. Used to position the OTR 144 // avatar icon. 145 virtual int GetTabStripHeight() const; 146 147 // Takes some view's origin (relative to this BrowserView) and offsets it such 148 // that it can be used as the source origin for seamlessly tiling the toolbar 149 // background image over that view. 150 gfx::Point OffsetPointForToolbarBackgroundImage( 151 const gfx::Point& point) const; 152 153 // Container for the tabstrip, toolbar, etc. 154 TopContainerView* top_container() { return top_container_; } 155 156 // Accessor for the TabStrip. 157 TabStrip* tabstrip() { return tabstrip_; } 158 159 // Accessor for the Toolbar. 160 ToolbarView* toolbar() { return toolbar_; } 161 162 // Accessor for the InfobarContainer. 163 InfoBarContainerView* infobar_container() { return infobar_container_; } 164 165 // Returns true if various window components are visible. 166 virtual bool IsTabStripVisible() const; 167 168 // Returns true if the profile associated with this Browser window is 169 // incognito. 170 bool IsOffTheRecord() const; 171 172 // Returns true if the profile associated with this Browser window is 173 // a guest session. 174 bool IsGuestSession() const; 175 176 // Returns true if the non-client view should render an avatar icon. 177 virtual bool ShouldShowAvatar() const; 178 179 // Handle the specified |accelerator| being pressed. 180 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; 181 182 // Provides the containing frame with the accelerator for the specified 183 // command id. This can be used to provide menu item shortcut hints etc. 184 // Returns true if an accelerator was found for the specified |cmd_id|, false 185 // otherwise. 186 bool GetAccelerator(int cmd_id, ui::Accelerator* accelerator); 187 188 // Returns the active WebContents. Used by our NonClientView's 189 // TabIconView::TabContentsProvider implementations. 190 // TODO(beng): exposing this here is a bit bogus, since it's only used to 191 // determine loading state. It'd be nicer if we could change this to be 192 // bool IsSelectedTabLoading() const; or something like that. We could even 193 // move it to a WindowDelegate subclass. 194 content::WebContents* GetActiveWebContents() const; 195 196 // Retrieves the icon to use in the frame to indicate an OTR window. 197 gfx::ImageSkia GetOTRAvatarIcon() const; 198 199 // Returns true if the Browser object associated with this BrowserView is a 200 // tabbed-type window (i.e. a browser window, not an app or popup). 201 bool IsBrowserTypeNormal() const { 202 return browser_->is_type_tabbed(); 203 } 204 205 // Returns true if the specified point(BrowserView coordinates) is in 206 // in the window caption area of the browser window. 207 bool IsPositionInWindowCaption(const gfx::Point& point); 208 209 // Returns whether the fullscreen bubble is visible or not. 210 virtual bool IsFullscreenBubbleVisible() const OVERRIDE; 211 212 // Invoked from the frame when the full screen state changes. This is only 213 // used on Linux. 214 void FullScreenStateChanged(); 215 216 // See ImmersiveModeController for description. 217 ImmersiveModeController* immersive_mode_controller() { 218 return immersive_mode_controller_.get(); 219 } 220 221 // Restores the focused view. This is also used to set the initial focus 222 // when a new browser window is created. 223 void RestoreFocus(); 224 225 void SetWindowSwitcherButton(views::Button* button); 226 227 views::Button* window_switcher_button() { 228 return window_switcher_button_; 229 } 230 231 // Called from BookmarkBarView/DownloadShelfView during their show/hide 232 // animations. 233 void ToolbarSizeChanged(bool is_animating); 234 235 // If immersive mode is enabled and we're revealing the tab strip and toolbar 236 // then stack it at the top. 237 void MaybeStackImmersiveRevealAtTop(); 238 239#if defined(USE_ASH) 240 // Test support. 241 // Note: This is only needed to be BrowserLauncherItemController instead of 242 // LauncherItemController because of the "favicon_loader" member - to be more 243 // exact that member function is the only one being called. 244 // TODO(skuhne): Remove once per-app is default. 245 BrowserLauncherItemController* launcher_item_controller() const { 246 return launcher_item_controller_.get(); 247 } 248#endif 249 250 BookmarkBarView* bookmark_bar() const { 251 return bookmark_bar_view_.get(); 252 } 253 254 // Overridden from BrowserWindow: 255 virtual void Show() OVERRIDE; 256 virtual void ShowInactive() OVERRIDE; 257 virtual void Hide() OVERRIDE; 258 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; 259 virtual void Close() OVERRIDE; 260 virtual void Activate() OVERRIDE; 261 virtual void Deactivate() OVERRIDE; 262 virtual bool IsActive() const OVERRIDE; 263 virtual void FlashFrame(bool flash) OVERRIDE; 264 virtual bool IsAlwaysOnTop() const OVERRIDE; 265 virtual gfx::NativeWindow GetNativeWindow() OVERRIDE; 266 virtual BrowserWindowTesting* GetBrowserWindowTesting() OVERRIDE; 267 virtual StatusBubble* GetStatusBubble() OVERRIDE; 268 virtual void UpdateTitleBar() OVERRIDE; 269 virtual void BookmarkBarStateChanged( 270 BookmarkBar::AnimateChangeType change_type) OVERRIDE; 271 virtual void UpdateDevTools() OVERRIDE; 272 virtual void UpdateLoadingAnimations(bool should_animate) OVERRIDE; 273 virtual void SetStarredState(bool is_starred) OVERRIDE; 274 virtual void ZoomChangedForActiveTab(bool can_show_bubble) OVERRIDE; 275 virtual gfx::Rect GetRestoredBounds() const OVERRIDE; 276 virtual gfx::Rect GetBounds() const OVERRIDE; 277 virtual bool IsMaximized() const OVERRIDE; 278 virtual bool IsMinimized() const OVERRIDE; 279 virtual void Maximize() OVERRIDE; 280 virtual void Minimize() OVERRIDE; 281 virtual void Restore() OVERRIDE; 282 virtual void EnterFullscreen( 283 const GURL& url, FullscreenExitBubbleType bubble_type) OVERRIDE; 284 virtual void ExitFullscreen() OVERRIDE; 285 virtual void UpdateFullscreenExitBubbleContent( 286 const GURL& url, 287 FullscreenExitBubbleType bubble_type) OVERRIDE; 288 virtual bool ShouldHideUIForFullscreen() const OVERRIDE; 289 virtual bool IsFullscreen() const OVERRIDE; 290#if defined(OS_WIN) 291 virtual void SetMetroSnapMode(bool enable) OVERRIDE; 292 virtual bool IsInMetroSnapMode() const OVERRIDE; 293#endif 294 virtual LocationBar* GetLocationBar() const OVERRIDE; 295 virtual void SetFocusToLocationBar(bool select_all) OVERRIDE; 296 virtual void UpdateReloadStopState(bool is_loading, bool force) OVERRIDE; 297 virtual void UpdateToolbar(content::WebContents* contents, 298 bool should_restore_state) OVERRIDE; 299 virtual void FocusToolbar() OVERRIDE; 300 virtual void FocusAppMenu() OVERRIDE; 301 virtual void FocusBookmarksToolbar() OVERRIDE; 302 virtual void RotatePaneFocus(bool forwards) OVERRIDE; 303 virtual void DestroyBrowser() OVERRIDE; 304 virtual bool IsBookmarkBarVisible() const OVERRIDE; 305 virtual bool IsBookmarkBarAnimating() const OVERRIDE; 306 virtual bool IsTabStripEditable() const OVERRIDE; 307 virtual bool IsToolbarVisible() const OVERRIDE; 308 virtual bool IsPanel() const OVERRIDE; 309 virtual gfx::Rect GetRootWindowResizerRect() const OVERRIDE; 310 virtual void DisableInactiveFrame() OVERRIDE; 311 virtual void ConfirmAddSearchProvider(TemplateURL* template_url, 312 Profile* profile) OVERRIDE; 313 virtual void ToggleBookmarkBar() OVERRIDE; 314 virtual void ShowUpdateChromeDialog() OVERRIDE; 315 virtual void ShowBookmarkBubble(const GURL& url, 316 bool already_bookmarked) OVERRIDE; 317 virtual void ShowBookmarkPrompt() OVERRIDE; 318 virtual void ShowChromeToMobileBubble() OVERRIDE; 319#if defined(ENABLE_ONE_CLICK_SIGNIN) 320 virtual void ShowOneClickSigninBubble( 321 OneClickSigninBubbleType type, 322 const StartSyncCallback& start_sync_callback) OVERRIDE; 323#endif 324 // TODO(beng): Not an override, move somewhere else. 325 void SetDownloadShelfVisible(bool visible); 326 virtual bool IsDownloadShelfVisible() const OVERRIDE; 327 virtual DownloadShelf* GetDownloadShelf() OVERRIDE; 328 virtual void ConfirmBrowserCloseWithPendingDownloads() OVERRIDE; 329 virtual void UserChangedTheme() OVERRIDE; 330 virtual int GetExtraRenderViewHeight() const OVERRIDE; 331 virtual void WebContentsFocused(content::WebContents* contents) OVERRIDE; 332 virtual void ShowWebsiteSettings(Profile* profile, 333 content::WebContents* web_contents, 334 const GURL& url, 335 const content::SSLStatus& ssl, 336 bool show_history) OVERRIDE; 337 virtual void ShowAppMenu() OVERRIDE; 338 virtual bool PreHandleKeyboardEvent( 339 const content::NativeWebKeyboardEvent& event, 340 bool* is_keyboard_shortcut) OVERRIDE; 341 virtual void HandleKeyboardEvent( 342 const content::NativeWebKeyboardEvent& event) OVERRIDE; 343 virtual void ShowCreateChromeAppShortcutsDialog( 344 Profile*, const extensions::Extension* app) OVERRIDE; 345 virtual void Cut() OVERRIDE; 346 virtual void Copy() OVERRIDE; 347 virtual void Paste() OVERRIDE; 348 virtual gfx::Rect GetInstantBounds() OVERRIDE; 349 virtual WindowOpenDisposition GetDispositionForPopupBounds( 350 const gfx::Rect& bounds) OVERRIDE; 351 virtual FindBar* CreateFindBar() OVERRIDE; 352 virtual bool GetConstrainedWindowTopY(int* top_y) OVERRIDE; 353 virtual void ShowAvatarBubble(content::WebContents* web_contents, 354 const gfx::Rect& rect) OVERRIDE; 355 virtual void ShowAvatarBubbleFromAvatarButton() OVERRIDE; 356 virtual void ShowPasswordGenerationBubble( 357 const gfx::Rect& rect, 358 const content::PasswordForm& form, 359 autofill::PasswordGenerator* password_generator) OVERRIDE; 360 361 // Overridden from BrowserWindowTesting: 362 virtual BookmarkBarView* GetBookmarkBarView() const OVERRIDE; 363 virtual LocationBarView* GetLocationBarView() const OVERRIDE; 364 virtual views::View* GetTabContentsContainerView() const OVERRIDE; 365 virtual ToolbarView* GetToolbarView() const OVERRIDE; 366 367 // Overridden from TabStripModelObserver: 368 virtual void TabDetachedAt(content::WebContents* contents, 369 int index) OVERRIDE; 370 virtual void TabDeactivated(content::WebContents* contents) OVERRIDE; 371 virtual void ActiveTabChanged(content::WebContents* old_contents, 372 content::WebContents* new_contents, 373 int index, 374 bool user_gesture) OVERRIDE; 375 virtual void TabStripEmpty() OVERRIDE; 376 377 // Overridden from ui::AcceleratorProvider: 378 virtual bool GetAcceleratorForCommandId(int command_id, 379 ui::Accelerator* accelerator) OVERRIDE; 380 381 // Overridden from views::WidgetDelegate: 382 virtual bool CanResize() const OVERRIDE; 383 virtual bool CanMaximize() const OVERRIDE; 384 virtual bool CanActivate() const OVERRIDE; 385 virtual string16 GetWindowTitle() const OVERRIDE; 386 virtual string16 GetAccessibleWindowTitle() const OVERRIDE; 387 virtual views::View* GetInitiallyFocusedView() OVERRIDE; 388 virtual bool ShouldShowWindowTitle() const OVERRIDE; 389 virtual gfx::ImageSkia GetWindowAppIcon() OVERRIDE; 390 virtual gfx::ImageSkia GetWindowIcon() OVERRIDE; 391 virtual bool ShouldShowWindowIcon() const OVERRIDE; 392 virtual bool ExecuteWindowsCommand(int command_id) OVERRIDE; 393 virtual std::string GetWindowName() const OVERRIDE; 394 virtual void SaveWindowPlacement(const gfx::Rect& bounds, 395 ui::WindowShowState show_state) OVERRIDE; 396 virtual bool GetSavedWindowPlacement( 397 gfx::Rect* bounds, 398 ui::WindowShowState* show_state) const OVERRIDE; 399 virtual views::View* GetContentsView() OVERRIDE; 400 virtual views::ClientView* CreateClientView(views::Widget* widget) OVERRIDE; 401 virtual void OnWindowBeginUserBoundsChange() OVERRIDE; 402 virtual void OnWidgetMove() OVERRIDE; 403 virtual views::Widget* GetWidget() OVERRIDE; 404 virtual const views::Widget* GetWidget() const OVERRIDE; 405 406 // Overridden from views::WidgetObserver: 407 virtual void OnWidgetActivationChanged(views::Widget* widget, 408 bool active) OVERRIDE; 409 410 // Overridden from views::ClientView: 411 virtual bool CanClose() OVERRIDE; 412 virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE; 413 virtual gfx::Size GetMinimumSize() OVERRIDE; 414 415 // InfoBarContainer::Delegate overrides 416 virtual SkColor GetInfoBarSeparatorColor() const OVERRIDE; 417 virtual void InfoBarContainerStateChanged(bool is_animating) OVERRIDE; 418 virtual bool DrawInfoBarArrows(int* x) const OVERRIDE; 419 420 // views::SingleSplitViewListener overrides: 421 virtual bool SplitHandleMoved(views::SingleSplitView* sender) OVERRIDE; 422 423 // gfx::SysColorChangeListener overrides: 424 virtual void OnSysColorChange() OVERRIDE; 425 426 // Returns the resource ID to use for the OTR icon, which depends on 427 // which layout is being shown and whether we are full-screen. 428 int GetOTRIconResourceID() const; 429 430 // Overridden from views::View: 431 virtual std::string GetClassName() const OVERRIDE; 432 virtual void Layout() OVERRIDE; 433 virtual void PaintChildren(gfx::Canvas* canvas) OVERRIDE; 434 virtual void ViewHierarchyChanged(bool is_add, 435 views::View* parent, 436 views::View* child) OVERRIDE; 437 virtual void ChildPreferredSizeChanged(View* child) OVERRIDE; 438 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; 439 440 protected: 441 // Appends to |toolbars| a pointer to each AccessiblePaneView that 442 // can be traversed using F6, in the order they should be traversed. 443 // Abstracted here so that it can be extended for Chrome OS. 444 virtual void GetAccessiblePanes( 445 std::vector<views::AccessiblePaneView*>* panes); 446 447 int last_focused_view_storage_id() const { 448 return last_focused_view_storage_id_; 449 } 450 451 // Factory Method. 452 // Returns a new LayoutManager for this browser view. A subclass may 453 // override to implement different layout policy. 454 virtual views::LayoutManager* CreateLayoutManager() const; 455 456 // Browser window related initializations. 457 virtual void Init(); 458 459 // Callback for the loading animation(s) associated with this view. 460 virtual void LoadingAnimationCallback(); 461 462 // LoadCompleteListener::Delegate implementation. Creates and initializes the 463 // |jumplist_| after the first page load. 464 virtual void OnLoadCompleted() OVERRIDE; 465 466 private: 467 friend class BrowserViewLayout; 468 FRIEND_TEST_ALL_PREFIXES(BrowserViewsAccessibilityTest, 469 TestAboutChromeViewAccObj); 470 471 enum FullscreenType { 472 FOR_DESKTOP, 473 FOR_METRO 474 }; 475 476 // We store this on linux because we must call ProcessFullscreen() 477 // asynchronously from FullScreenStateChanged() instead of directly from 478 // EnterFullscreen(). 479 struct PendingFullscreenRequest { 480 PendingFullscreenRequest() 481 : pending(false), 482 bubble_type(FEB_TYPE_NONE) {} 483 484 bool pending; 485 GURL url; 486 FullscreenExitBubbleType bubble_type; 487 }; 488 489 // Returns the BrowserViewLayout. 490 BrowserViewLayout* GetBrowserViewLayout() const; 491 492 // Layout the Status Bubble. 493 void LayoutStatusBubble(); 494 495 // Prepare to show the Bookmark Bar for the specified WebContents. 496 // Returns true if the Bookmark Bar can be shown (i.e. it's supported for this 497 // Browser type) and there should be a subsequent re-layout to show it. 498 // |contents| can be NULL. 499 bool MaybeShowBookmarkBar(content::WebContents* contents); 500 501 // Prepare to show an Info Bar for the specified WebContents. Returns 502 // true if there is an Info Bar to show and one is supported for this Browser 503 // type, and there should be a subsequent re-layout to show it. 504 // |contents| can be NULL. 505 bool MaybeShowInfoBar(content::WebContents* contents); 506 507 // Updates devtools window for given contents. This method will show docked 508 // devtools window for inspected |web_contents| that has docked devtools 509 // and hide it for NULL or not inspected |web_contents|. It will also make 510 // sure devtools window size and position are restored for given tab. 511 void UpdateDevToolsForContents(content::WebContents* web_contents); 512 513 // Shows docked devtools. 514 void ShowDevToolsContainer(); 515 516 // Hides docked devtools. 517 void HideDevToolsContainer(); 518 519 // Reads split position from the current tab's devtools window and applies 520 // it to the devtools split. 521 void UpdateDevToolsSplitPosition(); 522 523 // Updates various optional child Views, e.g. Bookmarks Bar, Info Bar or the 524 // Download Shelf in response to a change notification from the specified 525 // |contents|. |contents| can be NULL. In this case, all optional UI will be 526 // removed. 527 void UpdateUIForContents(content::WebContents* contents); 528 529 // Updates an optional child View, e.g. Bookmarks Bar, Info Bar, Download 530 // Shelf. If |*old_view| differs from new_view, the old_view is removed and 531 // the new_view is added. This is intended to be used when swapping in/out 532 // child views that are referenced via a field. 533 // Returns true if anything was changed, and a re-Layout is now required. 534 bool UpdateChildViewAndLayout(views::View* new_view, views::View** old_view); 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 // Copy the accelerator table from the app resources into something we can 551 // use. 552 void LoadAccelerators(); 553 554 // Retrieves the command id for the specified Windows app command. 555 int GetCommandIDForAppCommandID(int app_command_id) const; 556 557 // Initialize the hung plugin detector. 558 void InitHangMonitor(); 559 560 // Possibly records a user metrics action corresponding to the passed-in 561 // accelerator. Only implemented for Chrome OS, where we're interested in 562 // learning about how frequently the top-row keys are used. 563 void UpdateAcceleratorMetrics(const ui::Accelerator& accelerator, 564 int command_id); 565 566 // Exposes resize corner size to BrowserViewLayout. 567 gfx::Size GetResizeCornerSize() const; 568 569 // Create an icon for this window in the launcher (currently only for Ash). 570 void CreateLauncherIcon(); 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 // |windows_msg_id| is temporary until Win Aura is the default on Windows, 576 // since until then the omnibox doesn't use Views::Textfield. 577 void DoCutCopyPaste(void (content::RenderWidgetHost::*method)(), 578#if defined(OS_WIN) 579 int windows_msg_id, 580#endif 581 int command_id); 582 583 // Calls |method| which is either RenderWidgetHost::Cut, ::Copy, or ::Paste on 584 // the given WebContents, returning true if it consumed the event. 585 bool DoCutCopyPasteForWebContents( 586 content::WebContents* contents, 587 void (content::RenderWidgetHost::*method)()); 588 589 // Shows the next app-modal dialog box, if there is one to be shown, or moves 590 // an existing showing one to the front. 591 void ActivateAppModalDialog() const; 592 593 // Last focused view that issued a tab traversal. 594 int last_focused_view_storage_id_; 595 596 // The BrowserFrame that hosts this view. 597 BrowserFrame* frame_; 598 599 // The Browser object we are associated with. 600 scoped_ptr<Browser> browser_; 601 602 // BrowserView layout (LTR one is pictured here). 603 // 604 // -------------------------------------------------------------------- 605 // | TopContainerView (top_container_) | 606 // | -------------------------------------------------------------- | 607 // | | Tabs (tabstrip_) | | 608 // | |------------------------------------------------------------| | 609 // | | Navigation buttons, address bar, menu (toolbar_) | | 610 // | -------------------------------------------------------------- | 611 // |------------------------------------------------------------------| 612 // | All infobars (infobar_container_) [1] | 613 // |------------------------------------------------------------------| 614 // | Bookmarks (bookmark_bar_view_) [1] | 615 // |------------------------------------------------------------------| 616 // | Debugger splitter (contents_split_) | 617 // | -------------------------------------------------------------- | 618 // | | Page content (contents_) | | 619 // | | -------------------------------------------------------- | | 620 // | | | contents_container_ and/or | | | 621 // | | | overlay_controller_->overlay_container_ | | | 622 // | | | | | | 623 // | | | | | | 624 // | | -------------------------------------------------------- | | 625 // | -------------------------------------------------------------- | 626 // | -------------------------------------------------------------- | 627 // | | Debugger (devtools_container_) | | 628 // | | | | 629 // | -------------------------------------------------------------- | 630 // |------------------------------------------------------------------| 631 // | Active downloads (download_shelf_) | 632 // -------------------------------------------------------------------- 633 // 634 // [1] The bookmark bar and info bar are swapped when on the new tab page. 635 // Additionally contents_ is positioned on top of the bookmark bar when 636 // the bookmark bar is detached. This is done to allow the 637 // overlay_controller_->overlay_container_ to appear over the bookmark 638 // bar. 639 640 // The view that manages the tab strip, toolbar, and sometimes the bookmark 641 // bar. Stacked in the top of the view hiearachy so it can be used to 642 // slide out the top views in immersive fullscreen. 643 TopContainerView* top_container_; 644 645 // Tool/Info bars that we are currently showing. Used for layout. 646 // active_bookmark_bar_ is either NULL, if the bookmark bar isn't showing, 647 // or is bookmark_bar_view_ if the bookmark bar is showing. 648 views::View* active_bookmark_bar_; 649 650 // The TabStrip. 651 TabStrip* tabstrip_; 652 653 // The Toolbar containing the navigation buttons, menus and the address bar. 654 ToolbarView* toolbar_; 655 656 // This button sits next to the tabs on the right hand side and it is used 657 // only in windows metro metro mode to allow the user to flip among browser 658 // windows. 659 views::Button* window_switcher_button_; 660 661 // The Bookmark Bar View for this window. Lazily created. 662 scoped_ptr<BookmarkBarView> bookmark_bar_view_; 663 664 // The download shelf view (view at the bottom of the page). 665 scoped_ptr<DownloadShelfView> download_shelf_; 666 667 // The InfoBarContainerView that contains InfoBars for the current tab. 668 InfoBarContainerView* infobar_container_; 669 670 // The view that contains the selected WebContents. 671 views::WebView* contents_container_; 672 673 // The view that contains devtools window for the selected WebContents. 674 views::WebView* devtools_container_; 675 676 // The view managing both the contents_container_ and 677 // overlay_controller_->overlay_container_. 678 ContentsContainer* contents_; 679 680 // Split view containing the contents container and devtools container. 681 views::SingleSplitView* contents_split_; 682 683 // Side to dock devtools to. 684 DevToolsDockSide devtools_dock_side_; 685 686 // Docked devtools window instance. NULL when current tab is not inspected 687 // or is inspected with undocked version of DevToolsWindow. 688 DevToolsWindow* devtools_window_; 689 690 // Tracks and stores the last focused view which is not the 691 // devtools_container_ or any of its children. Used to restore focus once 692 // the devtools_container_ is hidden. 693 scoped_ptr<views::ExternalFocusTracker> devtools_focus_tracker_; 694 695 // The Status information bubble that appears at the bottom of the window. 696 scoped_ptr<StatusBubbleViews> status_bubble_; 697 698 // A mapping between accelerators and commands. 699 std::map<ui::Accelerator, int> accelerator_table_; 700 701 // True if we have already been initialized. 702 bool initialized_; 703 704 // True if we should ignore requests to layout. This is set while toggling 705 // fullscreen mode on and off to reduce jankiness. 706 bool ignore_layout_; 707 708 scoped_ptr<FullscreenExitBubbleViews> fullscreen_bubble_; 709 710#if defined(OS_WIN) && !defined(USE_AURA) 711 // This object is used to perform periodic actions in a worker 712 // thread. It is currently used to monitor hung plugin windows. 713 WorkerThreadTicker ticker_; 714 715 // This object is initialized with the frame window HWND. This 716 // object is also passed as a tick handler with the ticker_ object. 717 // It is used to periodically monitor for hung plugin windows 718 HungWindowDetector hung_window_detector_; 719 720 // This object is invoked by hung_window_detector_ when it detects a hung 721 // plugin window. 722 HungPluginAction hung_plugin_action_; 723 724 // Helper class to listen for completion of first page load. 725 scoped_ptr<LoadCompleteListener> load_complete_listener_; 726 727 // The custom JumpList for Windows 7. 728 scoped_refptr<JumpList> jumplist_; 729#endif 730 731#if defined(USE_ASH) 732 // Needs to be BrowserLauncerItemController for 733 // "BrowserActivationStateChanged" and "favicon_loader". 734 // TODO(skuhne): Remove once per-app is default. 735 scoped_ptr<BrowserLauncherItemController> launcher_item_controller_; 736#endif 737 738 // The timer used to update frames for the Loading Animation. 739 base::RepeatingTimer<BrowserView> loading_animation_timer_; 740 741 UnhandledKeyboardEventHandler unhandled_keyboard_event_handler_; 742 743 // Used to measure the loading spinner animation rate. 744 base::TimeTicks last_animation_time_; 745 746 // If this flag is set then SetFocusToLocationBar() will set focus to the 747 // location bar even if the browser window is not active. 748 bool force_location_bar_focus_; 749 750 PendingFullscreenRequest fullscreen_request_; 751 752 scoped_ptr<ImmersiveModeController> immersive_mode_controller_; 753 754 gfx::ScopedSysColorChangeListener color_change_listener_; 755 756 scoped_ptr<InstantOverlayControllerViews> overlay_controller_; 757 758 mutable base::WeakPtrFactory<BrowserView> activate_modal_dialog_factory_; 759 760 DISALLOW_COPY_AND_ASSIGN(BrowserView); 761}; 762 763#endif // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_VIEW_H_ 764