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" |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
132 return; | 132 return; |
133 if (base::ContainsKey(enabled_actions_, component_action_id)) { | 133 if (base::ContainsKey(enabled_actions_, component_action_id)) { |
134 UnloadExtension(extension_id); | 134 UnloadExtension(extension_id); |
135 SetComponentActionPref(component_action_id, true); | 135 SetComponentActionPref(component_action_id, true); |
136 | 136 |
137 if (!delegate_->HasComponentAction(component_action_id)) | 137 if (!delegate_->HasComponentAction(component_action_id)) |
138 delegate_->AddComponentAction(component_action_id); | 138 delegate_->AddComponentAction(component_action_id); |
139 } | 139 } |
140 } | 140 } |
141 | 141 |
142 bool ComponentMigrationHelper::GetComponentActionPref( | |
mark a. foltz
2016/09/13 18:23:04
- Please refactor @L80 to call this method.
- DCHE
takumif
2016/09/14 04:00:51
Done. DCHECKing here means component actions can o
| |
143 const std::string& component_action_id) const { | |
144 const base::DictionaryValue* migration_pref = pref_service_->GetDictionary( | |
145 ::prefs::kToolbarMigratedComponentActionStatus); | |
146 bool component_action_pref = false; | |
147 | |
148 migration_pref->GetBoolean(component_action_id, &component_action_pref); | |
mark a. foltz
2016/09/13 18:23:04
What does this return if there is no pre-existing
takumif
2016/09/14 04:00:51
GetBoolean returns false and not touch |component_
| |
149 return component_action_pref; | |
150 } | |
151 | |
142 void ComponentMigrationHelper::SetComponentActionPref( | 152 void ComponentMigrationHelper::SetComponentActionPref( |
143 const std::string& component_action_id, | 153 const std::string& component_action_id, |
144 bool enabled) { | 154 bool enabled) { |
145 DictionaryPrefUpdate update(pref_service_, | 155 DictionaryPrefUpdate update(pref_service_, |
146 ::prefs::kToolbarMigratedComponentActionStatus); | 156 ::prefs::kToolbarMigratedComponentActionStatus); |
147 update->SetBoolean(component_action_id, enabled); | 157 update->SetBoolean(component_action_id, enabled); |
148 } | 158 } |
149 | 159 |
150 bool ComponentMigrationHelper::IsExtensionInstalledAndEnabled( | 160 bool ComponentMigrationHelper::IsExtensionInstalledAndEnabled( |
151 const ExtensionId& extension_id) const { | 161 const ExtensionId& extension_id) const { |
(...skipping 27 matching lines...) Expand all Loading... | |
179 std::string ComponentMigrationHelper::GetActionIdForExtensionId( | 189 std::string ComponentMigrationHelper::GetActionIdForExtensionId( |
180 const ExtensionId& extension_id) const { | 190 const ExtensionId& extension_id) const { |
181 for (const auto& i : migrated_actions_) { | 191 for (const auto& i : migrated_actions_) { |
182 if (i.second == extension_id) | 192 if (i.second == extension_id) |
183 return i.first; | 193 return i.first; |
184 } | 194 } |
185 return ""; | 195 return ""; |
186 } | 196 } |
187 | 197 |
188 } // namespace extensions | 198 } // namespace extensions |
OLD | NEW |