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

Side by Side Diff: chrome/browser/ui/toolbar/media_router_action_controller.h

Issue 2294973002: Create MediaRouterActionController and MediaRouterUIService (Closed)
Patch Set: Modify BUILD.gn files, rebase Created 4 years, 3 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/browser/ui/BUILD.gn ('k') | chrome/browser/ui/toolbar/media_router_action_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 <vector>
9
10 #include "chrome/browser/extensions/component_migration_helper.h"
11 #include "chrome/browser/media/router/issues_observer.h"
12 #include "chrome/browser/media/router/media_routes_observer.h"
13 #include "chrome/browser/profiles/profile.h"
14 #include "components/prefs/pref_change_registrar.h"
15
16 using extensions::ComponentMigrationHelper;
17
18 // Controller for MediaRouterAction that determines when to show and hide the
19 // action icon on the toolbar. There should be one instance of this class per
20 // profile, and it should only be used on the UI thread.
21 class MediaRouterActionController : public media_router::IssuesObserver,
22 public media_router::MediaRoutesObserver {
23 public:
24 explicit MediaRouterActionController(Profile* profile);
25 ~MediaRouterActionController() override;
26
27 // media_router::IssuesObserver:
28 void OnIssueUpdated(const media_router::Issue* issue) override;
29
30 // media_router::MediaRoutesObserver:
31 void OnRoutesUpdated(const std::vector<media_router::MediaRoute>& routes,
32 const std::vector<media_router::MediaRoute::Id>&
33 joinable_route_ids) override;
34
35 private:
36 friend class MediaRouterActionControllerUnitTest;
37 FRIEND_TEST_ALL_PREFIXES(MediaRouterActionControllerUnitTest, EphemeralIcon);
38
39 // Constructor for injecting dependencies in tests.
40 MediaRouterActionController(
41 Profile* profile,
42 media_router::MediaRouter* router,
43 ComponentMigrationHelper::ComponentActionDelegate*
44 component_action_delegate,
45 ComponentMigrationHelper* component_migration_helper);
46
47 // Adds or removes the Media Router action icon to/from
48 // |component_action_delegate_| if necessary, depending on whether or not
49 // we have issues or local routes.
50 void MaybeAddOrRemoveAction();
51
52 // Returns |true| if the Media Router action should be present on the toolbar
53 // or the overflow menu.
54 bool ShouldEnableAction() const;
55
56 // The profile |this| is associated with. There should be one instance of this
57 // class per profile.
58 Profile* const profile_;
59
60 // The delegate that is responsible for showing and hiding the icon on the
61 // toolbar. It outlives |this|.
62 ComponentMigrationHelper::ComponentActionDelegate* const
63 component_action_delegate_;
64
65 // Responsible for changing the pref to always show or hide component actions.
66 // It is owned by ToolbarActionsModel and outlives |this|.
67 ComponentMigrationHelper* const component_migration_helper_;
68
69 bool has_issue_ = false;
70 bool has_local_display_route_ = false;
71
72 PrefChangeRegistrar pref_change_registrar_;
73
74 DISALLOW_COPY_AND_ASSIGN(MediaRouterActionController);
75 };
76
77 #endif // CHROME_BROWSER_UI_TOOLBAR_MEDIA_ROUTER_ACTION_CONTROLLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/BUILD.gn ('k') | chrome/browser/ui/toolbar/media_router_action_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698