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 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/timer/timer.h" | 14 #include "base/timer/timer.h" |
15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
16 #include "chrome/browser/devtools/devtools_window.h" | 16 #include "chrome/browser/devtools/devtools_window.h" |
| 17 #include "chrome/browser/extensions/sidebar_manager_observer.h" |
17 #include "chrome/browser/signin/signin_header_helper.h" | 18 #include "chrome/browser/signin/signin_header_helper.h" |
18 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
19 #include "chrome/browser/ui/browser_window.h" | 20 #include "chrome/browser/ui/browser_window.h" |
20 #include "chrome/browser/ui/exclusive_access/exclusive_access_context.h" | 21 #include "chrome/browser/ui/exclusive_access/exclusive_access_context.h" |
21 #include "chrome/browser/ui/infobar_container_delegate.h" | 22 #include "chrome/browser/ui/infobar_container_delegate.h" |
22 #include "chrome/browser/ui/omnibox/omnibox_popup_model_observer.h" | 23 #include "chrome/browser/ui/omnibox/omnibox_popup_model_observer.h" |
23 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" | 24 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" |
24 #include "chrome/browser/ui/views/exclusive_access_bubble_views_context.h" | 25 #include "chrome/browser/ui/views/exclusive_access_bubble_views_context.h" |
25 #include "chrome/browser/ui/views/frame/browser_frame.h" | 26 #include "chrome/browser/ui/views/frame/browser_frame.h" |
26 #include "chrome/browser/ui/views/frame/contents_web_view.h" | 27 #include "chrome/browser/ui/views/frame/contents_web_view.h" |
27 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" | 28 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" |
28 #include "chrome/browser/ui/views/frame/web_contents_close_handler.h" | 29 #include "chrome/browser/ui/views/frame/web_contents_close_handler.h" |
29 #include "chrome/browser/ui/views/load_complete_listener.h" | 30 #include "chrome/browser/ui/views/load_complete_listener.h" |
30 #include "ui/base/accelerators/accelerator.h" | 31 #include "ui/base/accelerators/accelerator.h" |
31 #include "ui/base/models/simple_menu_model.h" | 32 #include "ui/base/models/simple_menu_model.h" |
32 #include "ui/gfx/native_widget_types.h" | 33 #include "ui/gfx/native_widget_types.h" |
33 #include "ui/views/controls/button/button.h" | 34 #include "ui/views/controls/button/button.h" |
| 35 #include "ui/views/controls/single_split_view_listener.h" |
34 #include "ui/views/controls/webview/unhandled_keyboard_event_handler.h" | 36 #include "ui/views/controls/webview/unhandled_keyboard_event_handler.h" |
35 #include "ui/views/widget/widget_delegate.h" | 37 #include "ui/views/widget/widget_delegate.h" |
36 #include "ui/views/widget/widget_observer.h" | 38 #include "ui/views/widget/widget_observer.h" |
37 #include "ui/views/window/client_view.h" | 39 #include "ui/views/window/client_view.h" |
38 | 40 |
39 #if defined(OS_WIN) | 41 #if defined(OS_WIN) |
40 #include "chrome/browser/hang_monitor/hung_plugin_action.h" | 42 #include "chrome/browser/hang_monitor/hung_plugin_action.h" |
41 #include "chrome/browser/hang_monitor/hung_window_detector.h" | 43 #include "chrome/browser/hang_monitor/hung_window_detector.h" |
42 #endif | 44 #endif |
43 | 45 |
(...skipping 19 matching lines...) Expand all Loading... |
63 class JumpList; | 65 class JumpList; |
64 #endif | 66 #endif |
65 | 67 |
66 namespace extensions { | 68 namespace extensions { |
67 class Extension; | 69 class Extension; |
68 } | 70 } |
69 | 71 |
70 namespace views { | 72 namespace views { |
71 class AccessiblePaneView; | 73 class AccessiblePaneView; |
72 class ExternalFocusTracker; | 74 class ExternalFocusTracker; |
| 75 class SingleSplitView; |
73 class WebView; | 76 class WebView; |
74 } | 77 } |
75 | 78 |
76 /////////////////////////////////////////////////////////////////////////////// | 79 /////////////////////////////////////////////////////////////////////////////// |
77 // BrowserView | 80 // BrowserView |
78 // | 81 // |
79 // A ClientView subclass that provides the contents of a browser window, | 82 // A ClientView subclass that provides the contents of a browser window, |
80 // including the TabStrip, toolbars, download shelves, the content area etc. | 83 // including the TabStrip, toolbars, download shelves, the content area etc. |
81 // | 84 // |
82 class BrowserView : public BrowserWindow, | 85 class BrowserView : public BrowserWindow, |
83 public TabStripModelObserver, | 86 public TabStripModelObserver, |
84 public ui::AcceleratorProvider, | 87 public ui::AcceleratorProvider, |
85 public views::WidgetDelegate, | 88 public views::WidgetDelegate, |
86 public views::WidgetObserver, | 89 public views::WidgetObserver, |
87 public views::ClientView, | 90 public views::ClientView, |
88 public InfoBarContainerDelegate, | 91 public InfoBarContainerDelegate, |
89 public LoadCompleteListener::Delegate, | 92 public LoadCompleteListener::Delegate, |
90 public OmniboxPopupModelObserver, | 93 public OmniboxPopupModelObserver, |
| 94 public views::SingleSplitViewListener, |
91 public ExclusiveAccessContext, | 95 public ExclusiveAccessContext, |
| 96 public SidebarManagerObserver, |
92 public ExclusiveAccessBubbleViewsContext { | 97 public ExclusiveAccessBubbleViewsContext { |
93 public: | 98 public: |
94 // The browser view's class name. | 99 // The browser view's class name. |
95 static const char kViewClassName[]; | 100 static const char kViewClassName[]; |
96 | 101 |
97 BrowserView(); | 102 BrowserView(); |
98 ~BrowserView() override; | 103 ~BrowserView() override; |
99 | 104 |
100 // Takes ownership of |browser|. | 105 // Takes ownership of |browser|. |
101 void Init(Browser* browser); | 106 void Init(Browser* browser); |
102 | 107 |
103 void set_frame(BrowserFrame* frame) { frame_ = frame; } | 108 void set_frame(BrowserFrame* frame) { frame_ = frame; } |
104 BrowserFrame* frame() const { return frame_; } | 109 BrowserFrame* frame() const { return frame_; } |
105 | 110 int GetSidebarWidth() const; |
106 // Returns a pointer to the BrowserView* interface implementation (an | 111 // Returns a pointer to the BrowserView* interface implementation (an |
107 // instance of this object, typically) for a given native window, or null if | 112 // instance of this object, typically) for a given native window, or null if |
108 // there is no such association. | 113 // there is no such association. |
109 // | 114 // |
110 // Don't use this unless you only have a NativeWindow. In nearly all | 115 // Don't use this unless you only have a NativeWindow. In nearly all |
111 // situations plumb through browser and use it. | 116 // situations plumb through browser and use it. |
112 static BrowserView* GetBrowserViewForNativeWindow(gfx::NativeWindow window); | 117 static BrowserView* GetBrowserViewForNativeWindow(gfx::NativeWindow window); |
113 | 118 |
114 // Returns the BrowserView used for the specified Browser. | 119 // Returns the BrowserView used for the specified Browser. |
115 static BrowserView* GetBrowserViewForBrowser(const Browser* browser); | 120 static BrowserView* GetBrowserViewForBrowser(const Browser* browser); |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 ExclusiveAccessManager* GetExclusiveAccessManager() override; | 449 ExclusiveAccessManager* GetExclusiveAccessManager() override; |
445 bool IsImmersiveModeEnabled() override; | 450 bool IsImmersiveModeEnabled() override; |
446 views::Widget* GetBubbleAssociatedWidget() override; | 451 views::Widget* GetBubbleAssociatedWidget() override; |
447 gfx::Rect GetTopContainerBoundsInScreen() override; | 452 gfx::Rect GetTopContainerBoundsInScreen() override; |
448 | 453 |
449 // Testing interface: | 454 // Testing interface: |
450 views::View* GetContentsContainerForTest() { return contents_container_; } | 455 views::View* GetContentsContainerForTest() { return contents_container_; } |
451 views::WebView* GetContentsWebViewForTest() { return contents_web_view_; } | 456 views::WebView* GetContentsWebViewForTest() { return contents_web_view_; } |
452 views::WebView* GetDevToolsWebViewForTest() { return devtools_web_view_; } | 457 views::WebView* GetDevToolsWebViewForTest() { return devtools_web_view_; } |
453 | 458 |
| 459 // Handle SidebarManager events |
| 460 void OnSidebarShown(content::WebContents* tab, |
| 461 const std::string& content_id) override; |
| 462 void OnSidebarHidden(content::WebContents* tab, |
| 463 const std::string& content_id) override; |
| 464 |
454 private: | 465 private: |
455 // Do not friend BrowserViewLayout. Use the BrowserViewLayoutDelegate | 466 // Do not friend BrowserViewLayout. Use the BrowserViewLayoutDelegate |
456 // interface to keep these two classes decoupled and testable. | 467 // interface to keep these two classes decoupled and testable. |
457 friend class BrowserViewLayoutDelegateImpl; | 468 friend class BrowserViewLayoutDelegateImpl; |
458 FRIEND_TEST_ALL_PREFIXES(BrowserViewTest, BrowserView); | 469 FRIEND_TEST_ALL_PREFIXES(BrowserViewTest, BrowserView); |
459 FRIEND_TEST_ALL_PREFIXES(BrowserViewsAccessibilityTest, | 470 FRIEND_TEST_ALL_PREFIXES(BrowserViewsAccessibilityTest, |
460 TestAboutChromeViewAccObj); | 471 TestAboutChromeViewAccObj); |
461 | 472 |
462 enum FullscreenMode { | 473 enum FullscreenMode { |
463 NORMAL_FULLSCREEN, | 474 NORMAL_FULLSCREEN, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 // This method will not update actual DevTools WebContents, if not | 519 // This method will not update actual DevTools WebContents, if not |
509 // |update_devtools_web_contents|. In this case, manual update is required. | 520 // |update_devtools_web_contents|. In this case, manual update is required. |
510 void UpdateDevToolsForContents(content::WebContents* web_contents, | 521 void UpdateDevToolsForContents(content::WebContents* web_contents, |
511 bool update_devtools_web_contents); | 522 bool update_devtools_web_contents); |
512 | 523 |
513 // Updates various optional child Views, e.g. Bookmarks Bar, Info Bar or the | 524 // Updates various optional child Views, e.g. Bookmarks Bar, Info Bar or the |
514 // Download Shelf in response to a change notification from the specified | 525 // Download Shelf in response to a change notification from the specified |
515 // |contents|. |contents| can be null. In this case, all optional UI will be | 526 // |contents|. |contents| can be null. In this case, all optional UI will be |
516 // removed. | 527 // removed. |
517 void UpdateUIForContents(content::WebContents* contents); | 528 void UpdateUIForContents(content::WebContents* contents); |
518 | 529 bool SplitHandleMoved(views::SingleSplitView* sender) override; |
519 // Invoked to update the necessary things when our fullscreen state changes | 530 // Invoked to update the necessary things when our fullscreen state changes |
520 // to |fullscreen|. On Windows this is invoked immediately when we toggle the | 531 // to |fullscreen|. On Windows this is invoked immediately when we toggle the |
521 // full screen state. On Linux changing the fullscreen state is async, so we | 532 // full screen state. On Linux changing the fullscreen state is async, so we |
522 // ask the window to change its fullscreen state, then when we get | 533 // ask the window to change its fullscreen state, then when we get |
523 // notification that it succeeded this method is invoked. | 534 // notification that it succeeded this method is invoked. |
524 // If |url| is not empty, it is the URL of the page that requested fullscreen | 535 // If |url| is not empty, it is the URL of the page that requested fullscreen |
525 // (via the fullscreen JS API). | 536 // (via the fullscreen JS API). |
526 // |bubble_type| determines what should be shown in the fullscreen exit | 537 // |bubble_type| determines what should be shown in the fullscreen exit |
527 // bubble. | 538 // bubble. |
528 void ProcessFullscreen(bool fullscreen, | 539 void ProcessFullscreen(bool fullscreen, |
529 FullscreenMode mode, | 540 FullscreenMode mode, |
530 const GURL& url, | 541 const GURL& url, |
531 ExclusiveAccessBubbleType bubble_type); | 542 ExclusiveAccessBubbleType bubble_type); |
532 | 543 |
533 // Returns whether immmersive fullscreen should replace fullscreen. This | 544 // Returns whether immmersive fullscreen should replace fullscreen. This |
534 // should only occur for "browser-fullscreen" for tabbed-typed windows (not | 545 // should only occur for "browser-fullscreen" for tabbed-typed windows (not |
535 // for tab-fullscreen and not for app/popup type windows). | 546 // for tab-fullscreen and not for app/popup type windows). |
536 bool ShouldUseImmersiveFullscreenForUrl(const GURL& url) const; | 547 bool ShouldUseImmersiveFullscreenForUrl(const GURL& url) const; |
537 | 548 |
538 // Copy the accelerator table from the app resources into something we can | 549 // Copy the accelerator table from the app resources into something we can |
539 // use. | 550 // use. |
540 void LoadAccelerators(); | 551 void LoadAccelerators(); |
541 | 552 |
542 // Retrieves the command id for the specified Windows app command. | 553 // Retrieves the command id for the specified Windows app command. |
543 int GetCommandIDForAppCommandID(int app_command_id) const; | 554 int GetCommandIDForAppCommandID(int app_command_id) const; |
544 | 555 |
545 // Initialize the hung plugin detector. | 556 // Initialize the hung plugin detector. |
546 void InitHangMonitor(); | 557 void InitHangMonitor(); |
| 558 void UpdateSidebarForContents(content::WebContents* new_contents); |
547 | 559 |
548 // Possibly records a user metrics action corresponding to the passed-in | 560 // Possibly records a user metrics action corresponding to the passed-in |
549 // accelerator. Only implemented for Chrome OS, where we're interested in | 561 // accelerator. Only implemented for Chrome OS, where we're interested in |
550 // learning about how frequently the top-row keys are used. | 562 // learning about how frequently the top-row keys are used. |
551 void UpdateAcceleratorMetrics(const ui::Accelerator& accelerator, | 563 void UpdateAcceleratorMetrics(const ui::Accelerator& accelerator, |
552 int command_id); | 564 int command_id); |
553 | 565 |
554 // Calls |method| which is either WebContents::Cut, ::Copy, or ::Paste on | 566 // Calls |method| which is either WebContents::Cut, ::Copy, or ::Paste on |
555 // the given WebContents, returning true if it consumed the event. | 567 // the given WebContents, returning true if it consumed the event. |
556 bool DoCutCopyPasteForWebContents( | 568 bool DoCutCopyPasteForWebContents( |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
683 | 695 |
684 // The custom JumpList for Windows 7. | 696 // The custom JumpList for Windows 7. |
685 scoped_refptr<JumpList> jumplist_; | 697 scoped_refptr<JumpList> jumplist_; |
686 #endif | 698 #endif |
687 | 699 |
688 // The timer used to update frames for the Loading Animation. | 700 // The timer used to update frames for the Loading Animation. |
689 base::RepeatingTimer<BrowserView> loading_animation_timer_; | 701 base::RepeatingTimer<BrowserView> loading_animation_timer_; |
690 | 702 |
691 views::UnhandledKeyboardEventHandler unhandled_keyboard_event_handler_; | 703 views::UnhandledKeyboardEventHandler unhandled_keyboard_event_handler_; |
692 | 704 |
| 705 views::WebView* sidebar_web_view_; |
| 706 |
| 707 views::View* sidebar_container_; |
| 708 |
| 709 views::SingleSplitView* sidebar_split_; |
| 710 |
693 // Used to measure the loading spinner animation rate. | 711 // Used to measure the loading spinner animation rate. |
694 base::TimeTicks last_animation_time_; | 712 base::TimeTicks last_animation_time_; |
695 | 713 |
696 // If this flag is set then SetFocusToLocationBar() will set focus to the | 714 // If this flag is set then SetFocusToLocationBar() will set focus to the |
697 // location bar even if the browser window is not active. | 715 // location bar even if the browser window is not active. |
698 bool force_location_bar_focus_; | 716 bool force_location_bar_focus_; |
699 | 717 |
700 scoped_ptr<ImmersiveModeController> immersive_mode_controller_; | 718 scoped_ptr<ImmersiveModeController> immersive_mode_controller_; |
701 | 719 |
702 scoped_ptr<WebContentsCloseHandler> web_contents_close_handler_; | 720 scoped_ptr<WebContentsCloseHandler> web_contents_close_handler_; |
703 | 721 |
704 mutable base::WeakPtrFactory<BrowserView> activate_modal_dialog_factory_; | 722 mutable base::WeakPtrFactory<BrowserView> activate_modal_dialog_factory_; |
705 | 723 |
706 DISALLOW_COPY_AND_ASSIGN(BrowserView); | 724 DISALLOW_COPY_AND_ASSIGN(BrowserView); |
707 }; | 725 }; |
708 | 726 |
709 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_VIEW_H_ | 727 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_VIEW_H_ |
OLD | NEW |