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

Unified Diff: chrome/browser/extensions/api/settings_private/prefs_util.cc

Issue 2720503007: MD Settings: add more extension controlled pref handling. (Closed)
Patch Set: add early return for empty id. also format. Created 3 years, 10 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/settings_private/prefs_util.cc
diff --git a/chrome/browser/extensions/api/settings_private/prefs_util.cc b/chrome/browser/extensions/api/settings_private/prefs_util.cc
index e32baa11f46eac2beb28f262c0c407389ba09654..a0054d09d88cfd3929da6ff3a8410af0ed440614 100644
--- a/chrome/browser/extensions/api/settings_private/prefs_util.cc
+++ b/chrome/browser/extensions/api/settings_private/prefs_util.cc
@@ -478,6 +478,7 @@ std::unique_ptr<settings_private::PrefObject> PrefsUtil::GetPref(
#endif
const Extension* extension = GetExtensionControllingPref(*pref_object);
+
if (extension) {
pref_object->controlled_by =
settings_private::ControlledBy::CONTROLLED_BY_EXTENSION;
@@ -738,7 +739,15 @@ const Extension* PrefsUtil::GetExtensionControllingPref(
if (pref_object.key == proxy_config::prefs::kProxy)
return GetExtensionOverridingProxy(profile_);
- return nullptr;
+ // If it's none of the above, attempt a more general strategy.
+ std::string extension_id =
+ ExtensionPrefValueMapFactory::GetForBrowserContext(profile_)
+ ->GetExtensionControllingPref(pref_object.key);
+ if (extension_id.empty())
+ return nullptr;
+
+ return ExtensionRegistry::Get(profile_)->GetExtensionById(
+ extension_id, ExtensionRegistry::ENABLED);
}
} // namespace extensions
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698