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

Unified Diff: chrome/browser/extensions/api/settings_overrides/settings_overrides_api.cc

Issue 219593002: Add unit test for the Settings API Bubble. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix test Created 6 years, 9 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
Index: chrome/browser/extensions/api/settings_overrides/settings_overrides_api.cc
diff --git a/chrome/browser/extensions/api/settings_overrides/settings_overrides_api.cc b/chrome/browser/extensions/api/settings_overrides/settings_overrides_api.cc
index 73a3d60a275766346683ad356a8fb29b1db8766d..fe310902c66b0ac84178b11c22f0ebfa097aa5a5 100644
--- a/chrome/browser/extensions/api/settings_overrides/settings_overrides_api.cc
+++ b/chrome/browser/extensions/api/settings_overrides/settings_overrides_api.cc
@@ -111,16 +111,21 @@ SettingsOverridesAPI::GetFactoryInstance() {
void SettingsOverridesAPI::SetPref(const std::string& extension_id,
const std::string& pref_key,
base::Value* value) {
- PreferenceAPI::Get(profile_)->SetExtensionControlledPref(
- extension_id,
- pref_key,
- kExtensionPrefsScopeRegular,
- value);
+ PreferenceAPI* prefs = PreferenceAPI::Get(profile_);
+ if (!prefs)
+ return; // Expected in unit tests.
+ prefs->SetExtensionControlledPref(extension_id,
+ pref_key,
+ kExtensionPrefsScopeRegular,
+ value);
}
void SettingsOverridesAPI::UnsetPref(const std::string& extension_id,
const std::string& pref_key) {
- PreferenceAPI::Get(profile_)->RemoveExtensionControlledPref(
+ PreferenceAPI* prefs = PreferenceAPI::Get(profile_);
+ if (!prefs)
+ return; // Expected in unit tests.
+ prefs->RemoveExtensionControlledPref(
extension_id,
pref_key,
kExtensionPrefsScopeRegular);

Powered by Google App Engine
This is Rietveld 408576698