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

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

Issue 1287913005: Refactor prefs.js for MD-Settings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update after meeting Created 5 years, 4 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_private/settings_private_api.cc
diff --git a/chrome/browser/extensions/api/settings_private/settings_private_api.cc b/chrome/browser/extensions/api/settings_private/settings_private_api.cc
index 33e2b1c93aa56ca77cd3871cab6320b0327d9294..7efb03e7d3ad7294b352fdccb4a2875f0aed5836 100644
--- a/chrome/browser/extensions/api/settings_private/settings_private_api.cc
+++ b/chrome/browser/extensions/api/settings_private/settings_private_api.cc
@@ -29,8 +29,18 @@ ExtensionFunction::ResponseAction SettingsPrivateSetPrefFunction::Run() {
SettingsPrivateDelegate* delegate =
SettingsPrivateDelegateFactory::GetForBrowserContext(browser_context());
- return RespondNow(OneArgument(new base::FundamentalValue(
- delegate->SetPref(parameters->name, parameters->value.get()))));
+ PrefsUtil::SetPrefResult result =
+ delegate->SetPref(parameters->name, parameters->value.get());
+ switch (result) {
+ case PrefsUtil::SUCCESS:
+ return RespondNow(OneArgument(new base::FundamentalValue(true)));
+ case PrefsUtil::PREF_NOT_MODIFIABLE:
+ // Not an error, but return false to indicate setting the pref failed.
+ return RespondNow(OneArgument(new base::FundamentalValue(false)));
+ default:
+ // Indicates a problem with the function call.
+ return RespondNow(Error("Error setting pref *", parameters->name));
stevenjb 2015/08/26 17:32:18 Since we went to the trouble to define the differe
michaelpg 2015/08/26 23:32:15 Done.
+ }
}

Powered by Google App Engine
This is Rietveld 408576698