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

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

Issue 2450633004: Make ToolbarActionsModel ignore calls to AddComponentAction() before initialization (Closed)
Patch Set: Created 4 years, 1 month 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 #include "chrome/browser/ui/toolbar/media_router_action_controller.h" 5 #include "chrome/browser/ui/toolbar/media_router_action_controller.h"
6 6
7 #include "chrome/browser/media/router/media_router_factory.h" 7 #include "chrome/browser/media/router/media_router_factory.h"
8 #include "chrome/browser/ui/browser.h" 8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/toolbar/component_toolbar_actions_factory.h" 9 #include "chrome/browser/ui/toolbar/component_toolbar_actions_factory.h"
10 #include "chrome/browser/ui/toolbar/toolbar_actions_model.h" 10 #include "chrome/browser/ui/toolbar/toolbar_actions_model.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 DCHECK(component_action_delegate_); 54 DCHECK(component_action_delegate_);
55 RegisterObserver(); // media_router::IssuesObserver. 55 RegisterObserver(); // media_router::IssuesObserver.
56 pref_change_registrar_.Init(profile->GetPrefs()); 56 pref_change_registrar_.Init(profile->GetPrefs());
57 pref_change_registrar_.Add( 57 pref_change_registrar_.Add(
58 prefs::kToolbarMigratedComponentActionStatus, 58 prefs::kToolbarMigratedComponentActionStatus,
59 base::Bind(&MediaRouterActionController::MaybeAddOrRemoveAction, 59 base::Bind(&MediaRouterActionController::MaybeAddOrRemoveAction,
60 base::Unretained(this))); 60 base::Unretained(this)));
61 } 61 }
62 62
63 void MediaRouterActionController::MaybeAddOrRemoveAction() { 63 void MediaRouterActionController::MaybeAddOrRemoveAction() {
64 if (!component_action_delegate_->ActionsInitialized())
Devlin 2016/10/25 22:12:13 I'd have a slight preference to put this check in
takumif 2016/10/26 01:22:01 Yeah, that would be simpler. I thought about addi
65 return;
66
64 if (ShouldEnableAction()) { 67 if (ShouldEnableAction()) {
65 if (!component_action_delegate_->HasComponentAction( 68 if (!component_action_delegate_->HasComponentAction(
66 ComponentToolbarActionsFactory::kMediaRouterActionId)) 69 ComponentToolbarActionsFactory::kMediaRouterActionId))
67 component_action_delegate_->AddComponentAction( 70 component_action_delegate_->AddComponentAction(
68 ComponentToolbarActionsFactory::kMediaRouterActionId); 71 ComponentToolbarActionsFactory::kMediaRouterActionId);
69 } else if (component_action_delegate_->HasComponentAction( 72 } else if (component_action_delegate_->HasComponentAction(
70 ComponentToolbarActionsFactory::kMediaRouterActionId)) { 73 ComponentToolbarActionsFactory::kMediaRouterActionId)) {
71 component_action_delegate_->RemoveComponentAction( 74 component_action_delegate_->RemoveComponentAction(
72 ComponentToolbarActionsFactory::kMediaRouterActionId); 75 ComponentToolbarActionsFactory::kMediaRouterActionId);
73 } 76 }
74 } 77 }
75 78
76 bool MediaRouterActionController::ShouldEnableAction() const { 79 bool MediaRouterActionController::ShouldEnableAction() const {
77 return has_local_display_route_ || has_issue_ || 80 return has_local_display_route_ || has_issue_ ||
78 component_migration_helper_->GetComponentActionPref( 81 component_migration_helper_->GetComponentActionPref(
79 ComponentToolbarActionsFactory::kMediaRouterActionId); 82 ComponentToolbarActionsFactory::kMediaRouterActionId);
80 } 83 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698