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> | |
msw
2016/09/16 22:22:26
remove
takumif
2016/09/17 00:24:30
Done.
| |
9 #include <string> | |
msw
2016/09/16 22:22:26
remove
takumif
2016/09/17 00:24:30
Done.
| |
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" | |
msw
2016/09/16 22:22:25
nit: remove and rely on fwd decl (or remove the fw
takumif
2016/09/17 00:24:30
Removed the forward declaration.
| |
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 ~MediaRouterActionController() override; | |
30 | |
31 // media_router::IssuesObserver: | |
32 void OnIssueUpdated(const media_router::Issue* issue) override; | |
33 | |
34 // media_router::MediaRoutesObserver: | |
35 void OnRoutesUpdated(const std::vector<media_router::MediaRoute>& routes, | |
36 const std::vector<media_router::MediaRoute::Id>& | |
37 joinable_route_ids) override; | |
38 | |
39 private: | |
40 friend class MediaRouterActionControllerUnitTest; | |
41 FRIEND_TEST_ALL_PREFIXES(MediaRouterActionControllerUnitTest, EphemeralIcon); | |
42 | |
43 // Constructor for injecting dependencies in tests. | |
44 MediaRouterActionController( | |
45 Profile* profile, | |
46 media_router::MediaRouter* router, | |
47 ComponentMigrationHelper::ComponentActionDelegate* | |
48 component_action_delegate, | |
49 ComponentMigrationHelper* component_migration_helper); | |
50 | |
51 // Adds or removes the Media Router action icon to/from | |
52 // |component_action_delegate_| if necessary, depending on whether or not | |
53 // we have issues or local routes. | |
54 void MaybeAddOrRemoveAction(); | |
55 | |
56 // Returns |true| if the Media Router action should be present on the toolbar | |
57 // or the overflow menu. | |
58 bool ShouldEnableAction() const; | |
59 | |
60 // The profile |this| is associated with. There should be one instance of this | |
61 // class per profile. | |
62 Profile* const profile_; | |
63 | |
64 // The delegate that is responsible for showing and hiding the icon on the | |
65 // toolbar. It outlives |this|. | |
66 ComponentMigrationHelper::ComponentActionDelegate* const | |
67 component_action_delegate_; | |
68 | |
69 // Responsible for changing the pref to always show or hide component actions. | |
70 // It is owned by ToolbarActionsModel and outlives |this|. | |
71 ComponentMigrationHelper* const component_migration_helper_; | |
72 | |
73 bool has_issue_; | |
msw
2016/09/16 22:22:26
optional nit: init bools here instead of in the in
takumif
2016/09/17 00:24:30
Done.
| |
74 bool has_local_display_route_; | |
75 | |
76 PrefChangeRegistrar pref_change_registrar_; | |
77 | |
78 DISALLOW_COPY_AND_ASSIGN(MediaRouterActionController); | |
79 }; | |
80 | |
81 #endif // CHROME_BROWSER_UI_TOOLBAR_MEDIA_ROUTER_ACTION_CONTROLLER_H_ | |
OLD | NEW |