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