Chromium Code Reviews| 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 |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..6c05e8d3d35238c4ccda4b59e37fb1f0d64d3af3 |
| --- /dev/null |
| +++ b/chrome/browser/extensions/api/settings_private/settings_private_api.cc |
| @@ -0,0 +1,131 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/extensions/api/settings_private/settings_private_api.h" |
| + |
| +#include "base/values.h" |
| +#include "chrome/common/extensions/api/settings_private.h" |
| +#include "extensions/browser/extension_function_registry.h" |
| + |
| +namespace extensions { |
| + |
| +//////////////////////////////////////////////////////////////////////////////// |
| +// SettingsPrivateSetBooleanPrefFunction |
| + |
| +SettingsPrivateSetBooleanPrefFunction:: |
| + ~SettingsPrivateSetBooleanPrefFunction() { |
| +} |
| + |
| +ExtensionFunction::ResponseAction SettingsPrivateSetBooleanPrefFunction::Run() { |
| + scoped_ptr<api::settings_private::SetBooleanPref::Params> parameters = |
| + api::settings_private::SetBooleanPref::Params::Create(*args_); |
| + EXTENSION_FUNCTION_VALIDATE(parameters.get()); |
| + VLOG(1) << "chrome.settingsPrivate.setBooleanPref(" << parameters->name |
| + << ", " << (!!parameters->value ? "true" : "false") << ")"; |
|
stevenjb
2015/03/23 17:51:29
nit: parameters->value should just serialize, i.e.
Oren Blasberg
2015/03/23 20:20:11
I tried that first, and that makes it print 0 or 1
|
| + |
| + // TODO(orenb): Implement with a real check and not just true. |
| + VLOG(1) << "chrome.settingsPrivate.setBooleanPref is not yet implemented."; |
|
stevenjb
2015/03/23 17:51:29
nit: I don't think we need these extra VLOGs now.
Oren Blasberg
2015/03/23 20:20:11
Done.
|
| + base::FundamentalValue* value = new base::FundamentalValue(true); |
|
stevenjb
2015/03/23 17:51:29
nit: No need for a temporary here, could just inli
Oren Blasberg
2015/03/23 20:20:11
Done.
|
| + return RespondNow(OneArgument(value)); |
| +} |
| + |
| +//////////////////////////////////////////////////////////////////////////////// |
| +// SettingsPrivateSetNumericPrefFunction |
| + |
| +SettingsPrivateSetNumericPrefFunction:: |
| + ~SettingsPrivateSetNumericPrefFunction() { |
| +} |
| + |
| +ExtensionFunction::ResponseAction SettingsPrivateSetNumericPrefFunction::Run() { |
| + scoped_ptr<api::settings_private::SetNumericPref::Params> parameters = |
| + api::settings_private::SetNumericPref::Params::Create(*args_); |
| + EXTENSION_FUNCTION_VALIDATE(parameters.get()); |
| + VLOG(1) << "chrome.settingsPrivate.setNumericPref(" << parameters->name |
| + << ", " << parameters->value << ")"; |
| + |
| + // TODO(orenb): Implement with a real check and not just true. |
| + VLOG(1) << "chrome.settingsPrivate.setNumericPref is not yet implemented."; |
| + base::FundamentalValue* value = new base::FundamentalValue(true); |
| + return RespondNow(OneArgument(value)); |
| +} |
| + |
| +//////////////////////////////////////////////////////////////////////////////// |
| +// SettingsPrivateSetStringPrefFunction |
| + |
| +SettingsPrivateSetStringPrefFunction:: |
| + ~SettingsPrivateSetStringPrefFunction() { |
| +} |
| + |
| +ExtensionFunction::ResponseAction SettingsPrivateSetStringPrefFunction::Run() { |
| + scoped_ptr<api::settings_private::SetStringPref::Params> parameters = |
| + api::settings_private::SetStringPref::Params::Create(*args_); |
| + EXTENSION_FUNCTION_VALIDATE(parameters.get()); |
| + VLOG(1) << "chrome.settingsPrivate.setStringPref(" << parameters->name |
| + << ", " << parameters->value << ")"; |
| + |
| + // TODO(orenb): Implement with a real check and not just true. |
| + VLOG(1) << "chrome.settingsPrivate.setStringPref is not yet implemented."; |
| + base::FundamentalValue* value = new base::FundamentalValue(true); |
| + return RespondNow(OneArgument(value)); |
| +} |
| + |
| +//////////////////////////////////////////////////////////////////////////////// |
| +// SettingsPrivateSetURLPrefFunction |
| + |
| +SettingsPrivateSetURLPrefFunction:: |
| + ~SettingsPrivateSetURLPrefFunction() { |
| +} |
| + |
| +ExtensionFunction::ResponseAction SettingsPrivateSetURLPrefFunction::Run() { |
| + scoped_ptr<api::settings_private::SetURLPref::Params> parameters = |
| + api::settings_private::SetURLPref::Params::Create(*args_); |
| + EXTENSION_FUNCTION_VALIDATE(parameters.get()); |
| + VLOG(1) << "chrome.settingsPrivate.setURLPref(" << parameters->name |
| + << ", " << parameters->value << ")"; |
| + |
| + // TODO(orenb): Implement with a real check and not just true. |
| + VLOG(1) << "chrome.settingsPrivate.setURLPref is not yet implemented."; |
| + base::FundamentalValue* value = new base::FundamentalValue(true); |
| + return RespondNow(OneArgument(value)); |
| +} |
| + |
| +//////////////////////////////////////////////////////////////////////////////// |
| +// SettingsPrivateGetAllPrefsFunction |
| + |
| +SettingsPrivateGetAllPrefsFunction::~SettingsPrivateGetAllPrefsFunction() { |
| +} |
| + |
| +ExtensionFunction::ResponseAction SettingsPrivateGetAllPrefsFunction::Run() { |
| + // TODO(orenb): Implement with real prefs. |
| + VLOG(1) << "chrome.settingsPrivate.getAllPrefs is not yet implemented."; |
| + base::ListValue* value = new base::ListValue(); |
| + return RespondNow(OneArgument(value)); |
| +} |
| + |
| +//////////////////////////////////////////////////////////////////////////////// |
| +// SettingsPrivateGetPrefFunction |
| + |
| +SettingsPrivateGetPrefFunction::~SettingsPrivateGetPrefFunction() { |
| +} |
| + |
| +ExtensionFunction::ResponseAction SettingsPrivateGetPrefFunction::Run() { |
| + scoped_ptr<api::settings_private::GetPref::Params> parameters = |
| + api::settings_private::GetPref::Params::Create(*args_); |
| + EXTENSION_FUNCTION_VALIDATE(parameters.get()); |
| + VLOG(1) << "chrome.settingsPrivate.getPref(" << parameters->name << ")"; |
| + |
| + // TODO(orenb): Implement with real pref. |
| + VLOG(1) << "chrome.settingsPrivate.getPref is not yet implemented."; |
| + |
| + api::settings_private::PrefObject* prefObject = |
| + new api::settings_private::PrefObject(); |
| + |
| + prefObject->type = api::settings_private::PrefType::PREF_TYPE_BOOLEAN; |
| + prefObject->value.reset(new base::FundamentalValue(true)); |
| + prefObject->source = api::settings_private::PrefSource::PREF_SOURCE_USER; |
| + |
| + return RespondNow(OneArgument(prefObject->ToValue().release())); |
| +} |
| + |
| +} // namespace extensions |