Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_UI_TOOLBAR_MEDIA_ROUTER_ACTION_CONTROLLER_H_ | |
| 6 #define CHROME_BROWSER_UI_TOOLBAR_MEDIA_ROUTER_ACTION_CONTROLLER_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 #include <string> | |
| 10 #include <vector> | |
| 11 | |
| 12 #include "chrome/browser/extensions/component_migration_helper.h" | |
| 13 #include "chrome/browser/media/router/issues_observer.h" | |
| 14 #include "chrome/browser/media/router/media_routes_observer.h" | |
| 15 #include "chrome/browser/profiles/profile.h" | |
| 16 #include "components/prefs/pref_change_registrar.h" | |
| 17 | |
| 18 using extensions::ComponentMigrationHelper; | |
| 19 | |
| 20 class Profile; | |
| 21 | |
| 22 // Controller for MediaRouterAction that determines when to show and hide the | |
| 23 // action icon on the toolbar. There should be one instance of this class per | |
| 24 // profile, and it should only be used on the UI thread. | |
| 25 class MediaRouterActionController : public media_router::IssuesObserver, | |
| 26 public media_router::MediaRoutesObserver { | |
| 27 public: | |
| 28 explicit MediaRouterActionController(Profile* profile); | |
| 29 // Constructor for injecting dependencies in tests. | |
|
imcheng
2016/09/13 23:13:10
nit: blank line before comment
takumif
2016/09/14 04:00:52
Moving the ctor to private.
| |
| 30 MediaRouterActionController( | |
|
imcheng
2016/09/13 23:13:10
nit: consider moving this ctor to private and addi
takumif
2016/09/14 04:00:52
Done.
| |
| 31 Profile* profile, | |
| 32 media_router::MediaRouter* router, | |
| 33 ComponentMigrationHelper::ComponentActionDelegate* | |
| 34 component_action_delegate, | |
| 35 ComponentMigrationHelper* component_migration_helper); | |
| 36 ~MediaRouterActionController() override; | |
| 37 | |
| 38 // media_router::IssuesObserver: | |
| 39 void OnIssueUpdated(const media_router::Issue* issue) override; | |
| 40 | |
| 41 // media_router::MediaRoutesObserver: | |
| 42 void OnRoutesUpdated(const std::vector<media_router::MediaRoute>& routes, | |
| 43 const std::vector<media_router::MediaRoute::Id>& | |
| 44 joinable_route_ids) override; | |
| 45 | |
| 46 private: | |
| 47 FRIEND_TEST_ALL_PREFIXES(MediaRouterActionControllerUnitTest, EphemeralIcon); | |
| 48 | |
| 49 // Adds or removes the Media Router action icon to/from | |
| 50 // |component_action_delegate_| if necessary, depending on whether or not | |
| 51 // we have issues or local routes. | |
| 52 void MaybeAddOrRemoveAction(); | |
| 53 | |
| 54 // Returns ture if the Media Router action should be present on the toolbar | |
|
imcheng
2016/09/13 23:13:10
s/ture/|true|
takumif
2016/09/14 04:00:52
Oops. Replaced.
| |
| 55 // or the overflow menu. | |
| 56 bool IsActionEnabled(); | |
|
imcheng
2016/09/13 23:13:10
const
takumif
2016/09/14 04:00:52
Done.
| |
| 57 | |
| 58 // The profile |this| is associated with. There should be one instance of this | |
| 59 // class per profile. | |
| 60 Profile* const profile_; | |
| 61 | |
| 62 // The delegate that is responsible for showing and hiding the icon on the | |
| 63 // toolbar. It is a KeyedService and outlives |this|. | |
| 64 ComponentMigrationHelper::ComponentActionDelegate* const | |
| 65 component_action_delegate_; | |
| 66 | |
| 67 // Responsible for changing the pref to always show or hide component actions. | |
| 68 // It is owned by ToolbarActionsModel and outlives |this|. | |
| 69 ComponentMigrationHelper* const component_migration_helper_; | |
| 70 | |
| 71 bool has_issue_; | |
| 72 bool has_local_display_route_; | |
| 73 | |
| 74 PrefChangeRegistrar pref_change_registrar_; | |
| 75 | |
| 76 DISALLOW_COPY_AND_ASSIGN(MediaRouterActionController); | |
| 77 }; | |
| 78 | |
| 79 #endif // CHROME_BROWSER_UI_TOOLBAR_MEDIA_ROUTER_ACTION_CONTROLLER_H_ | |
| OLD | NEW |