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

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

Issue 2559323002: Add a policy to always show the Cast toolbar icon (Closed)
Patch Set: Created 4 years 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 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_CONTROLLER_H_ 5 #ifndef CHROME_BROWSER_UI_TOOLBAR_MEDIA_ROUTER_ACTION_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_TOOLBAR_MEDIA_ROUTER_ACTION_CONTROLLER_H_ 6 #define CHROME_BROWSER_UI_TOOLBAR_MEDIA_ROUTER_ACTION_CONTROLLER_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "chrome/browser/extensions/component_migration_helper.h" 10 #include "chrome/browser/extensions/component_migration_helper.h"
11 #include "chrome/browser/media/router/issues_observer.h" 11 #include "chrome/browser/media/router/issues_observer.h"
12 #include "chrome/browser/media/router/media_routes_observer.h" 12 #include "chrome/browser/media/router/media_routes_observer.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "components/prefs/pref_change_registrar.h" 14 #include "components/prefs/pref_change_registrar.h"
15 #include "components/user_prefs/user_prefs.h"
15 16
16 using extensions::ComponentMigrationHelper; 17 using extensions::ComponentMigrationHelper;
17 18
18 // Controller for MediaRouterAction that determines when to show and hide the 19 // 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 // 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 // profile, and it should only be used on the UI thread.
21 class MediaRouterActionController : public media_router::IssuesObserver, 22 class MediaRouterActionController : public media_router::IssuesObserver,
22 public media_router::MediaRoutesObserver { 23 public media_router::MediaRoutesObserver {
23 public: 24 public:
24 explicit MediaRouterActionController(Profile* profile); 25 explicit MediaRouterActionController(Profile* profile);
25 // Constructor for injecting dependencies in tests. 26 // Constructor for injecting dependencies in tests.
26 MediaRouterActionController( 27 MediaRouterActionController(
27 Profile* profile, 28 Profile* profile,
28 media_router::MediaRouter* router, 29 media_router::MediaRouter* router,
29 ComponentMigrationHelper::ComponentActionDelegate* 30 ComponentMigrationHelper::ComponentActionDelegate*
30 component_action_delegate, 31 component_action_delegate,
31 ComponentMigrationHelper* component_migration_helper); 32 ComponentMigrationHelper* component_migration_helper);
32 ~MediaRouterActionController() override; 33 ~MediaRouterActionController() override;
33 34
35 // Whether the media router action is shown by an administrator policy.
36 static bool IsActionShownByPolicy(content::BrowserContext* context);
imcheng 2016/12/15 19:57:38 might as well use Profile here? Then you can do pr
takumif 2016/12/15 22:04:14 Done.
37
34 // media_router::IssuesObserver: 38 // media_router::IssuesObserver:
35 void OnIssueUpdated(const media_router::Issue* issue) override; 39 void OnIssueUpdated(const media_router::Issue* issue) override;
36 40
37 // media_router::MediaRoutesObserver: 41 // media_router::MediaRoutesObserver:
38 void OnRoutesUpdated(const std::vector<media_router::MediaRoute>& routes, 42 void OnRoutesUpdated(const std::vector<media_router::MediaRoute>& routes,
39 const std::vector<media_router::MediaRoute::Id>& 43 const std::vector<media_router::MediaRoute::Id>&
40 joinable_route_ids) override; 44 joinable_route_ids) override;
41 45
42 // Called when a Media Router dialog is shown or hidden, and updates the 46 // Called when a Media Router dialog is shown or hidden, and updates the
43 // visibility of the action icon. Overridden in tests. 47 // visibility of the action icon. Overridden in tests.
(...skipping 25 matching lines...) Expand all
69 ComponentMigrationHelper::ComponentActionDelegate* const 73 ComponentMigrationHelper::ComponentActionDelegate* const
70 component_action_delegate_; 74 component_action_delegate_;
71 75
72 // Responsible for changing the pref to always show or hide component actions. 76 // Responsible for changing the pref to always show or hide component actions.
73 // It is owned by ToolbarActionsModel and outlives |this|. 77 // It is owned by ToolbarActionsModel and outlives |this|.
74 ComponentMigrationHelper* const component_migration_helper_; 78 ComponentMigrationHelper* const component_migration_helper_;
75 79
76 bool has_issue_ = false; 80 bool has_issue_ = false;
77 bool has_local_display_route_ = false; 81 bool has_local_display_route_ = false;
78 82
83 // Whether the media router action is shown by an administrator policy.
84 bool shown_by_policy_;
85
79 // The number of dialogs that are currently open. 86 // The number of dialogs that are currently open.
80 size_t dialog_count_ = 0; 87 size_t dialog_count_ = 0;
81 88
82 PrefChangeRegistrar pref_change_registrar_; 89 PrefChangeRegistrar pref_change_registrar_;
83 90
84 DISALLOW_COPY_AND_ASSIGN(MediaRouterActionController); 91 DISALLOW_COPY_AND_ASSIGN(MediaRouterActionController);
85 }; 92 };
86 93
87 #endif // CHROME_BROWSER_UI_TOOLBAR_MEDIA_ROUTER_ACTION_CONTROLLER_H_ 94 #endif // CHROME_BROWSER_UI_TOOLBAR_MEDIA_ROUTER_ACTION_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698