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> |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "chrome/browser/ui/views/exclusive_access_bubble_views_context.h" | 24 #include "chrome/browser/ui/views/exclusive_access_bubble_views_context.h" |
25 #include "chrome/browser/ui/views/frame/browser_frame.h" | 25 #include "chrome/browser/ui/views/frame/browser_frame.h" |
26 #include "chrome/browser/ui/views/frame/contents_web_view.h" | 26 #include "chrome/browser/ui/views/frame/contents_web_view.h" |
27 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" | 27 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" |
28 #include "chrome/browser/ui/views/frame/web_contents_close_handler.h" | 28 #include "chrome/browser/ui/views/frame/web_contents_close_handler.h" |
29 #include "chrome/browser/ui/views/load_complete_listener.h" | 29 #include "chrome/browser/ui/views/load_complete_listener.h" |
30 #include "ui/base/accelerators/accelerator.h" | 30 #include "ui/base/accelerators/accelerator.h" |
31 #include "ui/base/models/simple_menu_model.h" | 31 #include "ui/base/models/simple_menu_model.h" |
32 #include "ui/gfx/native_widget_types.h" | 32 #include "ui/gfx/native_widget_types.h" |
33 #include "ui/views/controls/button/button.h" | 33 #include "ui/views/controls/button/button.h" |
| 34 #include "ui/views/controls/single_split_view_listener.h" |
34 #include "ui/views/controls/webview/unhandled_keyboard_event_handler.h" | 35 #include "ui/views/controls/webview/unhandled_keyboard_event_handler.h" |
35 #include "ui/views/widget/widget_delegate.h" | 36 #include "ui/views/widget/widget_delegate.h" |
36 #include "ui/views/widget/widget_observer.h" | 37 #include "ui/views/widget/widget_observer.h" |
37 #include "ui/views/window/client_view.h" | 38 #include "ui/views/window/client_view.h" |
38 | 39 |
39 #if defined(OS_WIN) | 40 #if defined(OS_WIN) |
40 #include "chrome/browser/hang_monitor/hung_plugin_action.h" | 41 #include "chrome/browser/hang_monitor/hung_plugin_action.h" |
41 #include "chrome/browser/hang_monitor/hung_window_detector.h" | 42 #include "chrome/browser/hang_monitor/hung_window_detector.h" |
42 #endif | 43 #endif |
43 | 44 |
(...skipping 19 matching lines...) Expand all Loading... |
63 class JumpList; | 64 class JumpList; |
64 #endif | 65 #endif |
65 | 66 |
66 namespace extensions { | 67 namespace extensions { |
67 class Extension; | 68 class Extension; |
68 } | 69 } |
69 | 70 |
70 namespace views { | 71 namespace views { |
71 class AccessiblePaneView; | 72 class AccessiblePaneView; |
72 class ExternalFocusTracker; | 73 class ExternalFocusTracker; |
| 74 class SingleSplitView; |
73 class WebView; | 75 class WebView; |
74 } | 76 } |
75 | 77 |
76 /////////////////////////////////////////////////////////////////////////////// | 78 /////////////////////////////////////////////////////////////////////////////// |
77 // BrowserView | 79 // BrowserView |
78 // | 80 // |
79 // A ClientView subclass that provides the contents of a browser window, | 81 // A ClientView subclass that provides the contents of a browser window, |
80 // including the TabStrip, toolbars, download shelves, the content area etc. | 82 // including the TabStrip, toolbars, download shelves, the content area etc. |
81 // | 83 // |
82 class BrowserView : public BrowserWindow, | 84 class BrowserView : public BrowserWindow, |
83 public TabStripModelObserver, | 85 public TabStripModelObserver, |
84 public ui::AcceleratorProvider, | 86 public ui::AcceleratorProvider, |
85 public views::WidgetDelegate, | 87 public views::WidgetDelegate, |
| 88 public content::NotificationObserver, |
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, |
92 public ExclusiveAccessBubbleViewsContext { | 96 public ExclusiveAccessBubbleViewsContext { |
93 public: | 97 public: |
94 // The browser view's class name. | 98 // The browser view's class name. |
95 static const char kViewClassName[]; | 99 static const char kViewClassName[]; |
96 | 100 |
97 BrowserView(); | 101 BrowserView(); |
98 ~BrowserView() override; | 102 ~BrowserView() override; |
99 | 103 |
100 // Takes ownership of |browser|. | 104 // Takes ownership of |browser|. |
101 void Init(Browser* browser); | 105 void Init(Browser* browser); |
102 | 106 |
103 void set_frame(BrowserFrame* frame) { frame_ = frame; } | 107 void set_frame(BrowserFrame* frame) { frame_ = frame; } |
104 BrowserFrame* frame() const { return frame_; } | 108 BrowserFrame* frame() const { return frame_; } |
105 | 109 int GetSidebarWidth() const; |
106 // Returns a pointer to the BrowserView* interface implementation (an | 110 // Returns a pointer to the BrowserView* interface implementation (an |
107 // instance of this object, typically) for a given native window, or null if | 111 // instance of this object, typically) for a given native window, or null if |
108 // there is no such association. | 112 // there is no such association. |
109 // | 113 // |
110 // Don't use this unless you only have a NativeWindow. In nearly all | 114 // Don't use this unless you only have a NativeWindow. In nearly all |
111 // situations plumb through browser and use it. | 115 // situations plumb through browser and use it. |
112 static BrowserView* GetBrowserViewForNativeWindow(gfx::NativeWindow window); | 116 static BrowserView* GetBrowserViewForNativeWindow(gfx::NativeWindow window); |
113 | 117 |
114 // Returns the BrowserView used for the specified Browser. | 118 // Returns the BrowserView used for the specified Browser. |
115 static BrowserView* GetBrowserViewForBrowser(const Browser* browser); | 119 static BrowserView* GetBrowserViewForBrowser(const Browser* browser); |
116 | 120 |
117 // Returns a Browser instance of this view. | 121 // Returns a Browser instance of this view. |
118 Browser* browser() { return browser_.get(); } | 122 Browser* browser() { return browser_.get(); } |
119 const Browser* browser() const { return browser_.get(); } | 123 const Browser* browser() const { return browser_.get(); } |
120 | 124 |
| 125 void Observe(int type, |
| 126 const content::NotificationSource& source, |
| 127 const content::NotificationDetails& details) override; |
121 // Initializes (or re-initializes) the status bubble. We try to only create | 128 // Initializes (or re-initializes) the status bubble. We try to only create |
122 // the bubble once and re-use it for the life of the browser, but certain | 129 // the bubble once and re-use it for the life of the browser, but certain |
123 // events (such as changing enabling/disabling Aero on Win) can force a need | 130 // events (such as changing enabling/disabling Aero on Win) can force a need |
124 // to change some of the bubble's creation parameters. | 131 // to change some of the bubble's creation parameters. |
125 void InitStatusBubble(); | 132 void InitStatusBubble(); |
126 | 133 |
127 // Returns the apparent bounds of the toolbar, in BrowserView coordinates. | 134 // Returns the apparent bounds of the toolbar, in BrowserView coordinates. |
128 // These differ from |toolbar_.bounds()| in that they match where the toolbar | 135 // These differ from |toolbar_.bounds()| in that they match where the toolbar |
129 // background image is drawn -- slightly outside the "true" bounds | 136 // background image is drawn -- slightly outside the "true" bounds |
130 // horizontally. Note that this returns the bounds for the toolbar area. | 137 // horizontally. Note that this returns the bounds for the toolbar area. |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 // This method will not update actual DevTools WebContents, if not | 515 // This method will not update actual DevTools WebContents, if not |
509 // |update_devtools_web_contents|. In this case, manual update is required. | 516 // |update_devtools_web_contents|. In this case, manual update is required. |
510 void UpdateDevToolsForContents(content::WebContents* web_contents, | 517 void UpdateDevToolsForContents(content::WebContents* web_contents, |
511 bool update_devtools_web_contents); | 518 bool update_devtools_web_contents); |
512 | 519 |
513 // Updates various optional child Views, e.g. Bookmarks Bar, Info Bar or the | 520 // 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 | 521 // 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 | 522 // |contents|. |contents| can be null. In this case, all optional UI will be |
516 // removed. | 523 // removed. |
517 void UpdateUIForContents(content::WebContents* contents); | 524 void UpdateUIForContents(content::WebContents* contents); |
518 | 525 bool SplitHandleMoved(views::SingleSplitView* sender) override; |
519 // Invoked to update the necessary things when our fullscreen state changes | 526 // Invoked to update the necessary things when our fullscreen state changes |
520 // to |fullscreen|. On Windows this is invoked immediately when we toggle the | 527 // 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 | 528 // 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 | 529 // ask the window to change its fullscreen state, then when we get |
523 // notification that it succeeded this method is invoked. | 530 // notification that it succeeded this method is invoked. |
524 // If |url| is not empty, it is the URL of the page that requested fullscreen | 531 // If |url| is not empty, it is the URL of the page that requested fullscreen |
525 // (via the fullscreen JS API). | 532 // (via the fullscreen JS API). |
526 // |bubble_type| determines what should be shown in the fullscreen exit | 533 // |bubble_type| determines what should be shown in the fullscreen exit |
527 // bubble. | 534 // bubble. |
528 void ProcessFullscreen(bool fullscreen, | 535 void ProcessFullscreen(bool fullscreen, |
529 FullscreenMode mode, | 536 FullscreenMode mode, |
530 const GURL& url, | 537 const GURL& url, |
531 ExclusiveAccessBubbleType bubble_type); | 538 ExclusiveAccessBubbleType bubble_type); |
532 | 539 |
533 // Returns whether immmersive fullscreen should replace fullscreen. This | 540 // Returns whether immmersive fullscreen should replace fullscreen. This |
534 // should only occur for "browser-fullscreen" for tabbed-typed windows (not | 541 // should only occur for "browser-fullscreen" for tabbed-typed windows (not |
535 // for tab-fullscreen and not for app/popup type windows). | 542 // for tab-fullscreen and not for app/popup type windows). |
536 bool ShouldUseImmersiveFullscreenForUrl(const GURL& url) const; | 543 bool ShouldUseImmersiveFullscreenForUrl(const GURL& url) const; |
537 | 544 |
538 // Copy the accelerator table from the app resources into something we can | 545 // Copy the accelerator table from the app resources into something we can |
539 // use. | 546 // use. |
540 void LoadAccelerators(); | 547 void LoadAccelerators(); |
541 | 548 |
542 // Retrieves the command id for the specified Windows app command. | 549 // Retrieves the command id for the specified Windows app command. |
543 int GetCommandIDForAppCommandID(int app_command_id) const; | 550 int GetCommandIDForAppCommandID(int app_command_id) const; |
544 | 551 |
545 // Initialize the hung plugin detector. | 552 // Initialize the hung plugin detector. |
546 void InitHangMonitor(); | 553 void InitHangMonitor(); |
| 554 void UpdateSidebarForContents(content::WebContents* new_contents); |
547 | 555 |
548 // Possibly records a user metrics action corresponding to the passed-in | 556 // Possibly records a user metrics action corresponding to the passed-in |
549 // accelerator. Only implemented for Chrome OS, where we're interested in | 557 // accelerator. Only implemented for Chrome OS, where we're interested in |
550 // learning about how frequently the top-row keys are used. | 558 // learning about how frequently the top-row keys are used. |
551 void UpdateAcceleratorMetrics(const ui::Accelerator& accelerator, | 559 void UpdateAcceleratorMetrics(const ui::Accelerator& accelerator, |
552 int command_id); | 560 int command_id); |
553 | 561 |
554 // Calls |method| which is either WebContents::Cut, ::Copy, or ::Paste on | 562 // Calls |method| which is either WebContents::Cut, ::Copy, or ::Paste on |
555 // the given WebContents, returning true if it consumed the event. | 563 // the given WebContents, returning true if it consumed the event. |
556 bool DoCutCopyPasteForWebContents( | 564 bool DoCutCopyPasteForWebContents( |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 View* find_bar_host_view_; | 632 View* find_bar_host_view_; |
625 | 633 |
626 // The download shelf view (view at the bottom of the page). | 634 // The download shelf view (view at the bottom of the page). |
627 scoped_ptr<DownloadShelfView> download_shelf_; | 635 scoped_ptr<DownloadShelfView> download_shelf_; |
628 | 636 |
629 // The InfoBarContainerView that contains InfoBars for the current tab. | 637 // The InfoBarContainerView that contains InfoBars for the current tab. |
630 InfoBarContainerView* infobar_container_; | 638 InfoBarContainerView* infobar_container_; |
631 | 639 |
632 // The view that contains the selected WebContents. | 640 // The view that contains the selected WebContents. |
633 ContentsWebView* contents_web_view_; | 641 ContentsWebView* contents_web_view_; |
| 642 content::NotificationRegistrar registrar_; |
634 | 643 |
635 // The view that contains devtools window for the selected WebContents. | 644 // The view that contains devtools window for the selected WebContents. |
636 views::WebView* devtools_web_view_; | 645 views::WebView* devtools_web_view_; |
637 | 646 |
638 // The view managing the devtools and contents positions. | 647 // The view managing the devtools and contents positions. |
639 // Handled by ContentsLayoutManager. | 648 // Handled by ContentsLayoutManager. |
640 views::View* contents_container_; | 649 views::View* contents_container_; |
641 | 650 |
642 // Tracks and stores the last focused view which is not the | 651 // Tracks and stores the last focused view which is not the |
643 // devtools_web_view_ or any of its children. Used to restore focus once | 652 // devtools_web_view_ or any of its children. Used to restore focus once |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
683 | 692 |
684 // The custom JumpList for Windows 7. | 693 // The custom JumpList for Windows 7. |
685 scoped_refptr<JumpList> jumplist_; | 694 scoped_refptr<JumpList> jumplist_; |
686 #endif | 695 #endif |
687 | 696 |
688 // The timer used to update frames for the Loading Animation. | 697 // The timer used to update frames for the Loading Animation. |
689 base::RepeatingTimer<BrowserView> loading_animation_timer_; | 698 base::RepeatingTimer<BrowserView> loading_animation_timer_; |
690 | 699 |
691 views::UnhandledKeyboardEventHandler unhandled_keyboard_event_handler_; | 700 views::UnhandledKeyboardEventHandler unhandled_keyboard_event_handler_; |
692 | 701 |
| 702 views::WebView* sidebar_web_view_; |
| 703 |
| 704 views::View* sidebar_container_; |
| 705 |
| 706 views::SingleSplitView* sidebar_split_; |
| 707 |
693 // Used to measure the loading spinner animation rate. | 708 // Used to measure the loading spinner animation rate. |
694 base::TimeTicks last_animation_time_; | 709 base::TimeTicks last_animation_time_; |
695 | 710 |
696 // If this flag is set then SetFocusToLocationBar() will set focus to the | 711 // If this flag is set then SetFocusToLocationBar() will set focus to the |
697 // location bar even if the browser window is not active. | 712 // location bar even if the browser window is not active. |
698 bool force_location_bar_focus_; | 713 bool force_location_bar_focus_; |
699 | 714 |
700 scoped_ptr<ImmersiveModeController> immersive_mode_controller_; | 715 scoped_ptr<ImmersiveModeController> immersive_mode_controller_; |
701 | 716 |
702 scoped_ptr<WebContentsCloseHandler> web_contents_close_handler_; | 717 scoped_ptr<WebContentsCloseHandler> web_contents_close_handler_; |
703 | 718 |
704 mutable base::WeakPtrFactory<BrowserView> activate_modal_dialog_factory_; | 719 mutable base::WeakPtrFactory<BrowserView> activate_modal_dialog_factory_; |
705 | 720 |
706 DISALLOW_COPY_AND_ASSIGN(BrowserView); | 721 DISALLOW_COPY_AND_ASSIGN(BrowserView); |
707 }; | 722 }; |
708 | 723 |
709 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_VIEW_H_ | 724 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_VIEW_H_ |
OLD | NEW |