| 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/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/timer.h" | 14 #include "base/timer.h" |
| 15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 16 #include "chrome/browser/tabs/tab_strip_model_observer.h" | 16 #include "chrome/browser/tabs/tab_strip_model_observer.h" |
| 17 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
| 18 #include "chrome/browser/ui/browser_window.h" | 18 #include "chrome/browser/ui/browser_window.h" |
| 19 #include "chrome/browser/ui/views/compact_nav/compact_location_bar_view_host.h" |
| 19 #include "chrome/browser/ui/views/frame/browser_bubble_host.h" | 20 #include "chrome/browser/ui/views/frame/browser_bubble_host.h" |
| 20 #include "chrome/browser/ui/views/frame/browser_frame.h" | 21 #include "chrome/browser/ui/views/frame/browser_frame.h" |
| 21 #include "chrome/browser/ui/views/infobars/infobar_container.h" | 22 #include "chrome/browser/ui/views/infobars/infobar_container.h" |
| 22 #include "chrome/browser/ui/views/tab_contents/tab_contents_container.h" | 23 #include "chrome/browser/ui/views/tab_contents/tab_contents_container.h" |
| 23 #include "chrome/browser/ui/views/tabs/abstract_tab_strip_view.h" | 24 #include "chrome/browser/ui/views/tabs/abstract_tab_strip_view.h" |
| 24 #include "chrome/browser/ui/views/unhandled_keyboard_event_handler.h" | 25 #include "chrome/browser/ui/views/unhandled_keyboard_event_handler.h" |
| 25 #include "content/common/notification_registrar.h" | 26 #include "content/common/notification_registrar.h" |
| 26 #include "ui/base/models/simple_menu_model.h" | 27 #include "ui/base/models/simple_menu_model.h" |
| 27 #include "ui/gfx/native_widget_types.h" | 28 #include "ui/gfx/native_widget_types.h" |
| 28 #include "views/controls/single_split_view.h" | 29 #include "views/controls/single_split_view.h" |
| 29 #include "views/window/client_view.h" | 30 #include "views/window/client_view.h" |
| 30 #include "views/window/window_delegate.h" | 31 #include "views/window/window_delegate.h" |
| 31 | 32 |
| 32 #if defined(OS_WIN) | 33 #if defined(OS_WIN) |
| 33 #include "chrome/browser/hang_monitor/hung_plugin_action.h" | 34 #include "chrome/browser/hang_monitor/hung_plugin_action.h" |
| 34 #include "chrome/browser/hang_monitor/hung_window_detector.h" | 35 #include "chrome/browser/hang_monitor/hung_window_detector.h" |
| 35 #include "views/controls/menu/native_menu_win.h" | 36 #include "views/controls/menu/native_menu_win.h" |
| 36 #endif | 37 #endif |
| 37 | 38 |
| 38 // NOTE: For more information about the objects and files in this directory, | 39 // NOTE: For more information about the objects and files in this directory, |
| 39 // view: http://dev.chromium.org/developers/design-documents/browser-window | 40 // view: http://dev.chromium.org/developers/design-documents/browser-window |
| 40 | 41 |
| 41 class AccessiblePaneView; | 42 class AccessiblePaneView; |
| 42 class BookmarkBarView; | 43 class BookmarkBarView; |
| 43 class Browser; | 44 class Browser; |
| 44 class BrowserBubble; | 45 class BrowserBubble; |
| 45 class BrowserViewLayout; | 46 class BrowserViewLayout; |
| 46 class ContentsContainer; | 47 class ContentsContainer; |
| 48 class CompactLocationBar; |
| 49 class CompactNavigationBar; |
| 50 class CompactOptionsBar; |
| 47 class DownloadShelfView; | 51 class DownloadShelfView; |
| 48 class EncodingMenuModel; | 52 class EncodingMenuModel; |
| 49 class FullscreenExitBubble; | 53 class FullscreenExitBubble; |
| 50 class HtmlDialogUIDelegate; | 54 class HtmlDialogUIDelegate; |
| 51 class InfoBarContainerView; | 55 class InfoBarContainerView; |
| 52 class LocationBarView; | 56 class LocationBarView; |
| 53 class SideTabStrip; | 57 class SideTabStrip; |
| 54 class StatusBubbleViews; | 58 class StatusBubbleViews; |
| 55 class TabContentsContainer; | 59 class TabContentsContainer; |
| 56 class TabStripModel; | 60 class TabStripModel; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 // instance of this object, typically) for a given native window, or NULL if | 102 // instance of this object, typically) for a given native window, or NULL if |
| 99 // there is no such association. | 103 // there is no such association. |
| 100 static BrowserView* GetBrowserViewForNativeWindow(gfx::NativeWindow window); | 104 static BrowserView* GetBrowserViewForNativeWindow(gfx::NativeWindow window); |
| 101 | 105 |
| 102 // Returns a Browser instance of this view. | 106 // Returns a Browser instance of this view. |
| 103 Browser* browser() const { return browser_.get(); } | 107 Browser* browser() const { return browser_.get(); } |
| 104 | 108 |
| 105 // Returns the apparent bounds of the toolbar, in BrowserView coordinates. | 109 // Returns the apparent bounds of the toolbar, in BrowserView coordinates. |
| 106 // These differ from |toolbar_.bounds()| in that they match where the toolbar | 110 // These differ from |toolbar_.bounds()| in that they match where the toolbar |
| 107 // background image is drawn -- slightly outside the "true" bounds | 111 // background image is drawn -- slightly outside the "true" bounds |
| 108 // horizontally, and, when using vertical tabs, behind the tab column. | 112 // horizontally, and, when using vertical tabs, behind the tab column. Note |
| 113 // that this returns the bounds for the toolbar area, which could just be the |
| 114 // spacer bounds if in compact navigation mode. |
| 109 virtual gfx::Rect GetToolbarBounds() const; | 115 virtual gfx::Rect GetToolbarBounds() const; |
| 110 | 116 |
| 111 // Returns the bounds of the content area, in the coordinates of the | 117 // Returns the bounds of the content area, in the coordinates of the |
| 112 // BrowserView's parent. | 118 // BrowserView's parent. |
| 113 gfx::Rect GetClientAreaBounds() const; | 119 gfx::Rect GetClientAreaBounds() const; |
| 114 | 120 |
| 115 // Returns the constraining bounding box that should be used to lay out the | 121 // Returns the constraining bounding box that should be used to lay out the |
| 116 // FindBar within. This is _not_ the size of the find bar, just the bounding | 122 // FindBar within. This is _not_ the size of the find bar, just the bounding |
| 117 // box it should be laid out within. The coordinate system of the returned | 123 // box it should be laid out within. The coordinate system of the returned |
| 118 // rect is in the coordinate system of the frame, since the FindBar is a child | 124 // rect is in the coordinate system of the frame, since the FindBar is a child |
| 119 // window. | 125 // window. |
| 120 gfx::Rect GetFindBarBoundingBox() const; | 126 gfx::Rect GetFindBarBoundingBox() const; |
| 121 | 127 |
| 128 // Returns the bounds of the compact navigation bar (back and forward |
| 129 // buttons). |
| 130 gfx::Rect GetCompactNavigationBarBounds() const; |
| 131 |
| 132 // Returns the bounds of the compact options bar (browser actions and app |
| 133 // menu). |
| 134 gfx::Rect GetCompactOptionsBarBounds() const; |
| 135 |
| 122 // Returns the preferred height of the TabStrip. Used to position the OTR | 136 // Returns the preferred height of the TabStrip. Used to position the OTR |
| 123 // avatar icon. | 137 // avatar icon. |
| 124 virtual int GetTabStripHeight() const; | 138 virtual int GetTabStripHeight() const; |
| 125 | 139 |
| 126 // Takes some view's origin (relative to this BrowserView) and offsets it such | 140 // Takes some view's origin (relative to this BrowserView) and offsets it such |
| 127 // that it can be used as the source origin for seamlessly tiling the toolbar | 141 // that it can be used as the source origin for seamlessly tiling the toolbar |
| 128 // background image over that view. | 142 // background image over that view. |
| 129 gfx::Point OffsetPointForToolbarBackgroundImage( | 143 gfx::Point OffsetPointForToolbarBackgroundImage( |
| 130 const gfx::Point& point) const; | 144 const gfx::Point& point) const; |
| 131 | 145 |
| 132 // Returns the width of the currently displayed sidebar or 0. | 146 // Returns the width of the currently displayed sidebar or 0. |
| 133 int GetSidebarWidth() const; | 147 int GetSidebarWidth() const; |
| 134 | 148 |
| 135 // Accessor for the TabStrip. | 149 // Accessor for the TabStrip. |
| 136 AbstractTabStripView* tabstrip() const { return tabstrip_; } | 150 AbstractTabStripView* tabstrip() const { return tabstrip_; } |
| 137 | 151 |
| 138 // Accessor for the Toolbar. | 152 // Accessor for the Toolbar. |
| 139 ToolbarView* toolbar() const { return toolbar_; } | 153 ToolbarView* toolbar() const { return toolbar_; } |
| 140 | 154 |
| 141 // Returns true if various window components are visible. | 155 // Returns true if various window components are visible. |
| 142 virtual bool IsTabStripVisible() const; | 156 virtual bool IsTabStripVisible() const; |
| 143 | 157 |
| 144 // Returns true if the vertical tabstrip is in use. | 158 // Returns true if the vertical tabstrip is in use. |
| 145 bool UseVerticalTabs() const; | 159 bool UseVerticalTabs() const; |
| 146 | 160 |
| 161 // Returns true if the compact navigation bar is in use. |
| 162 bool UseCompactNavigationBar() const; |
| 163 |
| 147 // Returns true if the profile associated with this Browser window is | 164 // Returns true if the profile associated with this Browser window is |
| 148 // incognito. | 165 // incognito. |
| 149 bool IsOffTheRecord() const; | 166 bool IsOffTheRecord() const; |
| 150 | 167 |
| 151 // Returns true if the non-client view should render the Incognito | 168 // Returns true if the non-client view should render the Incognito |
| 152 // avatar icon if the window is incognito. | 169 // avatar icon if the window is incognito. |
| 153 virtual bool ShouldShowOffTheRecordAvatar() const; | 170 virtual bool ShouldShowOffTheRecordAvatar() const; |
| 154 | 171 |
| 155 // Handle the specified |accelerator| being pressed. | 172 // Handle the specified |accelerator| being pressed. |
| 156 virtual bool AcceleratorPressed(const views::Accelerator& accelerator); | 173 virtual bool AcceleratorPressed(const views::Accelerator& accelerator); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 virtual bool IsFullscreenBubbleVisible() const; | 236 virtual bool IsFullscreenBubbleVisible() const; |
| 220 | 237 |
| 221 // Invoked from the frame when the full screen state changes. This is only | 238 // Invoked from the frame when the full screen state changes. This is only |
| 222 // used on Linux. | 239 // used on Linux. |
| 223 void FullScreenStateChanged(); | 240 void FullScreenStateChanged(); |
| 224 | 241 |
| 225 // Restores the focused view. This is also used to set the initial focus | 242 // Restores the focused view. This is also used to set the initial focus |
| 226 // when a new browser window is created. | 243 // when a new browser window is created. |
| 227 void RestoreFocus(); | 244 void RestoreFocus(); |
| 228 | 245 |
| 246 // Access the CompactLocationBarHost. |
| 247 CompactLocationBarViewHost* compact_location_bar_view_host() { |
| 248 return compact_location_bar_view_host_.get(); |
| 249 } |
| 250 |
| 229 // Overridden from BrowserWindow: | 251 // Overridden from BrowserWindow: |
| 230 virtual void Show() OVERRIDE; | 252 virtual void Show() OVERRIDE; |
| 231 virtual void ShowInactive() OVERRIDE; | 253 virtual void ShowInactive() OVERRIDE; |
| 232 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; | 254 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; |
| 233 virtual void Close() OVERRIDE; | 255 virtual void Close() OVERRIDE; |
| 234 virtual void Activate() OVERRIDE; | 256 virtual void Activate() OVERRIDE; |
| 235 virtual void Deactivate() OVERRIDE; | 257 virtual void Deactivate() OVERRIDE; |
| 236 virtual bool IsActive() const OVERRIDE; | 258 virtual bool IsActive() const OVERRIDE; |
| 237 virtual void FlashFrame() OVERRIDE; | 259 virtual void FlashFrame() OVERRIDE; |
| 238 virtual gfx::NativeWindow GetNativeHandle() OVERRIDE; | 260 virtual gfx::NativeWindow GetNativeHandle() OVERRIDE; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 bool show_history) OVERRIDE; | 319 bool show_history) OVERRIDE; |
| 298 virtual void ShowAppMenu() OVERRIDE; | 320 virtual void ShowAppMenu() OVERRIDE; |
| 299 virtual bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, | 321 virtual bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, |
| 300 bool* is_keyboard_shortcut) OVERRIDE; | 322 bool* is_keyboard_shortcut) OVERRIDE; |
| 301 virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event) | 323 virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event) |
| 302 OVERRIDE; | 324 OVERRIDE; |
| 303 virtual void ShowCreateWebAppShortcutsDialog(TabContentsWrapper* tab_contents) | 325 virtual void ShowCreateWebAppShortcutsDialog(TabContentsWrapper* tab_contents) |
| 304 OVERRIDE; | 326 OVERRIDE; |
| 305 virtual void ShowCreateChromeAppShortcutsDialog( | 327 virtual void ShowCreateChromeAppShortcutsDialog( |
| 306 Profile*, const Extension* app) OVERRIDE; | 328 Profile*, const Extension* app) OVERRIDE; |
| 329 virtual void ToggleUseCompactNavigationBar() OVERRIDE; |
| 307 virtual void Cut() OVERRIDE; | 330 virtual void Cut() OVERRIDE; |
| 308 virtual void Copy() OVERRIDE; | 331 virtual void Copy() OVERRIDE; |
| 309 virtual void Paste() OVERRIDE; | 332 virtual void Paste() OVERRIDE; |
| 310 virtual void ToggleTabStripMode() OVERRIDE; | 333 virtual void ToggleTabStripMode() OVERRIDE; |
| 311 virtual void PrepareForInstant() OVERRIDE; | 334 virtual void PrepareForInstant() OVERRIDE; |
| 312 virtual void ShowInstant(TabContentsWrapper* preview) OVERRIDE; | 335 virtual void ShowInstant(TabContentsWrapper* preview) OVERRIDE; |
| 313 virtual void HideInstant(bool instant_is_active) OVERRIDE; | 336 virtual void HideInstant(bool instant_is_active) OVERRIDE; |
| 314 virtual gfx::Rect GetInstantBounds() OVERRIDE; | 337 virtual gfx::Rect GetInstantBounds() OVERRIDE; |
| 315 virtual WindowOpenDisposition GetDispositionForPopupBounds( | 338 virtual WindowOpenDisposition GetDispositionForPopupBounds( |
| 316 const gfx::Rect& bounds) OVERRIDE; | 339 const gfx::Rect& bounds) OVERRIDE; |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 virtual ToolbarView* CreateToolbar() const; | 452 virtual ToolbarView* CreateToolbar() const; |
| 430 | 453 |
| 431 // Browser window related initializations. | 454 // Browser window related initializations. |
| 432 virtual void Init(); | 455 virtual void Init(); |
| 433 | 456 |
| 434 // Callback for the loading animation(s) associated with this view. | 457 // Callback for the loading animation(s) associated with this view. |
| 435 virtual void LoadingAnimationCallback(); | 458 virtual void LoadingAnimationCallback(); |
| 436 | 459 |
| 437 private: | 460 private: |
| 438 friend class BrowserViewLayout; | 461 friend class BrowserViewLayout; |
| 462 friend class CompactLocationBarHostTest; |
| 439 FRIEND_TEST_ALL_PREFIXES(BrowserViewsAccessibilityTest, | 463 FRIEND_TEST_ALL_PREFIXES(BrowserViewsAccessibilityTest, |
| 440 TestAboutChromeViewAccObj); | 464 TestAboutChromeViewAccObj); |
| 441 | 465 |
| 442 #if defined(OS_WIN) | 466 #if defined(OS_WIN) |
| 443 // Creates the system menu. | 467 // Creates the system menu. |
| 444 void InitSystemMenu(); | 468 void InitSystemMenu(); |
| 445 #endif | 469 #endif |
| 446 | 470 |
| 447 // Returns the BrowserViewLayout. | 471 // Returns the BrowserViewLayout. |
| 448 BrowserViewLayout* GetBrowserViewLayout() const; | 472 BrowserViewLayout* GetBrowserViewLayout() const; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 // has already been added to the view hierarchy. | 543 // has already been added to the view hierarchy. |
| 520 void ProcessTabSelected(TabContentsWrapper* new_contents, | 544 void ProcessTabSelected(TabContentsWrapper* new_contents, |
| 521 bool change_tab_contents); | 545 bool change_tab_contents); |
| 522 | 546 |
| 523 // Exposes resize corner size to BrowserViewLayout. | 547 // Exposes resize corner size to BrowserViewLayout. |
| 524 gfx::Size GetResizeCornerSize() const; | 548 gfx::Size GetResizeCornerSize() const; |
| 525 | 549 |
| 526 // Shows the about chrome modal dialog and returns the Window object. | 550 // Shows the about chrome modal dialog and returns the Window object. |
| 527 views::Window* DoShowAboutChromeDialog(); | 551 views::Window* DoShowAboutChromeDialog(); |
| 528 | 552 |
| 529 // Set the value of |toolbar_| and hook it into the views hiearchy | 553 // Shows the Compact Location Bar under the selected tab. |
| 554 void ShowCompactLocationBarUnderSelectedTab(); |
| 555 |
| 556 // Set the value of |toolbar_| and hook it into the views hierarchy |
| 530 void SetToolbar(ToolbarView* toolbar); | 557 void SetToolbar(ToolbarView* toolbar); |
| 531 | 558 |
| 532 // Last focused view that issued a tab traversal. | 559 // Last focused view that issued a tab traversal. |
| 533 int last_focused_view_storage_id_; | 560 int last_focused_view_storage_id_; |
| 534 | 561 |
| 535 // The BrowserFrame that hosts this view. | 562 // The BrowserFrame that hosts this view. |
| 536 BrowserFrame* frame_; | 563 BrowserFrame* frame_; |
| 537 | 564 |
| 538 // The Browser object we are associated with. | 565 // The Browser object we are associated with. |
| 539 scoped_ptr<Browser> browser_; | 566 scoped_ptr<Browser> browser_; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 // active_bookmark_bar_ is either NULL, if the bookmark bar isn't showing, | 610 // active_bookmark_bar_ is either NULL, if the bookmark bar isn't showing, |
| 584 // or is bookmark_bar_view_ if the bookmark bar is showing. | 611 // or is bookmark_bar_view_ if the bookmark bar is showing. |
| 585 views::View* active_bookmark_bar_; | 612 views::View* active_bookmark_bar_; |
| 586 | 613 |
| 587 // The TabStrip. | 614 // The TabStrip. |
| 588 AbstractTabStripView* tabstrip_; | 615 AbstractTabStripView* tabstrip_; |
| 589 | 616 |
| 590 // The Toolbar containing the navigation buttons, menus and the address bar. | 617 // The Toolbar containing the navigation buttons, menus and the address bar. |
| 591 ToolbarView* toolbar_; | 618 ToolbarView* toolbar_; |
| 592 | 619 |
| 620 // CompactNavigationBar view. |
| 621 CompactNavigationBar* compact_navigation_bar_; |
| 622 |
| 623 // CompactOptionsBar view. |
| 624 CompactOptionsBar* compact_options_bar_; |
| 625 |
| 626 // CompactLocationBarHost. |
| 627 scoped_ptr<CompactLocationBarViewHost> compact_location_bar_view_host_; |
| 628 |
| 629 // A spacer under the tap strip used when the compact navigation bar |
| 630 // is active. |
| 631 views::View* compact_spacer_; |
| 632 |
| 593 // The Bookmark Bar View for this window. Lazily created. | 633 // The Bookmark Bar View for this window. Lazily created. |
| 594 scoped_ptr<BookmarkBarView> bookmark_bar_view_; | 634 scoped_ptr<BookmarkBarView> bookmark_bar_view_; |
| 595 | 635 |
| 596 // The download shelf view (view at the bottom of the page). | 636 // The download shelf view (view at the bottom of the page). |
| 597 scoped_ptr<DownloadShelfView> download_shelf_; | 637 scoped_ptr<DownloadShelfView> download_shelf_; |
| 598 | 638 |
| 599 // The InfoBarContainerView that contains InfoBars for the current tab. | 639 // The InfoBarContainerView that contains InfoBars for the current tab. |
| 600 InfoBarContainerView* infobar_container_; | 640 InfoBarContainerView* infobar_container_; |
| 601 | 641 |
| 602 // The view that contains sidebar for the current tab. | 642 // The view that contains sidebar for the current tab. |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 | 715 |
| 676 NotificationRegistrar registrar_; | 716 NotificationRegistrar registrar_; |
| 677 | 717 |
| 678 // Used to measure the loading spinner animation rate. | 718 // Used to measure the loading spinner animation rate. |
| 679 base::TimeTicks last_animation_time_; | 719 base::TimeTicks last_animation_time_; |
| 680 | 720 |
| 681 DISALLOW_COPY_AND_ASSIGN(BrowserView); | 721 DISALLOW_COPY_AND_ASSIGN(BrowserView); |
| 682 }; | 722 }; |
| 683 | 723 |
| 684 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_VIEW_H_ | 724 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_VIEW_H_ |
| OLD | NEW |