Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7915)

Unified Diff: chrome/browser/ui/toolbar/media_router_action.h

Issue 1268553002: Reflect the current state in Media Router Action icon. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes per pkasting@'s comments. Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..3d0752e5d3396bb531ce4d75c8b1caa15ff0de61 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.
+ void MaybeUpdateIcon();
+
+ gfx::Image* GetCurrentIcon();
Kevin M 2015/08/05 20:20:27 const
Kevin M 2015/08/05 20:20:27 Mark this function as const. (inspired by a miu c
apacible 2015/08/05 22:13:52 Done.
apacible 2015/08/05 22:13:52 Done.
+
const std::string id_;
const base::string16 name_;
// Cached icons.
+ gfx::Image media_router_active_icon_;
Kevin M 2015/08/05 20:20:27 Make these const?
apacible 2015/08/05 22:13:52 Done.
+ gfx::Image media_router_error_icon_;
gfx::Image media_router_idle_icon_;
+ 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:
+ // 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.
+ // Error: Indicates a failure, e.g. session launch failure.
+ // Warning: Indicates there is a warning message.
+ gfx::Image* current_icon_;
Kevin M 2015/08/05 20:20:27 const ref?
apacible 2015/08/05 22:13:52 Talked offline, const pointer instead.
+
+ // The current issue shown in the Media Router WebUI. Can be null. It is set
+ // in |OnIssueUpdated|, which is called by the IssueManager.
+ scoped_ptr<media_router::Issue> issue_;
+
+ // Whether there exists a local active route.
+ bool has_local_routes_;
ToolbarActionViewDelegate* delegate_;

Powered by Google App Engine
This is Rietveld 408576698