Chromium Code Reviews| Index: chrome/browser/ui/toolbar/media_router_action.h |
| diff --git a/chrome/browser/ui/toolbar/media_router_action.h b/chrome/browser/ui/toolbar/media_router_action.h |
| index 6cc6073cf8ca7248525faab2f2efbcf26108f187..777da13840a531005cc860db2eea4b867dc32d9c 100644 |
| --- a/chrome/browser/ui/toolbar/media_router_action.h |
| +++ b/chrome/browser/ui/toolbar/media_router_action.h |
| @@ -5,8 +5,11 @@ |
| #ifndef CHROME_BROWSER_UI_TOOLBAR_MEDIA_ROUTER_ACTION_H_ |
| #define CHROME_BROWSER_UI_TOOLBAR_MEDIA_ROUTER_ACTION_H_ |
| +#include "chrome/browser/media/router/issues_observer.h" |
| +#include "chrome/browser/media/router/media_routes_observer.h" |
| #include "chrome/browser/ui/toolbar/media_router_contextual_menu.h" |
| #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h" |
| +#include "extensions/browser/process_manager.h" |
| class Browser; |
| class MediaRouterActionPlatformDelegate; |
| @@ -15,9 +18,27 @@ namespace media_router { |
| class MediaRouterDialogController; |
| } // namespace media_router |
| +// The current state of the MediaRouterAction. |
| +enum MediaRouterActionState { |
|
Peter Kasting
2015/08/03 21:28:51
Why not make this public inside MediaRouterAction
apacible
2015/08/05 06:47:55
Acknowledged; ended up removing the enum.
|
| + // Indicates that the current Chrome profile is not using any devices. |
| + // Devices may or may not be available. |
| + MEDIA_ROUTER_ACTION_IDLE, |
| + |
| + // Indicates that the current Chrome profile is using at least one device. |
| + MEDIA_ROUTER_ACTION_ACTIVE, |
| + |
| + // Indicates a failure, e.g. session launch failure. |
| + MEDIA_ROUTER_ACTION_ERROR, |
| + |
| + // Indicates warning messages. |
| + MEDIA_ROUTER_ACTION_WARNING, |
| +}; |
| + |
| // The class for the Media Router component action that will be shown in |
| // the toolbar. |
| -class MediaRouterAction : public ToolbarActionViewController { |
| +class MediaRouterAction : public ToolbarActionViewController, |
| + public media_router::IssuesObserver, |
| + public media_router::MediaRoutesObserver { |
| public: |
| explicit MediaRouterAction(Browser* browser); |
| ~MediaRouterAction() override; |
| @@ -43,17 +64,53 @@ class MediaRouterAction : public ToolbarActionViewController { |
| void UpdateState() override; |
| bool DisabledClickOpensMenu() const override; |
| + // media_router::IssuesObserver: |
| + void OnIssueUpdated(const media_router::Issue* issue) override; |
| + |
| + // media_router::MediaRoutesObserver: |
| + void OnRoutesUpdated(const std::vector<media_router::MediaRoute>& routes) |
| + override; |
| + |
| private: |
| + friend class TestMediaRouterAction; |
| + FRIEND_TEST_ALL_PREFIXES(MediaRouterActionUnitTest, Initialization); |
| + FRIEND_TEST_ALL_PREFIXES(MediaRouterActionUnitTest, UpdateIssues); |
| + FRIEND_TEST_ALL_PREFIXES(MediaRouterActionUnitTest, UpdateRoutes); |
| + FRIEND_TEST_ALL_PREFIXES(MediaRouterActionUnitTest, UpdateIssuesAndRoutes); |
|
Peter Kasting
2015/08/03 21:28:51
I think in this case these friend declarations sig
apacible
2015/08/05 06:47:55
Thanks for bringing this up; from the changes (bas
|
| + |
| // Returns a reference to the MediaRouterDialogController associated with |
| // |delegate_|'s current WebContents. Guaranteed to be non-null. |
| // |delegate_| and its current WebContents must not be null. |
| media_router::MediaRouterDialogController* GetMediaRouterDialogController(); |
| + // Marked virtual to use in tests. |
|
Peter Kasting
2015/08/03 21:28:51
Nit: "Overridden by tests." would probably be clea
apacible
2015/08/05 06:47:55
Done.
|
| + virtual media_router::MediaRouter* GetMediaRouter(Browser* browser); |
| + |
| + // Checks if the currents state of MediaRouterAction has changed. Updates |
| + // |state_|. If |state_| has changed, update |state_| and then update |
|
Peter Kasting
2015/08/03 21:28:51
Nit: update -> updates (2x)
apacible
2015/08/05 06:47:55
Done.
|
| + // MediaRouterAction's icon. |
|
Peter Kasting
2015/08/03 21:28:51
This updates |state_|, not just the icon. So eith
apacible
2015/08/05 06:47:55
Switched to keeping track of the current icon rath
|
| + void MaybeUpdateIcon(); |
| + |
| + // Called when |issue_| or |local_active_route_exists_| may have changed. |
|
Peter Kasting
2015/08/03 21:28:51
This comment is confusing, since it's not really p
apacible
2015/08/05 06:47:55
Done.
|
| + MediaRouterActionState GetMediaRouterActionState(); |
| + |
| const std::string id_; |
| const base::string16 name_; |
| // Cached icons. |
| + gfx::Image media_router_active_icon_; |
| + gfx::Image media_router_error_icon_; |
| gfx::Image media_router_idle_icon_; |
| + gfx::Image media_router_warning_icon_; |
| + |
| + // Current state of the MediaRouterAction. |
| + MediaRouterActionState state_; |
| + |
| + // Used to determine current state of the MediaRouterAction. |
|
Peter Kasting
2015/08/03 21:28:51
This doesn't actually say what |issue_| is, how it
apacible
2015/08/05 06:47:55
Done.
|
| + scoped_ptr<media_router::Issue> issue_; |
| + |
| + // Whether there exists a local active route. |
| + bool has_local_routes_; |
| ToolbarActionViewDelegate* delegate_; |