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

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: Address Derek's comments 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"
msw 2017/01/05 01:14:57 nit: not needed here
takumif 2017/01/06 22:06:57 Removed.
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(Profile* profile);
37
34 // media_router::IssuesObserver: 38 // media_router::IssuesObserver:
35 void OnIssue(const media_router::Issue& issue) override; 39 void OnIssue(const media_router::Issue& issue) override;
36 void OnIssuesCleared() override; 40 void OnIssuesCleared() override;
37 41
38 // media_router::MediaRoutesObserver: 42 // media_router::MediaRoutesObserver:
39 void OnRoutesUpdated(const std::vector<media_router::MediaRoute>& routes, 43 void OnRoutesUpdated(const std::vector<media_router::MediaRoute>& routes,
40 const std::vector<media_router::MediaRoute::Id>& 44 const std::vector<media_router::MediaRoute::Id>&
41 joinable_route_ids) override; 45 joinable_route_ids) override;
42 46
43 // Called when a Media Router dialog is shown or hidden, and updates the 47 // Called when a Media Router dialog is shown or hidden, and updates the
(...skipping 26 matching lines...) Expand all
70 ComponentMigrationHelper::ComponentActionDelegate* const 74 ComponentMigrationHelper::ComponentActionDelegate* const
71 component_action_delegate_; 75 component_action_delegate_;
72 76
73 // Responsible for changing the pref to always show or hide component actions. 77 // Responsible for changing the pref to always show or hide component actions.
74 // It is owned by ToolbarActionsModel and outlives |this|. 78 // It is owned by ToolbarActionsModel and outlives |this|.
75 ComponentMigrationHelper* const component_migration_helper_; 79 ComponentMigrationHelper* const component_migration_helper_;
76 80
77 bool has_issue_ = false; 81 bool has_issue_ = false;
78 bool has_local_display_route_ = false; 82 bool has_local_display_route_ = false;
79 83
84 // Whether the media router action is shown by an administrator policy.
85 bool shown_by_policy_;
86
80 // The number of dialogs that are currently open. 87 // The number of dialogs that are currently open.
81 size_t dialog_count_ = 0; 88 size_t dialog_count_ = 0;
82 89
83 PrefChangeRegistrar pref_change_registrar_; 90 PrefChangeRegistrar pref_change_registrar_;
84 91
85 DISALLOW_COPY_AND_ASSIGN(MediaRouterActionController); 92 DISALLOW_COPY_AND_ASSIGN(MediaRouterActionController);
86 }; 93 };
87 94
88 #endif // CHROME_BROWSER_UI_TOOLBAR_MEDIA_ROUTER_ACTION_CONTROLLER_H_ 95 #endif // CHROME_BROWSER_UI_TOOLBAR_MEDIA_ROUTER_ACTION_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698