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..41cd1c9d4a9dc23bc06c297352529c08c03ce23a 100644 |
--- a/chrome/browser/ui/toolbar/media_router_action.h |
+++ b/chrome/browser/ui/toolbar/media_router_action.h |
@@ -5,16 +5,59 @@ |
#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 MediaRouterAction; |
class MediaRouterActionPlatformDelegate; |
namespace media_router { |
+class Issue; |
+class MediaRoute; |
+class MediaRouter; |
class MediaRouterDialogController; |
} // namespace media_router |
+class MediaRouterActionObserver : public media_router::IssuesObserver, |
Kevin M
2015/08/03 17:15:37
Add a comment about the class' function?
apacible
2015/08/03 20:47:22
Acknowledged.
|
+ public media_router::MediaRoutesObserver { |
+ public: |
+ MediaRouterActionObserver(media_router::MediaRouter* router, |
Kevin M
2015/08/03 17:15:37
As per our discussion, the MediaRouter* will not c
apacible
2015/08/03 20:47:22
Done.
|
+ MediaRouterAction* action); |
+ ~MediaRouterActionObserver() 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: |
+ MediaRouterAction* action_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(MediaRouterActionObserver); |
+}; |
+ |
+// The current state of the MediaRouterAction. |
+enum MediaRouterActionState { |
+ // 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 { |
@@ -43,19 +86,57 @@ class MediaRouterAction : public ToolbarActionViewController { |
void UpdateState() override; |
bool DisabledClickOpensMenu() const override; |
+ // Updates |issue_|. |issue| may be null. |
+ void SetCurrentIssue(const media_router::Issue* issue); |
+ |
+ // Updates |has_local_routes_|. |
+ void SetHasLocalRoutes(bool has_local_routes); |
+ |
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); |
+ |
// 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. |
+ virtual media_router::MediaRouter* GetMediaRouter(); |
+ |
+ // Checks if the currents state of MediaRouterAction has changed. Updates |
+ // |state_|. If |state_| has changed, update |state_| and then update |
+ // MediaRouterAction's icon. |
+ void MaybeUpdateIcon(); |
+ |
+ // Called when |issue_| or |local_active_route_exists_| may have changed. |
+ 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. |
+ scoped_ptr<media_router::Issue> issue_; |
+ |
+ // Whether there exists a local active route. |
+ bool has_local_routes_; |
ToolbarActionViewDelegate* delegate_; |
+ // scoped_ptr<media_router::IssuesObserver> issues_observer_; |
Kevin M
2015/08/03 17:15:37
Remove these?
apacible
2015/08/03 20:47:22
Done.
|
+ // scoped_ptr<media_router::MediaRoutesObserver> routes_observer_; |
+ scoped_ptr<MediaRouterActionObserver> action_observer_; |
// The delegate to handle platform-specific implementations. |
scoped_ptr<MediaRouterActionPlatformDelegate> platform_delegate_; |