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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_UI_TOOLBAR_MEDIA_ROUTER_ACTION_H_ 5 #ifndef CHROME_BROWSER_UI_TOOLBAR_MEDIA_ROUTER_ACTION_H_
6 #define CHROME_BROWSER_UI_TOOLBAR_MEDIA_ROUTER_ACTION_H_ 6 #define CHROME_BROWSER_UI_TOOLBAR_MEDIA_ROUTER_ACTION_H_
7 7
8 #include "chrome/browser/media/router/issues_observer.h"
9 #include "chrome/browser/media/router/media_routes_observer.h"
8 #include "chrome/browser/ui/toolbar/media_router_contextual_menu.h" 10 #include "chrome/browser/ui/toolbar/media_router_contextual_menu.h"
9 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h" 11 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h"
10 12
11 class Browser; 13 class Browser;
12 class MediaRouterActionPlatformDelegate; 14 class MediaRouterActionPlatformDelegate;
13 15
14 namespace media_router { 16 namespace media_router {
15 class MediaRouterDialogController; 17 class MediaRouterDialogController;
16 } // namespace media_router 18 } // namespace media_router
17 19
18 // The class for the Media Router component action that will be shown in 20 // The class for the Media Router component action that will be shown in
19 // the toolbar. 21 // the toolbar.
20 class MediaRouterAction : public ToolbarActionViewController { 22 class MediaRouterAction : public ToolbarActionViewController,
23 public media_router::IssuesObserver,
24 public media_router::MediaRoutesObserver {
21 public: 25 public:
22 explicit MediaRouterAction(Browser* browser); 26 explicit MediaRouterAction(Browser* browser);
23 ~MediaRouterAction() override; 27 ~MediaRouterAction() override;
24 28
25 // ToolbarActionViewController implementation. 29 // ToolbarActionViewController implementation.
26 const std::string& GetId() const override; 30 const std::string& GetId() const override;
27 void SetDelegate(ToolbarActionViewDelegate* delegate) override; 31 void SetDelegate(ToolbarActionViewDelegate* delegate) override;
28 gfx::Image GetIcon(content::WebContents* web_contents, 32 gfx::Image GetIcon(content::WebContents* web_contents,
29 const gfx::Size& size) override; 33 const gfx::Size& size) override;
30 base::string16 GetActionName() const override; 34 base::string16 GetActionName() const override;
31 base::string16 GetAccessibleName(content::WebContents* web_contents) 35 base::string16 GetAccessibleName(content::WebContents* web_contents)
32 const override; 36 const override;
33 base::string16 GetTooltip(content::WebContents* web_contents) 37 base::string16 GetTooltip(content::WebContents* web_contents)
34 const override; 38 const override;
35 bool IsEnabled(content::WebContents* web_contents) const override; 39 bool IsEnabled(content::WebContents* web_contents) const override;
36 bool WantsToRun(content::WebContents* web_contents) const override; 40 bool WantsToRun(content::WebContents* web_contents) const override;
37 bool HasPopup(content::WebContents* web_contents) const override; 41 bool HasPopup(content::WebContents* web_contents) const override;
38 void HidePopup() override; 42 void HidePopup() override;
39 gfx::NativeView GetPopupNativeView() override; 43 gfx::NativeView GetPopupNativeView() override;
40 ui::MenuModel* GetContextMenu() override; 44 ui::MenuModel* GetContextMenu() override;
41 bool CanDrag() const override; 45 bool CanDrag() const override;
42 bool ExecuteAction(bool by_user) override; 46 bool ExecuteAction(bool by_user) override;
43 void UpdateState() override; 47 void UpdateState() override;
44 bool DisabledClickOpensMenu() const override; 48 bool DisabledClickOpensMenu() const override;
45 49
50 // media_router::IssuesObserver:
51 void OnIssueUpdated(const media_router::Issue* issue) override;
52
53 // media_router::MediaRoutesObserver:
54 void OnRoutesUpdated(const std::vector<media_router::MediaRoute>& routes)
55 override;
56
46 private: 57 private:
47 // Returns a reference to the MediaRouterDialogController associated with 58 // Returns a reference to the MediaRouterDialogController associated with
48 // |delegate_|'s current WebContents. Guaranteed to be non-null. 59 // |delegate_|'s current WebContents. Guaranteed to be non-null.
49 // |delegate_| and its current WebContents must not be null. 60 // |delegate_| and its current WebContents must not be null.
50 media_router::MediaRouterDialogController* GetMediaRouterDialogController(); 61 media_router::MediaRouterDialogController* GetMediaRouterDialogController();
51 62
63 // Overridden by tests.
64 virtual media_router::MediaRouter* GetMediaRouter(Browser* browser);
65
66 // Checks if the current icon of MediaRouterAction has changed. If so,
67 // updates |current_icon_|.
68 void MaybeUpdateIcon();
69
70 const gfx::Image* GetCurrentIcon() const;
71
52 const std::string id_; 72 const std::string id_;
53 const base::string16 name_; 73 const base::string16 name_;
54 74
55 // Cached icons. 75 // Cached icons.
56 gfx::Image media_router_idle_icon_; 76 // Indicates that the current Chrome profile is using at least one device.
77 const gfx::Image media_router_active_icon_;
78 // Indicates a failure, e.g. session launch failure.
79 const gfx::Image media_router_error_icon_;
80 // Indicates that the current Chrome profile is not using any devices.
81 // Devices may or may not be available.
82 const gfx::Image media_router_idle_icon_;
83 // Indicates there is a warning message.
84 const gfx::Image media_router_warning_icon_;
85
86 // The current icon to show. This is updated based on the current issues and
87 // routes since |this| is an IssueObserver and MediaRoutesObserver.
88 const gfx::Image* current_icon_;
89
90 // The current issue shown in the Media Router WebUI. Can be null. It is set
91 // in OnIssueUpdated(), which is called by the IssueManager.
92 scoped_ptr<media_router::Issue> issue_;
93
94 // Whether a local active route exists.
95 bool has_local_route_;
57 96
58 ToolbarActionViewDelegate* delegate_; 97 ToolbarActionViewDelegate* delegate_;
59 98
60 // The delegate to handle platform-specific implementations. 99 // The delegate to handle platform-specific implementations.
61 scoped_ptr<MediaRouterActionPlatformDelegate> platform_delegate_; 100 scoped_ptr<MediaRouterActionPlatformDelegate> platform_delegate_;
62 101
63 MediaRouterContextualMenu contextual_menu_; 102 MediaRouterContextualMenu contextual_menu_;
64 103
65 DISALLOW_COPY_AND_ASSIGN(MediaRouterAction); 104 DISALLOW_COPY_AND_ASSIGN(MediaRouterAction);
66 }; 105 };
67 106
68 #endif // CHROME_BROWSER_UI_TOOLBAR_MEDIA_ROUTER_ACTION_H_ 107 #endif // CHROME_BROWSER_UI_TOOLBAR_MEDIA_ROUTER_ACTION_H_
OLDNEW
« 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