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..e8f2ec13553c7a3a4542f537345aaa63267bef27 100644 |
--- a/chrome/browser/ui/toolbar/media_router_action.h |
+++ b/chrome/browser/ui/toolbar/media_router_action.h |
@@ -5,6 +5,8 @@ |
#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" |
@@ -17,7 +19,9 @@ class MediaRouterDialogController; |
// 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 +47,55 @@ 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: |
// 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(); |
+ // Overridden by tests. |
+ virtual media_router::MediaRouter* GetMediaRouter(Browser* browser); |
+ |
+ // Checks if the currents state of MediaRouterAction has changed. Updates |
+ // |state_|. If |state_| has changed, updates |state_| and then updates |
+ // MediaRouterAction's icon. |
Peter Kasting
2015/08/07 17:49:28
This comment is out of date.
apacible
2015/08/10 23:10:32
Updated.
|
+ void MaybeUpdateIcon(); |
+ |
+ const gfx::Image& GetCurrentIcon() const; |
+ |
const std::string id_; |
const base::string16 name_; |
// Cached icons. |
- gfx::Image media_router_idle_icon_; |
+ const gfx::Image media_router_active_icon_; |
+ const gfx::Image media_router_error_icon_; |
+ const gfx::Image media_router_idle_icon_; |
+ const gfx::Image media_router_warning_icon_; |
+ |
+ // The current icon to show. This is updated based on the current issues and |
+ // routes since |this| is an IssueObserver and MediaRoutesObserver. |
+ // The possible icons and their behaviors are: |
Peter Kasting
2015/08/07 17:49:27
You might want to put the icon descriptions above
apacible
2015/08/10 23:10:32
Done.
|
+ // Idle: Indicates that the current Chrome profile is not using any |
+ // devices. Devices may or may not be available. |
+ // Active: Indicates that the current Chrome profile is using at least one |
+ // device. |
Peter Kasting
2015/08/07 17:49:27
Tiny nit: Indent 2 more
apacible
2015/08/10 23:10:32
Acknowledged.
|
+ // Error: Indicates a failure, e.g. session launch failure. |
+ // Warning: Indicates there is a warning message. |
+ const gfx::Image* current_icon_; |
+ |
+ // The current issue shown in the Media Router WebUI. Can be null. It is set |
+ // in |OnIssueUpdated|, which is called by the IssueManager. |
Peter Kasting
2015/08/07 17:49:28
Nit: Use () rather than || to denote function name
apacible
2015/08/10 23:10:32
Done.
|
+ scoped_ptr<media_router::Issue> issue_; |
+ |
+ // Whether there exists a local active route. |
Peter Kasting
2015/08/07 17:49:27
Nit: Whether a local active route exists.
apacible
2015/08/10 23:10:32
Done.
|
+ bool has_local_routes_; |
Peter Kasting
2015/08/07 17:49:27
Tiny nit: If this is true if "a route" exists, sho
apacible
2015/08/10 23:10:32
Done.
|
ToolbarActionViewDelegate* delegate_; |