| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_VIEW_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_VIEW_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/timer.h" | 15 #include "base/timer.h" |
| 16 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 17 #include "chrome/browser/infobars/infobar_container.h" | 17 #include "chrome/browser/infobars/infobar_container.h" |
| 18 #include "chrome/browser/tabs/tab_strip_model_observer.h" | 18 #include "chrome/browser/tabs/tab_strip_model_observer.h" |
| 19 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
| 20 #include "chrome/browser/ui/browser_window.h" | 20 #include "chrome/browser/ui/browser_window.h" |
| 21 #include "chrome/browser/ui/views/frame/browser_frame.h" | 21 #include "chrome/browser/ui/views/frame/browser_frame.h" |
| 22 #include "chrome/browser/ui/views/tab_contents/tab_contents_container.h" | 22 #include "chrome/browser/ui/views/tab_contents/tab_contents_container.h" |
| 23 #include "chrome/browser/ui/views/tabs/abstract_tab_strip_view.h" | 23 #include "chrome/browser/ui/views/tabs/abstract_tab_strip_view.h" |
| 24 #include "chrome/browser/ui/views/unhandled_keyboard_event_handler.h" | 24 #include "chrome/browser/ui/views/unhandled_keyboard_event_handler.h" |
| 25 #include "content/public/browser/notification_registrar.h" | |
| 26 #include "ui/base/models/simple_menu_model.h" | 25 #include "ui/base/models/simple_menu_model.h" |
| 27 #include "ui/gfx/native_widget_types.h" | 26 #include "ui/gfx/native_widget_types.h" |
| 28 #include "ui/views/controls/single_split_view_listener.h" | 27 #include "ui/views/controls/single_split_view_listener.h" |
| 29 #include "ui/views/widget/widget_delegate.h" | 28 #include "ui/views/widget/widget_delegate.h" |
| 30 #include "ui/views/window/client_view.h" | 29 #include "ui/views/window/client_view.h" |
| 31 | 30 |
| 32 #if defined(OS_WIN) | 31 #if defined(OS_WIN) |
| 33 #include "chrome/browser/hang_monitor/hung_plugin_action.h" | 32 #include "chrome/browser/hang_monitor/hung_plugin_action.h" |
| 34 #include "chrome/browser/hang_monitor/hung_window_detector.h" | 33 #include "chrome/browser/hang_monitor/hung_window_detector.h" |
| 35 #include "ui/views/controls/menu/native_menu_win.h" | 34 #include "ui/views/controls/menu/native_menu_win.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 } | 73 } |
| 75 | 74 |
| 76 /////////////////////////////////////////////////////////////////////////////// | 75 /////////////////////////////////////////////////////////////////////////////// |
| 77 // BrowserView | 76 // BrowserView |
| 78 // | 77 // |
| 79 // A ClientView subclass that provides the contents of a browser window, | 78 // A ClientView subclass that provides the contents of a browser window, |
| 80 // including the TabStrip, toolbars, download shelves, the content area etc. | 79 // including the TabStrip, toolbars, download shelves, the content area etc. |
| 81 // | 80 // |
| 82 class BrowserView : public BrowserWindow, | 81 class BrowserView : public BrowserWindow, |
| 83 public BrowserWindowTesting, | 82 public BrowserWindowTesting, |
| 84 public content::NotificationObserver, | |
| 85 public TabStripModelObserver, | 83 public TabStripModelObserver, |
| 86 public ui::SimpleMenuModel::Delegate, | 84 public ui::SimpleMenuModel::Delegate, |
| 87 public views::WidgetDelegate, | 85 public views::WidgetDelegate, |
| 88 public views::Widget::Observer, | 86 public views::Widget::Observer, |
| 89 public views::ClientView, | 87 public views::ClientView, |
| 90 public InfoBarContainer::Delegate, | 88 public InfoBarContainer::Delegate, |
| 91 public views::SingleSplitViewListener { | 89 public views::SingleSplitViewListener { |
| 92 public: | 90 public: |
| 93 // The browser view's class name. | 91 // The browser view's class name. |
| 94 static const char kViewClassName[]; | 92 static const char kViewClassName[]; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 // Returns the preferred height of the TabStrip. Used to position the OTR | 133 // Returns the preferred height of the TabStrip. Used to position the OTR |
| 136 // avatar icon. | 134 // avatar icon. |
| 137 virtual int GetTabStripHeight() const; | 135 virtual int GetTabStripHeight() const; |
| 138 | 136 |
| 139 // Takes some view's origin (relative to this BrowserView) and offsets it such | 137 // Takes some view's origin (relative to this BrowserView) and offsets it such |
| 140 // that it can be used as the source origin for seamlessly tiling the toolbar | 138 // that it can be used as the source origin for seamlessly tiling the toolbar |
| 141 // background image over that view. | 139 // background image over that view. |
| 142 gfx::Point OffsetPointForToolbarBackgroundImage( | 140 gfx::Point OffsetPointForToolbarBackgroundImage( |
| 143 const gfx::Point& point) const; | 141 const gfx::Point& point) const; |
| 144 | 142 |
| 145 // Returns the width of the currently displayed sidebar or 0. | |
| 146 int GetSidebarWidth() const; | |
| 147 | |
| 148 // Accessor for the TabStrip. | 143 // Accessor for the TabStrip. |
| 149 AbstractTabStripView* tabstrip() const { return tabstrip_; } | 144 AbstractTabStripView* tabstrip() const { return tabstrip_; } |
| 150 | 145 |
| 151 // Accessor for the Toolbar. | 146 // Accessor for the Toolbar. |
| 152 ToolbarView* toolbar() const { return toolbar_; } | 147 ToolbarView* toolbar() const { return toolbar_; } |
| 153 | 148 |
| 154 // Returns true if various window components are visible. | 149 // Returns true if various window components are visible. |
| 155 virtual bool IsTabStripVisible() const; | 150 virtual bool IsTabStripVisible() const; |
| 156 | 151 |
| 157 // Returns true if the profile associated with this Browser window is | 152 // Returns true if the profile associated with this Browser window is |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 virtual void ShowKeyboardOverlay(gfx::NativeWindow owning_window) OVERRIDE; | 336 virtual void ShowKeyboardOverlay(gfx::NativeWindow owning_window) OVERRIDE; |
| 342 #endif | 337 #endif |
| 343 virtual void ShowAvatarBubble(content::WebContents* web_contents, | 338 virtual void ShowAvatarBubble(content::WebContents* web_contents, |
| 344 const gfx::Rect& rect) OVERRIDE; | 339 const gfx::Rect& rect) OVERRIDE; |
| 345 virtual void ShowAvatarBubbleFromAvatarButton() OVERRIDE; | 340 virtual void ShowAvatarBubbleFromAvatarButton() OVERRIDE; |
| 346 | 341 |
| 347 // Overridden from BrowserWindowTesting: | 342 // Overridden from BrowserWindowTesting: |
| 348 virtual BookmarkBarView* GetBookmarkBarView() const OVERRIDE; | 343 virtual BookmarkBarView* GetBookmarkBarView() const OVERRIDE; |
| 349 virtual LocationBarView* GetLocationBarView() const OVERRIDE; | 344 virtual LocationBarView* GetLocationBarView() const OVERRIDE; |
| 350 virtual views::View* GetTabContentsContainerView() const OVERRIDE; | 345 virtual views::View* GetTabContentsContainerView() const OVERRIDE; |
| 351 virtual views::View* GetSidebarContainerView() const OVERRIDE; | |
| 352 virtual ToolbarView* GetToolbarView() const OVERRIDE; | 346 virtual ToolbarView* GetToolbarView() const OVERRIDE; |
| 353 | 347 |
| 354 // Overridden from content::NotificationObserver: | |
| 355 virtual void Observe(int type, | |
| 356 const content::NotificationSource& source, | |
| 357 const content::NotificationDetails& details) OVERRIDE; | |
| 358 | |
| 359 // Overridden from TabStripModelObserver: | 348 // Overridden from TabStripModelObserver: |
| 360 virtual void TabDetachedAt(TabContentsWrapper* contents, int index) OVERRIDE; | 349 virtual void TabDetachedAt(TabContentsWrapper* contents, int index) OVERRIDE; |
| 361 virtual void TabDeactivated(TabContentsWrapper* contents) OVERRIDE; | 350 virtual void TabDeactivated(TabContentsWrapper* contents) OVERRIDE; |
| 362 virtual void ActiveTabChanged(TabContentsWrapper* old_contents, | 351 virtual void ActiveTabChanged(TabContentsWrapper* old_contents, |
| 363 TabContentsWrapper* new_contents, | 352 TabContentsWrapper* new_contents, |
| 364 int index, | 353 int index, |
| 365 bool user_gesture) OVERRIDE; | 354 bool user_gesture) OVERRIDE; |
| 366 virtual void TabReplacedAt(TabStripModel* tab_strip_model, | 355 virtual void TabReplacedAt(TabStripModel* tab_strip_model, |
| 367 TabContentsWrapper* old_contents, | 356 TabContentsWrapper* old_contents, |
| 368 TabContentsWrapper* new_contents, | 357 TabContentsWrapper* new_contents, |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 // Browser type) and there should be a subsequent re-layout to show it. | 483 // Browser type) and there should be a subsequent re-layout to show it. |
| 495 // |contents| can be NULL. | 484 // |contents| can be NULL. |
| 496 bool MaybeShowBookmarkBar(TabContentsWrapper* contents); | 485 bool MaybeShowBookmarkBar(TabContentsWrapper* contents); |
| 497 | 486 |
| 498 // Prepare to show an Info Bar for the specified TabContents. Returns true | 487 // Prepare to show an Info Bar for the specified TabContents. Returns true |
| 499 // if there is an Info Bar to show and one is supported for this Browser | 488 // if there is an Info Bar to show and one is supported for this Browser |
| 500 // type, and there should be a subsequent re-layout to show it. | 489 // type, and there should be a subsequent re-layout to show it. |
| 501 // |contents| can be NULL. | 490 // |contents| can be NULL. |
| 502 bool MaybeShowInfoBar(TabContentsWrapper* contents); | 491 bool MaybeShowInfoBar(TabContentsWrapper* contents); |
| 503 | 492 |
| 504 // Updates sidebar UI according to the current tab and sidebar state. | |
| 505 void UpdateSidebar(); | |
| 506 // Displays active sidebar linked to the |tab_contents| or hides sidebar UI, | |
| 507 // if there's no such sidebar. | |
| 508 void UpdateSidebarForContents(TabContentsWrapper* tab_contents); | |
| 509 | |
| 510 // Shows docked devtools. | 493 // Shows docked devtools. |
| 511 void ShowDevToolsContainer(); | 494 void ShowDevToolsContainer(); |
| 512 | 495 |
| 513 // Hides docked devtools. | 496 // Hides docked devtools. |
| 514 void HideDevToolsContainer(); | 497 void HideDevToolsContainer(); |
| 515 | 498 |
| 516 // Updated devtools window for given contents. | 499 // Updated devtools window for given contents. |
| 517 void UpdateDevToolsForContents(TabContentsWrapper* tab_contents); | 500 void UpdateDevToolsForContents(TabContentsWrapper* tab_contents); |
| 518 | 501 |
| 519 // Updates various optional child Views, e.g. Bookmarks Bar, Info Bar or the | 502 // Updates various optional child Views, e.g. Bookmarks Bar, Info Bar or the |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 // | 576 // |
| 594 // ---------------------------------------------------------------- | 577 // ---------------------------------------------------------------- |
| 595 // | Tabs (1) | | 578 // | Tabs (1) | |
| 596 // |--------------------------------------------------------------| | 579 // |--------------------------------------------------------------| |
| 597 // | Navigation buttons, menus and the address bar (toolbar_) | | 580 // | Navigation buttons, menus and the address bar (toolbar_) | |
| 598 // |--------------------------------------------------------------| | 581 // |--------------------------------------------------------------| |
| 599 // | All infobars (infobar_container_) * | | 582 // | All infobars (infobar_container_) * | |
| 600 // |--------------------------------------------------------------| | 583 // |--------------------------------------------------------------| |
| 601 // | Bookmarks (bookmark_bar_view_) * | | 584 // | Bookmarks (bookmark_bar_view_) * | |
| 602 // |--------------------------------------------------------------| | 585 // |--------------------------------------------------------------| |
| 603 // |Page content (contents_) || | | 586 // |Page content (contents_) || |
| 604 // |--------------------------------------|| Sidebar content | | 587 // |-------------------------------------------------------------|| |
| 605 // || contents_container_ and/or ||| (sidebar_container_) | | 588 // || contents_container_ and/or ||| |
| 606 // || preview_container_ ||| | | 589 // || preview_container_ ||| |
| 607 // || |(2) | | 590 // || ||| |
| 608 // || ||| | | 591 // || ||| |
| 609 // || ||| | | 592 // || ||| |
| 610 // || ||| | | 593 // || ||| |
| 611 // || ||| | | 594 // || ||| |
| 612 // |--------------------------------------|| | | 595 // |-------------------------------------------------------------|| |
| 613 // |==(3)=========================================================| | 596 // |==(2)=========================================================| |
| 614 // | | | 597 // | | |
| 615 // | | | 598 // | | |
| 616 // | Debugger (devtools_container_) | | 599 // | Debugger (devtools_container_) | |
| 617 // | | | 600 // | | |
| 618 // | | | 601 // | | |
| 619 // |--------------------------------------------------------------| | 602 // |--------------------------------------------------------------| |
| 620 // | Active downloads (download_shelf_) | | 603 // | Active downloads (download_shelf_) | |
| 621 // ---------------------------------------------------------------- | 604 // ---------------------------------------------------------------- |
| 622 // | 605 // |
| 623 // (1) - tabstrip_, default position | 606 // (1) - tabstrip_, default position |
| 624 // (2) - sidebar_split_ | 607 // (2) - contents_split_ |
| 625 // (3) - contents_split_ | |
| 626 // | 608 // |
| 627 // * - The bookmark bar and info bar are swapped when on the new tab page. | 609 // * - The bookmark bar and info bar are swapped when on the new tab page. |
| 628 // Additionally contents_ is positioned on top of the bookmark bar when | 610 // Additionally contents_ is positioned on top of the bookmark bar when |
| 629 // the bookmark bar is detached. This is done to allow the | 611 // the bookmark bar is detached. This is done to allow the |
| 630 // preview_container_ to appear over the bookmark bar. | 612 // preview_container_ to appear over the bookmark bar. |
| 631 | 613 |
| 632 // Tool/Info bars that we are currently showing. Used for layout. | 614 // Tool/Info bars that we are currently showing. Used for layout. |
| 633 // active_bookmark_bar_ is either NULL, if the bookmark bar isn't showing, | 615 // active_bookmark_bar_ is either NULL, if the bookmark bar isn't showing, |
| 634 // or is bookmark_bar_view_ if the bookmark bar is showing. | 616 // or is bookmark_bar_view_ if the bookmark bar is showing. |
| 635 views::View* active_bookmark_bar_; | 617 views::View* active_bookmark_bar_; |
| 636 | 618 |
| 637 // The TabStrip. | 619 // The TabStrip. |
| 638 AbstractTabStripView* tabstrip_; | 620 AbstractTabStripView* tabstrip_; |
| 639 | 621 |
| 640 // The Toolbar containing the navigation buttons, menus and the address bar. | 622 // The Toolbar containing the navigation buttons, menus and the address bar. |
| 641 ToolbarView* toolbar_; | 623 ToolbarView* toolbar_; |
| 642 | 624 |
| 643 // The Bookmark Bar View for this window. Lazily created. | 625 // The Bookmark Bar View for this window. Lazily created. |
| 644 scoped_ptr<BookmarkBarView> bookmark_bar_view_; | 626 scoped_ptr<BookmarkBarView> bookmark_bar_view_; |
| 645 | 627 |
| 646 #if !defined(OS_CHROMEOS) || defined(USE_AURA) | 628 #if !defined(OS_CHROMEOS) || defined(USE_AURA) |
| 647 // The download shelf view (view at the bottom of the page). ChromiumOS | 629 // The download shelf view (view at the bottom of the page). ChromiumOS |
| 648 // uses ActiveDownloadsUI instead. | 630 // uses ActiveDownloadsUI instead. |
| 649 scoped_ptr<DownloadShelfView> download_shelf_; | 631 scoped_ptr<DownloadShelfView> download_shelf_; |
| 650 #endif | 632 #endif |
| 651 | 633 |
| 652 // The InfoBarContainerView that contains InfoBars for the current tab. | 634 // The InfoBarContainerView that contains InfoBars for the current tab. |
| 653 InfoBarContainerView* infobar_container_; | 635 InfoBarContainerView* infobar_container_; |
| 654 | 636 |
| 655 // The view that contains sidebar for the current tab. | |
| 656 TabContentsContainer* sidebar_container_; | |
| 657 | |
| 658 // Split view containing the contents container and sidebar container. | |
| 659 views::SingleSplitView* sidebar_split_; | |
| 660 | |
| 661 // The view that contains the selected TabContents. | 637 // The view that contains the selected TabContents. |
| 662 TabContentsContainer* contents_container_; | 638 TabContentsContainer* contents_container_; |
| 663 | 639 |
| 664 // The view that contains devtools window for the selected TabContents. | 640 // The view that contains devtools window for the selected TabContents. |
| 665 TabContentsContainer* devtools_container_; | 641 TabContentsContainer* devtools_container_; |
| 666 | 642 |
| 667 // The view that contains instant's TabContents. | 643 // The view that contains instant's TabContents. |
| 668 TabContentsContainer* preview_container_; | 644 TabContentsContainer* preview_container_; |
| 669 | 645 |
| 670 // The view managing both the contents_container_ and preview_container_. | 646 // The view managing both the contents_container_ and preview_container_. |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 726 | 702 |
| 727 #if defined(USE_AURA) | 703 #if defined(USE_AURA) |
| 728 scoped_ptr<LauncherIconUpdater> icon_updater_; | 704 scoped_ptr<LauncherIconUpdater> icon_updater_; |
| 729 #endif | 705 #endif |
| 730 | 706 |
| 731 // The timer used to update frames for the Loading Animation. | 707 // The timer used to update frames for the Loading Animation. |
| 732 base::RepeatingTimer<BrowserView> loading_animation_timer_; | 708 base::RepeatingTimer<BrowserView> loading_animation_timer_; |
| 733 | 709 |
| 734 UnhandledKeyboardEventHandler unhandled_keyboard_event_handler_; | 710 UnhandledKeyboardEventHandler unhandled_keyboard_event_handler_; |
| 735 | 711 |
| 736 content::NotificationRegistrar registrar_; | |
| 737 | |
| 738 // Used to measure the loading spinner animation rate. | 712 // Used to measure the loading spinner animation rate. |
| 739 base::TimeTicks last_animation_time_; | 713 base::TimeTicks last_animation_time_; |
| 740 | 714 |
| 741 // If this flag is set then SetFocusToLocationBar() will set focus to the | 715 // If this flag is set then SetFocusToLocationBar() will set focus to the |
| 742 // location bar even if the browser window is not active. | 716 // location bar even if the browser window is not active. |
| 743 bool force_location_bar_focus_; | 717 bool force_location_bar_focus_; |
| 744 | 718 |
| 745 PendingFullscreenRequest fullscreen_request_; | 719 PendingFullscreenRequest fullscreen_request_; |
| 746 | 720 |
| 747 DISALLOW_COPY_AND_ASSIGN(BrowserView); | 721 DISALLOW_COPY_AND_ASSIGN(BrowserView); |
| 748 }; | 722 }; |
| 749 | 723 |
| 750 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_VIEW_H_ | 724 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_VIEW_H_ |
| OLD | NEW |