Index: chrome/browser/extensions/component_migration_helper.cc |
diff --git a/chrome/browser/extensions/component_migration_helper.cc b/chrome/browser/extensions/component_migration_helper.cc |
index 7de2caa9773e3e49033483107317284b888d23b4..aa7242f20651b664a43cb0c9e9b3f93387071ffc 100644 |
--- a/chrome/browser/extensions/component_migration_helper.cc |
+++ b/chrome/browser/extensions/component_migration_helper.cc |
@@ -79,15 +79,10 @@ void ComponentMigrationHelper::OnFeatureEnabled( |
// true if we unloaded an extension. |
const base::DictionaryValue* migration_pref = pref_service_->GetDictionary( |
::prefs::kToolbarMigratedComponentActionStatus); |
- bool has_component_action_pref = migration_pref->HasKey(component_action_id); |
bool component_action_pref = false; |
- if (has_component_action_pref) { |
- bool success = |
- migration_pref->GetBoolean(component_action_id, &component_action_pref); |
- DCHECK(success); // Shouldn't fail, but can in case of pref corruption. |
- } |
- |
- if (!has_component_action_pref && extension_was_installed) { |
+ if (migration_pref->HasKey(component_action_id)) { |
+ component_action_pref = GetComponentActionPref(component_action_id); |
+ } else if (extension_was_installed) { |
SetComponentActionPref(component_action_id, true); |
component_action_pref = true; |
} |
@@ -139,6 +134,18 @@ void ComponentMigrationHelper::OnExtensionReady( |
} |
} |
+bool ComponentMigrationHelper::GetComponentActionPref( |
+ const std::string& component_action_id) const { |
+ const base::DictionaryValue* migration_pref = pref_service_->GetDictionary( |
+ ::prefs::kToolbarMigratedComponentActionStatus); |
+ bool component_action_pref = false; |
+ |
+ // If the entry for |component_action_id| doesn't exist, GetBoolean() does not |
+ // modify |component_action_pref|. |
+ migration_pref->GetBoolean(component_action_id, &component_action_pref); |
+ return component_action_pref; |
+} |
+ |
void ComponentMigrationHelper::SetComponentActionPref( |
const std::string& component_action_id, |
bool enabled) { |