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

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

Issue 2294973002: Create MediaRouterActionController and MediaRouterUIService (Closed)
Patch Set: Address Derek and Mark's comments 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
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 <memory>
9 #include <string>
10 #include <vector>
11
12 #include "base/observer_list.h"
13 #include "chrome/browser/extensions/component_migration_helper.h"
mark a. foltz 2016/09/09 17:48:29 Can you forward declare ComponentMigrationHelper?
takumif 2016/09/12 19:01:32 No, because it includes declaration for ComponentA
14 #include "chrome/browser/media/router/issues_observer.h"
15 #include "chrome/browser/media/router/media_router_factory.h"
mark a. foltz 2016/09/09 17:48:29 Is this used? Or can you forward declare MediaRout
takumif 2016/09/12 19:01:32 It's not used here. Removed.
16 #include "chrome/browser/media/router/media_routes_observer.h"
17 #include "chrome/browser/profiles/profile.h"
mark a. foltz 2016/09/09 17:48:29 Can you forward declare Profile?
takumif 2016/09/12 19:01:31 Done.
18 #include "components/prefs/pref_change_registrar.h"
19
20 class MediaRouterActionControllerUnitTest;
mark a. foltz 2016/09/09 17:48:29 This seems to be unused
takumif 2016/09/12 19:01:32 Removed.
21
22 // Controller for MediaRouterAction that determines when to show and hide the
mark a. foltz 2016/09/09 17:48:29 Please document threading assumptions, i.e. this c
takumif 2016/09/12 19:01:31 Done.
23 // action icon on the toolbar.
24 // There should be one instance of this class per profile.
mark a. foltz 2016/09/09 17:48:28 Sorry for the churn, but my current thinking is we
imcheng 2016/09/09 18:12:25 I think that makes sense given that we face opposi
25 class MediaRouterActionController : public media_router::IssuesObserver,
26 public media_router::MediaRoutesObserver {
27 public:
28 // MediaRouterAction will observe MediaRouterActionController to update its
29 // icon.
30 class Observer {
mark a. foltz 2016/09/09 17:48:29 This does not seem to be used (yet). Is there a s
31 public:
32 virtual void OnIssueUpdated(const media_router::Issue* issue) = 0;
33 virtual void OnLocalRouteUpdated(bool has_local_route) = 0;
34 };
35
36 MediaRouterActionController(Profile* profile,
37 media_router::MediaRouter* router);
38 MediaRouterActionController(
mark a. foltz 2016/09/09 17:48:28 Normally |router| and |component_action_delegate|
takumif 2016/09/12 19:01:32 Done.
39 Profile* profile,
40 media_router::MediaRouter* router,
41 extensions::ComponentMigrationHelper::ComponentActionDelegate*
42 component_action_delegate);
43 ~MediaRouterActionController() override;
44
45 // media_router::IssuesObserver:
46 void OnIssueUpdated(const media_router::Issue* issue) override;
47
48 // media_router::MediaRoutesObserver:
49 void OnRoutesUpdated(const std::vector<media_router::MediaRoute>& routes,
50 const std::vector<media_router::MediaRoute::Id>&
51 joinable_route_ids) override;
52
53 // Sets the preferences to always show the Media Router action icon on the
54 // toolbar.
55 // Also updates the presence of the action if necessary.
mark a. foltz 2016/09/09 17:48:29 Nit: wrap comment to previous line
takumif 2016/09/12 19:01:31 Done.
56 void SetAlwaysShowActionPref(bool always_show);
57
58 bool HasLocalRoute() const;
mark a. foltz 2016/09/09 17:48:28 Should this be part of the Observer API? If this
59
60 // Returns the current issue, or a nullptr if there is none.
61 media_router::Issue* GetIssue() const;
mark a. foltz 2016/09/09 17:48:29 Similar comments to |HasLocalRoute()|.
62
63 void AddObserver(Observer* observer);
64 void RemoveObserver(Observer* observer);
65
66 private:
67 // Adds or removes the Media Router action icon to/from
68 // |component_action_delegate_| if necessary, depending on whether or not
69 // we have issues or local routes.
70 void MaybeAddOrRemoveAction();
71
72 // Whether the preference to always show the Media Router action icon is
73 // turned on for the current profile.
74 bool GetAlwaysShowActionPref();
75
76 // Returns ture if the Media Router action should be present on the toolbar
77 // or the overflow menu.
78 bool IsActionEnabled();
79
80 // The profile |this| is associated with. There should be one instance of this
81 // class per profile.
82 Profile* const profile_;
83
84 // The delegate that is responsible for showing and hiding the icon on the
85 // toolbar. It is a KeyedService and outlives |this|.
86 extensions::ComponentMigrationHelper::ComponentActionDelegate* const
87 component_action_delegate_;
88
89 std::unique_ptr<media_router::Issue> issue_;
90 bool has_local_display_route_;
91
92 base::ObserverList<Observer> observers_;
93
94 PrefChangeRegistrar pref_change_registrar_;
95
96 DISALLOW_COPY_AND_ASSIGN(MediaRouterActionController);
97 };
98
99 #endif // CHROME_BROWSER_UI_TOOLBAR_MEDIA_ROUTER_ACTION_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698