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