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

Unified Diff: chrome/browser/extensions/component_migration_helper.cc

Issue 2294973002: Create MediaRouterActionController and MediaRouterUIService (Closed)
Patch Set: Modify BUILD.gn files, rebase Created 4 years, 3 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/component_migration_helper.h ('k') | chrome/browser/media/router/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « chrome/browser/extensions/component_migration_helper.h ('k') | chrome/browser/media/router/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698