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