Chromium Code Reviews| 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()) |
|
msw
2017/01/05 01:14:57
q: should this check for a non-null pref?
takumif
2017/01/06 22:06:57
The pref gets registered in profile_impl.cc, so it
|
| + 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); |
| } |