| OLD | NEW |
| 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 "base/scoped_observer.h" | 8 #include "base/scoped_observer.h" |
| 9 #include "chrome/browser/media/router/issues_observer.h" | 9 #include "chrome/browser/media/router/issues_observer.h" |
| 10 #include "chrome/browser/media/router/media_routes_observer.h" | 10 #include "chrome/browser/media/router/local_media_routes_observer.h" |
| 11 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" | 11 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" |
| 12 #include "chrome/browser/ui/toolbar/media_router_contextual_menu.h" | 12 #include "chrome/browser/ui/toolbar/media_router_contextual_menu.h" |
| 13 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h" | 13 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h" |
| 14 | 14 |
| 15 class Browser; | 15 class Browser; |
| 16 class MediaRouterActionPlatformDelegate; | 16 class MediaRouterActionPlatformDelegate; |
| 17 class TabStripModel; | 17 class TabStripModel; |
| 18 | 18 |
| 19 namespace media_router { | 19 namespace media_router { |
| 20 class MediaRouterDialogControllerImpl; | 20 class MediaRouterDialogControllerImpl; |
| 21 } // namespace media_router | 21 } // namespace media_router |
| 22 | 22 |
| 23 // The class for the Media Router component action that will be shown in | 23 // The class for the Media Router component action that will be shown in |
| 24 // the toolbar. | 24 // the toolbar. |
| 25 class MediaRouterAction : public ToolbarActionViewController, | 25 class MediaRouterAction : public ToolbarActionViewController, |
| 26 public media_router::IssuesObserver, | 26 public media_router::IssuesObserver, |
| 27 public media_router::MediaRoutesObserver, | 27 public media_router::LocalMediaRoutesObserver, |
| 28 public TabStripModelObserver { | 28 public TabStripModelObserver { |
| 29 public: | 29 public: |
| 30 explicit MediaRouterAction(Browser* browser); | 30 explicit MediaRouterAction(Browser* browser); |
| 31 ~MediaRouterAction() override; | 31 ~MediaRouterAction() override; |
| 32 | 32 |
| 33 // ToolbarActionViewController implementation. | 33 // ToolbarActionViewController implementation. |
| 34 std::string GetId() const override; | 34 std::string GetId() const override; |
| 35 void SetDelegate(ToolbarActionViewDelegate* delegate) override; | 35 void SetDelegate(ToolbarActionViewDelegate* delegate) override; |
| 36 gfx::Image GetIcon(content::WebContents* web_contents, | 36 gfx::Image GetIcon(content::WebContents* web_contents, |
| 37 const gfx::Size& size) override; | 37 const gfx::Size& size) override; |
| 38 base::string16 GetActionName() const override; | 38 base::string16 GetActionName() const override; |
| 39 base::string16 GetAccessibleName(content::WebContents* web_contents) | 39 base::string16 GetAccessibleName(content::WebContents* web_contents) |
| 40 const override; | 40 const override; |
| 41 base::string16 GetTooltip(content::WebContents* web_contents) | 41 base::string16 GetTooltip(content::WebContents* web_contents) |
| 42 const override; | 42 const override; |
| 43 bool IsEnabled(content::WebContents* web_contents) const override; | 43 bool IsEnabled(content::WebContents* web_contents) const override; |
| 44 bool WantsToRun(content::WebContents* web_contents) const override; | 44 bool WantsToRun(content::WebContents* web_contents) const override; |
| 45 bool HasPopup(content::WebContents* web_contents) const override; | 45 bool HasPopup(content::WebContents* web_contents) const override; |
| 46 void HidePopup() override; | 46 void HidePopup() override; |
| 47 gfx::NativeView GetPopupNativeView() override; | 47 gfx::NativeView GetPopupNativeView() override; |
| 48 ui::MenuModel* GetContextMenu() override; | 48 ui::MenuModel* GetContextMenu() override; |
| 49 bool ExecuteAction(bool by_user) override; | 49 bool ExecuteAction(bool by_user) override; |
| 50 void UpdateState() override; | 50 void UpdateState() override; |
| 51 bool DisabledClickOpensMenu() const override; | 51 bool DisabledClickOpensMenu() const override; |
| 52 | 52 |
| 53 // media_router::IssuesObserver: | 53 // media_router::IssuesObserver: |
| 54 void OnIssueUpdated(const media_router::Issue* issue) override; | 54 void OnIssueUpdated(const media_router::Issue* issue) override; |
| 55 | 55 |
| 56 // media_router::MediaRoutesObserver: | 56 // media_router::LocalMediaRoutesObserver: |
| 57 void OnRoutesUpdated(const std::vector<media_router::MediaRoute>& routes) | 57 void OnHasLocalRouteUpdated(bool has_local_route) override; |
| 58 override; | |
| 59 | 58 |
| 60 // ToolbarStripModelObserver: | 59 // ToolbarStripModelObserver: |
| 61 void ActiveTabChanged(content::WebContents* old_contents, | 60 void ActiveTabChanged(content::WebContents* old_contents, |
| 62 content::WebContents* new_contents, | 61 content::WebContents* new_contents, |
| 63 int index, | 62 int index, |
| 64 int reason) override; | 63 int reason) override; |
| 65 | 64 |
| 66 void OnPopupHidden(); | 65 void OnPopupHidden(); |
| 67 void OnPopupShown(); | 66 void OnPopupShown(); |
| 68 | 67 |
| 69 private: | 68 private: |
| 70 void UpdatePopupState(); | 69 void UpdatePopupState(); |
| 71 | 70 |
| 72 // Returns a reference to the MediaRouterDialogControllerImpl associated with | 71 // Returns a reference to the MediaRouterDialogControllerImpl associated with |
| 73 // |delegate_|'s current WebContents. Guaranteed to be non-null. | 72 // |delegate_|'s current WebContents. Guaranteed to be non-null. |
| 74 // |delegate_| and its current WebContents must not be null. | 73 // |delegate_| and its current WebContents must not be null. |
| 75 // Marked virtual for tests. | 74 // Marked virtual for tests. |
| 76 virtual media_router::MediaRouterDialogControllerImpl* | 75 virtual media_router::MediaRouterDialogControllerImpl* |
| 77 GetMediaRouterDialogController(); | 76 GetMediaRouterDialogController(); |
| 78 | 77 |
| 79 // Overridden by tests. | 78 // Overridden by tests. |
| 80 virtual media_router::MediaRouter* GetMediaRouter(Browser* browser); | |
| 81 virtual MediaRouterActionPlatformDelegate* GetPlatformDelegate(); | 79 virtual MediaRouterActionPlatformDelegate* GetPlatformDelegate(); |
| 82 | 80 |
| 83 // Checks if the current icon of MediaRouterAction has changed. If so, | 81 // Checks if the current icon of MediaRouterAction has changed. If so, |
| 84 // updates |current_icon_|. | 82 // updates |current_icon_|. |
| 85 void MaybeUpdateIcon(); | 83 void MaybeUpdateIcon(); |
| 86 | 84 |
| 87 const gfx::Image* GetCurrentIcon() const; | 85 const gfx::Image* GetCurrentIcon() const; |
| 88 | 86 |
| 89 // Cached icons. | 87 // Cached icons. |
| 90 // Indicates that the current Chrome profile is using at least one device. | 88 // Indicates that the current Chrome profile is using at least one device. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 119 | 117 |
| 120 ScopedObserver<TabStripModel, TabStripModelObserver> | 118 ScopedObserver<TabStripModel, TabStripModelObserver> |
| 121 tab_strip_model_observer_; | 119 tab_strip_model_observer_; |
| 122 | 120 |
| 123 base::WeakPtrFactory<MediaRouterAction> weak_ptr_factory_; | 121 base::WeakPtrFactory<MediaRouterAction> weak_ptr_factory_; |
| 124 | 122 |
| 125 DISALLOW_COPY_AND_ASSIGN(MediaRouterAction); | 123 DISALLOW_COPY_AND_ASSIGN(MediaRouterAction); |
| 126 }; | 124 }; |
| 127 | 125 |
| 128 #endif // CHROME_BROWSER_UI_TOOLBAR_MEDIA_ROUTER_ACTION_H_ | 126 #endif // CHROME_BROWSER_UI_TOOLBAR_MEDIA_ROUTER_ACTION_H_ |
| OLD | NEW |