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