| 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 <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/scoped_observer.h" | 12 #include "base/scoped_observer.h" |
| 13 #include "chrome/browser/media/router/issues_observer.h" | 13 #include "chrome/browser/media/router/issues_observer.h" |
| 14 #include "chrome/browser/media/router/media_routes_observer.h" | 14 #include "chrome/browser/media/router/media_routes_observer.h" |
| 15 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" | 15 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" |
| 16 #include "chrome/browser/ui/toolbar/media_router_contextual_menu.h" | 16 #include "chrome/browser/ui/toolbar/media_router_contextual_menu.h" |
| 17 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h" | 17 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h" |
| 18 #include "chrome/browser/ui/toolbar/toolbar_actions_bar.h" | 18 #include "chrome/browser/ui/toolbar/toolbar_actions_bar.h" |
| 19 #include "chrome/browser/ui/toolbar/toolbar_actions_bar_observer.h" | 19 #include "chrome/browser/ui/toolbar/toolbar_actions_bar_observer.h" |
| 20 #include "ui/gfx/vector_icons_public.h" | |
| 21 | 20 |
| 22 class Browser; | 21 class Browser; |
| 23 class MediaRouterActionPlatformDelegate; | 22 class MediaRouterActionPlatformDelegate; |
| 24 class TabStripModel; | 23 class TabStripModel; |
| 25 | 24 |
| 25 namespace gfx { |
| 26 struct VectorIcon; |
| 27 } |
| 28 |
| 26 namespace media_router { | 29 namespace media_router { |
| 27 class MediaRouterDialogControllerImpl; | 30 class MediaRouterDialogControllerImpl; |
| 28 } // namespace media_router | 31 } // namespace media_router |
| 29 | 32 |
| 30 // The class for the Media Router component action that will be shown in | 33 // The class for the Media Router component action that will be shown in |
| 31 // the toolbar. | 34 // the toolbar. |
| 32 class MediaRouterAction : public ToolbarActionViewController, | 35 class MediaRouterAction : public ToolbarActionViewController, |
| 33 public media_router::IssuesObserver, | 36 public media_router::IssuesObserver, |
| 34 public media_router::MediaRoutesObserver, | 37 public media_router::MediaRoutesObserver, |
| 35 public TabStripModelObserver, | 38 public TabStripModelObserver, |
| 36 public ToolbarActionsBarObserver { | 39 public ToolbarActionsBarObserver { |
| 37 public: | 40 public: |
| 38 MediaRouterAction(Browser* browser, ToolbarActionsBar* toolbar_actions_bar); | 41 MediaRouterAction(Browser* browser, ToolbarActionsBar* toolbar_actions_bar); |
| 39 ~MediaRouterAction() override; | 42 ~MediaRouterAction() override; |
| 40 | 43 |
| 41 static SkColor GetIconColor(gfx::VectorIconId icon_id); | 44 static SkColor GetIconColor(const gfx::VectorIcon& icon_id); |
| 42 | 45 |
| 43 // ToolbarActionViewController implementation. | 46 // ToolbarActionViewController implementation. |
| 44 std::string GetId() const override; | 47 std::string GetId() const override; |
| 45 void SetDelegate(ToolbarActionViewDelegate* delegate) override; | 48 void SetDelegate(ToolbarActionViewDelegate* delegate) override; |
| 46 gfx::Image GetIcon(content::WebContents* web_contents, | 49 gfx::Image GetIcon(content::WebContents* web_contents, |
| 47 const gfx::Size& size) override; | 50 const gfx::Size& size) override; |
| 48 base::string16 GetActionName() const override; | 51 base::string16 GetActionName() const override; |
| 49 base::string16 GetAccessibleName(content::WebContents* web_contents) | 52 base::string16 GetAccessibleName(content::WebContents* web_contents) |
| 50 const override; | 53 const override; |
| 51 base::string16 GetTooltip(content::WebContents* web_contents) | 54 base::string16 GetTooltip(content::WebContents* web_contents) |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 virtual media_router::MediaRouterDialogControllerImpl* | 103 virtual media_router::MediaRouterDialogControllerImpl* |
| 101 GetMediaRouterDialogController(); | 104 GetMediaRouterDialogController(); |
| 102 | 105 |
| 103 // Overridden by tests. | 106 // Overridden by tests. |
| 104 virtual MediaRouterActionPlatformDelegate* GetPlatformDelegate(); | 107 virtual MediaRouterActionPlatformDelegate* GetPlatformDelegate(); |
| 105 | 108 |
| 106 // Checks if the current icon of MediaRouterAction has changed. If so, | 109 // Checks if the current icon of MediaRouterAction has changed. If so, |
| 107 // updates |current_icon_|. | 110 // updates |current_icon_|. |
| 108 void MaybeUpdateIcon(); | 111 void MaybeUpdateIcon(); |
| 109 | 112 |
| 110 gfx::VectorIconId GetCurrentIcon() const; | 113 const gfx::VectorIcon& GetCurrentIcon() const; |
| 111 | 114 |
| 112 // The current icon to show. This is updated based on the current issues and | 115 // The current icon to show. This is updated based on the current issues and |
| 113 // routes since |this| is an IssueObserver and MediaRoutesObserver. | 116 // routes since |this| is an IssueObserver and MediaRoutesObserver. |
| 114 gfx::VectorIconId current_icon_; | 117 const gfx::VectorIcon* current_icon_; |
| 115 | 118 |
| 116 // The current issue shown in the Media Router WebUI, set in OnIssue() and | 119 // The current issue shown in the Media Router WebUI, set in OnIssue() and |
| 117 // cleared in OnIssuesCleared(). | 120 // cleared in OnIssuesCleared(). |
| 118 std::unique_ptr<media_router::IssueInfo> current_issue_; | 121 std::unique_ptr<media_router::IssueInfo> current_issue_; |
| 119 | 122 |
| 120 // Whether a local displayable active route exists. | 123 // Whether a local displayable active route exists. |
| 121 bool has_local_display_route_; | 124 bool has_local_display_route_; |
| 122 | 125 |
| 123 // Whether the Media Router dialog is shown in the current tab. | 126 // Whether the Media Router dialog is shown in the current tab. |
| 124 // This should only be updated in OnDialogShown() and OnDialogHidden(). | 127 // This should only be updated in OnDialogShown() and OnDialogHidden(). |
| (...skipping 13 matching lines...) Expand all Loading... |
| 138 tab_strip_model_observer_; | 141 tab_strip_model_observer_; |
| 139 ScopedObserver<ToolbarActionsBar, ToolbarActionsBarObserver> | 142 ScopedObserver<ToolbarActionsBar, ToolbarActionsBarObserver> |
| 140 toolbar_actions_bar_observer_; | 143 toolbar_actions_bar_observer_; |
| 141 | 144 |
| 142 base::WeakPtrFactory<MediaRouterAction> weak_ptr_factory_; | 145 base::WeakPtrFactory<MediaRouterAction> weak_ptr_factory_; |
| 143 | 146 |
| 144 DISALLOW_COPY_AND_ASSIGN(MediaRouterAction); | 147 DISALLOW_COPY_AND_ASSIGN(MediaRouterAction); |
| 145 }; | 148 }; |
| 146 | 149 |
| 147 #endif // CHROME_BROWSER_UI_TOOLBAR_MEDIA_ROUTER_ACTION_H_ | 150 #endif // CHROME_BROWSER_UI_TOOLBAR_MEDIA_ROUTER_ACTION_H_ |
| OLD | NEW |