OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_TOOLBAR_MEDIA_ROUTER_ACTION_H_ | 5 #ifndef CHROME_BROWSER_UI_TOOLBAR_MEDIA_ROUTER_ACTION_H_ |
6 #define CHROME_BROWSER_UI_TOOLBAR_MEDIA_ROUTER_ACTION_H_ | 6 #define CHROME_BROWSER_UI_TOOLBAR_MEDIA_ROUTER_ACTION_H_ |
7 | 7 |
8 #include "base/scoped_observer.h" | 8 #include "base/scoped_observer.h" |
9 #include "chrome/browser/media/router/issues_observer.h" | 9 #include "chrome/browser/media/router/issues_observer.h" |
10 #include "chrome/browser/media/router/local_media_routes_observer.h" | 10 #include "chrome/browser/media/router/local_media_routes_observer.h" |
11 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" | 11 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" |
12 #include "chrome/browser/ui/toolbar/media_router_contextual_menu.h" | 12 #include "chrome/browser/ui/toolbar/media_router_contextual_menu.h" |
13 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h" | 13 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h" |
| 14 #include "chrome/browser/ui/toolbar/toolbar_actions_bar.h" |
14 | 15 |
15 class Browser; | 16 class Browser; |
16 class MediaRouterActionPlatformDelegate; | 17 class MediaRouterActionPlatformDelegate; |
17 class TabStripModel; | 18 class TabStripModel; |
18 | 19 |
19 namespace media_router { | 20 namespace media_router { |
20 class MediaRouterDialogControllerImpl; | 21 class MediaRouterDialogControllerImpl; |
21 } // namespace media_router | 22 } // namespace media_router |
22 | 23 |
23 // The class for the Media Router component action that will be shown in | 24 // The class for the Media Router component action that will be shown in |
24 // the toolbar. | 25 // the toolbar. |
25 class MediaRouterAction : public ToolbarActionViewController, | 26 class MediaRouterAction : public ToolbarActionViewController, |
26 public media_router::IssuesObserver, | 27 public media_router::IssuesObserver, |
27 public media_router::LocalMediaRoutesObserver, | 28 public media_router::LocalMediaRoutesObserver, |
28 public TabStripModelObserver { | 29 public TabStripModelObserver { |
29 public: | 30 public: |
30 explicit MediaRouterAction(Browser* browser); | 31 MediaRouterAction(Browser* browser, ToolbarActionsBar* toolbar_actions_bar); |
31 ~MediaRouterAction() override; | 32 ~MediaRouterAction() override; |
32 | 33 |
33 // ToolbarActionViewController implementation. | 34 // ToolbarActionViewController implementation. |
34 std::string GetId() const override; | 35 std::string GetId() const override; |
35 void SetDelegate(ToolbarActionViewDelegate* delegate) override; | 36 void SetDelegate(ToolbarActionViewDelegate* delegate) override; |
36 gfx::Image GetIcon(content::WebContents* web_contents, | 37 gfx::Image GetIcon(content::WebContents* web_contents, |
37 const gfx::Size& size) override; | 38 const gfx::Size& size) override; |
38 base::string16 GetActionName() const override; | 39 base::string16 GetActionName() const override; |
39 base::string16 GetAccessibleName(content::WebContents* web_contents) | 40 base::string16 GetAccessibleName(content::WebContents* web_contents) |
40 const override; | 41 const override; |
(...skipping 18 matching lines...) Expand all Loading... |
59 // ToolbarStripModelObserver: | 60 // ToolbarStripModelObserver: |
60 void ActiveTabChanged(content::WebContents* old_contents, | 61 void ActiveTabChanged(content::WebContents* old_contents, |
61 content::WebContents* new_contents, | 62 content::WebContents* new_contents, |
62 int index, | 63 int index, |
63 int reason) override; | 64 int reason) override; |
64 | 65 |
65 void OnPopupHidden(); | 66 void OnPopupHidden(); |
66 void OnPopupShown(); | 67 void OnPopupShown(); |
67 | 68 |
68 private: | 69 private: |
| 70 // Called when a new browser window is opened, the user switches tabs in the |
| 71 // browser window, or when |delegate_| is swapped out to be non-null and has |
| 72 // a valid WebContents. |
| 73 // This updates the pressed/unpressed state of the icon, which is different |
| 74 // on a per-tab basis. |
69 void UpdatePopupState(); | 75 void UpdatePopupState(); |
70 | 76 |
71 // Returns a reference to the MediaRouterDialogControllerImpl associated with | 77 // Returns a reference to the MediaRouterDialogControllerImpl associated with |
72 // |delegate_|'s current WebContents. Guaranteed to be non-null. | 78 // |delegate_|'s current WebContents. Guaranteed to be non-null. |
73 // |delegate_| and its current WebContents must not be null. | 79 // |delegate_| and its current WebContents must not be null. |
74 // Marked virtual for tests. | 80 // Marked virtual for tests. |
75 virtual media_router::MediaRouterDialogControllerImpl* | 81 virtual media_router::MediaRouterDialogControllerImpl* |
76 GetMediaRouterDialogController(); | 82 GetMediaRouterDialogController(); |
77 | 83 |
78 // Overridden by tests. | 84 // Overridden by tests. |
(...skipping 23 matching lines...) Expand all Loading... |
102 // The current issue shown in the Media Router WebUI. Can be null. It is set | 108 // The current issue shown in the Media Router WebUI. Can be null. It is set |
103 // in OnIssueUpdated(), which is called by the IssueManager. | 109 // in OnIssueUpdated(), which is called by the IssueManager. |
104 scoped_ptr<media_router::Issue> issue_; | 110 scoped_ptr<media_router::Issue> issue_; |
105 | 111 |
106 // Whether a local displayable active route exists. | 112 // Whether a local displayable active route exists. |
107 bool has_local_display_route_; | 113 bool has_local_display_route_; |
108 | 114 |
109 ToolbarActionViewDelegate* delegate_; | 115 ToolbarActionViewDelegate* delegate_; |
110 | 116 |
111 Browser* const browser_; | 117 Browser* const browser_; |
| 118 ToolbarActionsBar* const toolbar_actions_bar_; |
112 | 119 |
113 // The delegate to handle platform-specific implementations. | 120 // The delegate to handle platform-specific implementations. |
114 scoped_ptr<MediaRouterActionPlatformDelegate> platform_delegate_; | 121 scoped_ptr<MediaRouterActionPlatformDelegate> platform_delegate_; |
115 | 122 |
116 MediaRouterContextualMenu contextual_menu_; | 123 MediaRouterContextualMenu contextual_menu_; |
117 | 124 |
118 ScopedObserver<TabStripModel, TabStripModelObserver> | 125 ScopedObserver<TabStripModel, TabStripModelObserver> |
119 tab_strip_model_observer_; | 126 tab_strip_model_observer_; |
120 | 127 |
121 base::WeakPtrFactory<MediaRouterAction> weak_ptr_factory_; | 128 base::WeakPtrFactory<MediaRouterAction> weak_ptr_factory_; |
122 | 129 |
123 DISALLOW_COPY_AND_ASSIGN(MediaRouterAction); | 130 DISALLOW_COPY_AND_ASSIGN(MediaRouterAction); |
124 }; | 131 }; |
125 | 132 |
126 #endif // CHROME_BROWSER_UI_TOOLBAR_MEDIA_ROUTER_ACTION_H_ | 133 #endif // CHROME_BROWSER_UI_TOOLBAR_MEDIA_ROUTER_ACTION_H_ |
OLD | NEW |