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

Unified Diff: chrome/browser/ui/toolbar/media_router_action_controller.cc

Issue 2559323002: Add a policy to always show the Cast toolbar icon (Closed)
Patch Set: Rebase Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/toolbar/media_router_action_controller.cc
diff --git a/chrome/browser/ui/toolbar/media_router_action_controller.cc b/chrome/browser/ui/toolbar/media_router_action_controller.cc
index 9db79c88093b92967994662d81c8e44971ebdc34..feaca76ae1ce1f77153f754afa67e993c18cd72e 100644
--- a/chrome/browser/ui/toolbar/media_router_action_controller.cc
+++ b/chrome/browser/ui/toolbar/media_router_action_controller.cc
@@ -24,6 +24,17 @@ MediaRouterActionController::~MediaRouterActionController() {
DCHECK_EQ(dialog_count_, 0u);
}
+// static
+bool MediaRouterActionController::IsActionShownByPolicy(Profile* profile) {
+ CHECK(profile);
+ const PrefService::Preference* pref =
+ profile->GetPrefs()->FindPreference(prefs::kShowCastIconInToolbar);
+ bool show = false;
+ if (pref->IsManaged())
+ pref->GetValue()->GetAsBoolean(&show);
+ return show;
+}
+
void MediaRouterActionController::OnIssue(const media_router::Issue& issue) {
has_issue_ = true;
MaybeAddOrRemoveAction();
@@ -68,8 +79,10 @@ MediaRouterActionController::MediaRouterActionController(
media_router::MediaRoutesObserver(router),
profile_(profile),
component_action_delegate_(component_action_delegate),
- component_migration_helper_(component_migration_helper) {
- DCHECK(profile_);
+ component_migration_helper_(component_migration_helper),
+ shown_by_policy_(
+ MediaRouterActionController::IsActionShownByPolicy(profile)) {
+ CHECK(profile_);
media_router::IssuesObserver::Init();
pref_change_registrar_.Init(profile->GetPrefs());
pref_change_registrar_.Add(
@@ -93,7 +106,8 @@ void MediaRouterActionController::MaybeAddOrRemoveAction() {
}
bool MediaRouterActionController::ShouldEnableAction() const {
- return has_local_display_route_ || has_issue_ || dialog_count_ ||
+ return shown_by_policy_ || has_local_display_route_ || has_issue_ ||
+ dialog_count_ ||
component_migration_helper_->GetComponentActionPref(
ComponentToolbarActionsFactory::kMediaRouterActionId);
}
« no previous file with comments | « chrome/browser/ui/toolbar/media_router_action_controller.h ('k') | chrome/browser/ui/toolbar/media_router_contextual_menu.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698