| OLD | NEW |
| 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/extensions/component_migration_helper.h" | 5 #include "chrome/browser/extensions/component_migration_helper.h" |
| 6 | 6 |
| 7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
| 10 #include "chrome/browser/extensions/extension_system_impl.h" | 10 #include "chrome/browser/extensions/extension_system_impl.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/ui/toolbar/component_toolbar_actions_factory.h" |
| 12 #include "chrome/common/pref_names.h" | 13 #include "chrome/common/pref_names.h" |
| 13 #include "components/prefs/pref_registry_simple.h" | 14 #include "components/prefs/pref_registry_simple.h" |
| 14 #include "components/prefs/pref_service.h" | 15 #include "components/prefs/pref_service.h" |
| 15 #include "components/prefs/scoped_user_pref_update.h" | 16 #include "components/prefs/scoped_user_pref_update.h" |
| 16 #include "content/public/browser/browser_context.h" | 17 #include "content/public/browser/browser_context.h" |
| 17 #include "extensions/browser/extension_registry.h" | 18 #include "extensions/browser/extension_registry.h" |
| 18 #include "extensions/common/feature_switch.h" | 19 #include "extensions/common/feature_switch.h" |
| 19 | 20 |
| 20 namespace extensions { | 21 namespace extensions { |
| 21 | 22 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 const Extension* extension) { | 128 const Extension* extension) { |
| 128 const ExtensionId& extension_id = extension->id(); | 129 const ExtensionId& extension_id = extension->id(); |
| 129 const std::string& component_action_id = | 130 const std::string& component_action_id = |
| 130 GetActionIdForExtensionId(extension_id); | 131 GetActionIdForExtensionId(extension_id); |
| 131 if (component_action_id.empty()) | 132 if (component_action_id.empty()) |
| 132 return; | 133 return; |
| 133 if (ContainsKey(enabled_actions_, component_action_id)) { | 134 if (ContainsKey(enabled_actions_, component_action_id)) { |
| 134 UnloadExtension(extension_id); | 135 UnloadExtension(extension_id); |
| 135 SetComponentActionPref(component_action_id, true); | 136 SetComponentActionPref(component_action_id, true); |
| 136 | 137 |
| 138 if (component_action_id == |
| 139 ComponentToolbarActionsFactory::kMediaRouterActionId) { |
| 140 pref_service_->SetBoolean(prefs::kMediaRouterAlwaysShowActionIcon, |
| 141 true); |
| 142 } |
| 143 |
| 137 if (!delegate_->HasComponentAction(component_action_id)) | 144 if (!delegate_->HasComponentAction(component_action_id)) |
| 138 delegate_->AddComponentAction(component_action_id); | 145 delegate_->AddComponentAction(component_action_id); |
| 139 } | 146 } |
| 140 } | 147 } |
| 141 | 148 |
| 142 void ComponentMigrationHelper::SetComponentActionPref( | 149 void ComponentMigrationHelper::SetComponentActionPref( |
| 143 const std::string& component_action_id, | 150 const std::string& component_action_id, |
| 144 bool enabled) { | 151 bool enabled) { |
| 145 DictionaryPrefUpdate update(pref_service_, | 152 DictionaryPrefUpdate update(pref_service_, |
| 146 ::prefs::kToolbarMigratedComponentActionStatus); | 153 ::prefs::kToolbarMigratedComponentActionStatus); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 std::string ComponentMigrationHelper::GetActionIdForExtensionId( | 186 std::string ComponentMigrationHelper::GetActionIdForExtensionId( |
| 180 const ExtensionId& extension_id) const { | 187 const ExtensionId& extension_id) const { |
| 181 for (const auto& i : migrated_actions_) { | 188 for (const auto& i : migrated_actions_) { |
| 182 if (i.second == extension_id) | 189 if (i.second == extension_id) |
| 183 return i.first; | 190 return i.first; |
| 184 } | 191 } |
| 185 return ""; | 192 return ""; |
| 186 } | 193 } |
| 187 | 194 |
| 188 } // namespace extensions | 195 } // namespace extensions |
| OLD | NEW |