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 722745255b949eb1d22bd56fda177439e377fe63..73bb1aa31a70b6c2848dec2ce99d3d4856f1865c 100644 |
| --- a/chrome/browser/ui/toolbar/media_router_action_controller.cc |
| +++ b/chrome/browser/ui/toolbar/media_router_action_controller.cc |
| @@ -15,7 +15,10 @@ MediaRouterActionController::MediaRouterActionController(Profile* profile) |
| profile, |
| media_router::MediaRouterFactory::GetApiForBrowserContext(profile), |
| ToolbarActionsModel::Get(profile), |
| - ToolbarActionsModel::Get(profile)->component_migration_helper()) {} |
| + ToolbarActionsModel::Get(profile)->component_migration_helper()) { |
| + DCHECK(component_action_delegate_); |
| + DCHECK(component_migration_helper_); |
| +} |
| MediaRouterActionController::~MediaRouterActionController() { |
| UnregisterObserver(); // media_router::IssuesObserver. |
|
mark a. foltz
2016/10/17 18:57:40
Can you add a DCHECK() here that dialogs_shown_ ==
takumif
2016/10/27 23:06:38
Done.
|
| @@ -39,6 +42,18 @@ void MediaRouterActionController::OnRoutesUpdated( |
| MaybeAddOrRemoveAction(); |
| } |
| +void MediaRouterActionController::OnDialogShown() { |
| + dialog_count_++; |
| + MaybeAddOrRemoveAction(); |
| +} |
| + |
| +void MediaRouterActionController::OnDialogHidden() { |
| + DCHECK_NE(dialog_count_, 0u); |
| + if (dialog_count_) |
| + dialog_count_--; |
| + MaybeAddOrRemoveAction(); |
| +} |
| + |
| MediaRouterActionController::MediaRouterActionController( |
| Profile* profile, |
| media_router::MediaRouter* router, |
| @@ -51,7 +66,6 @@ MediaRouterActionController::MediaRouterActionController( |
| component_action_delegate_(component_action_delegate), |
| component_migration_helper_(component_migration_helper) { |
| DCHECK(profile_); |
| - DCHECK(component_action_delegate_); |
| RegisterObserver(); // media_router::IssuesObserver. |
| pref_change_registrar_.Init(profile->GetPrefs()); |
| pref_change_registrar_.Add( |
| @@ -63,9 +77,10 @@ MediaRouterActionController::MediaRouterActionController( |
| void MediaRouterActionController::MaybeAddOrRemoveAction() { |
| if (ShouldEnableAction()) { |
| if (!component_action_delegate_->HasComponentAction( |
| - ComponentToolbarActionsFactory::kMediaRouterActionId)) |
| + ComponentToolbarActionsFactory::kMediaRouterActionId)) { |
| component_action_delegate_->AddComponentAction( |
| ComponentToolbarActionsFactory::kMediaRouterActionId); |
| + } |
| } else if (component_action_delegate_->HasComponentAction( |
| ComponentToolbarActionsFactory::kMediaRouterActionId)) { |
| component_action_delegate_->RemoveComponentAction( |
| @@ -74,7 +89,7 @@ void MediaRouterActionController::MaybeAddOrRemoveAction() { |
| } |
| bool MediaRouterActionController::ShouldEnableAction() const { |
| - return has_local_display_route_ || has_issue_ || |
| + return has_local_display_route_ || has_issue_ || dialog_count_ || |
| component_migration_helper_->GetComponentActionPref( |
| ComponentToolbarActionsFactory::kMediaRouterActionId); |
| } |