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

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: Fix tests (lsan). 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
« no previous file with comments | « chrome/app/theme/theme_resources.grd ('k') | chrome/browser/ui/toolbar/media_router_action.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..607e726da4fa96b32969d9f5ca18bb2b65b83781 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,52 @@ 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 current icon of MediaRouterAction has changed. If so,
+ // updates |current_icon_|.
+ void MaybeUpdateIcon();
+
+ const gfx::Image* GetCurrentIcon() const;
+
const std::string id_;
const base::string16 name_;
// Cached icons.
- gfx::Image media_router_idle_icon_;
+ // Indicates that the current Chrome profile is using at least one device.
+ const gfx::Image media_router_active_icon_;
+ // Indicates a failure, e.g. session launch failure.
+ const gfx::Image media_router_error_icon_;
+ // Indicates that the current Chrome profile is not using any devices.
+ // Devices may or may not be available.
+ const gfx::Image media_router_idle_icon_;
+ // Indicates there is a warning message.
+ 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.
+ 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.
+ scoped_ptr<media_router::Issue> issue_;
+
+ // Whether a local active route exists.
+ bool has_local_route_;
ToolbarActionViewDelegate* delegate_;
« no previous file with comments | « chrome/app/theme/theme_resources.grd ('k') | chrome/browser/ui/toolbar/media_router_action.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698