OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/extensions/api/settings_private/settings_private_api.h" |
| 6 |
| 7 #include "base/values.h" |
| 8 #include "chrome/common/extensions/api/settings_private.h" |
| 9 #include "extensions/browser/extension_function_registry.h" |
| 10 |
| 11 namespace extensions { |
| 12 |
| 13 //////////////////////////////////////////////////////////////////////////////// |
| 14 // SettingsPrivateSetBooleanPrefFunction |
| 15 |
| 16 SettingsPrivateSetBooleanPrefFunction:: |
| 17 ~SettingsPrivateSetBooleanPrefFunction() { |
| 18 } |
| 19 |
| 20 ExtensionFunction::ResponseAction SettingsPrivateSetBooleanPrefFunction::Run() { |
| 21 scoped_ptr<api::settings_private::SetBooleanPref::Params> parameters = |
| 22 api::settings_private::SetBooleanPref::Params::Create(*args_); |
| 23 EXTENSION_FUNCTION_VALIDATE(parameters.get()); |
| 24 VLOG(1) << "chrome.settingsPrivate.setBooleanPref(" << parameters->name |
| 25 << ", " << (!!parameters->value ? "true" : "false") << ")"; |
| 26 |
| 27 // TODO(orenb): Implement with a real check and not just true. |
| 28 return RespondNow(OneArgument(new base::FundamentalValue(true))); |
| 29 } |
| 30 |
| 31 //////////////////////////////////////////////////////////////////////////////// |
| 32 // SettingsPrivateSetNumericPrefFunction |
| 33 |
| 34 SettingsPrivateSetNumericPrefFunction:: |
| 35 ~SettingsPrivateSetNumericPrefFunction() { |
| 36 } |
| 37 |
| 38 ExtensionFunction::ResponseAction SettingsPrivateSetNumericPrefFunction::Run() { |
| 39 scoped_ptr<api::settings_private::SetNumericPref::Params> parameters = |
| 40 api::settings_private::SetNumericPref::Params::Create(*args_); |
| 41 EXTENSION_FUNCTION_VALIDATE(parameters.get()); |
| 42 VLOG(1) << "chrome.settingsPrivate.setNumericPref(" << parameters->name |
| 43 << ", " << parameters->value << ")"; |
| 44 |
| 45 // TODO(orenb): Implement with a real check and not just true. |
| 46 return RespondNow(OneArgument(new base::FundamentalValue(true))); |
| 47 } |
| 48 |
| 49 //////////////////////////////////////////////////////////////////////////////// |
| 50 // SettingsPrivateSetStringPrefFunction |
| 51 |
| 52 SettingsPrivateSetStringPrefFunction:: |
| 53 ~SettingsPrivateSetStringPrefFunction() { |
| 54 } |
| 55 |
| 56 ExtensionFunction::ResponseAction SettingsPrivateSetStringPrefFunction::Run() { |
| 57 scoped_ptr<api::settings_private::SetStringPref::Params> parameters = |
| 58 api::settings_private::SetStringPref::Params::Create(*args_); |
| 59 EXTENSION_FUNCTION_VALIDATE(parameters.get()); |
| 60 VLOG(1) << "chrome.settingsPrivate.setStringPref(" << parameters->name |
| 61 << ", " << parameters->value << ")"; |
| 62 |
| 63 // TODO(orenb): Implement with a real check and not just true. |
| 64 return RespondNow(OneArgument(new base::FundamentalValue(true))); |
| 65 } |
| 66 |
| 67 //////////////////////////////////////////////////////////////////////////////// |
| 68 // SettingsPrivateSetURLPrefFunction |
| 69 |
| 70 SettingsPrivateSetURLPrefFunction:: |
| 71 ~SettingsPrivateSetURLPrefFunction() { |
| 72 } |
| 73 |
| 74 ExtensionFunction::ResponseAction SettingsPrivateSetURLPrefFunction::Run() { |
| 75 scoped_ptr<api::settings_private::SetURLPref::Params> parameters = |
| 76 api::settings_private::SetURLPref::Params::Create(*args_); |
| 77 EXTENSION_FUNCTION_VALIDATE(parameters.get()); |
| 78 VLOG(1) << "chrome.settingsPrivate.setURLPref(" << parameters->name |
| 79 << ", " << parameters->value << ")"; |
| 80 |
| 81 // TODO(orenb): Implement with a real check and not just true. |
| 82 return RespondNow(OneArgument(new base::FundamentalValue(true))); |
| 83 } |
| 84 |
| 85 //////////////////////////////////////////////////////////////////////////////// |
| 86 // SettingsPrivateGetAllPrefsFunction |
| 87 |
| 88 SettingsPrivateGetAllPrefsFunction::~SettingsPrivateGetAllPrefsFunction() { |
| 89 } |
| 90 |
| 91 ExtensionFunction::ResponseAction SettingsPrivateGetAllPrefsFunction::Run() { |
| 92 // TODO(orenb): Implement with real prefs. |
| 93 return RespondNow(OneArgument(new base::FundamentalValue(true))); |
| 94 } |
| 95 |
| 96 //////////////////////////////////////////////////////////////////////////////// |
| 97 // SettingsPrivateGetPrefFunction |
| 98 |
| 99 SettingsPrivateGetPrefFunction::~SettingsPrivateGetPrefFunction() { |
| 100 } |
| 101 |
| 102 ExtensionFunction::ResponseAction SettingsPrivateGetPrefFunction::Run() { |
| 103 scoped_ptr<api::settings_private::GetPref::Params> parameters = |
| 104 api::settings_private::GetPref::Params::Create(*args_); |
| 105 EXTENSION_FUNCTION_VALIDATE(parameters.get()); |
| 106 VLOG(1) << "chrome.settingsPrivate.getPref(" << parameters->name << ")"; |
| 107 |
| 108 // TODO(orenb): Implement with real pref. |
| 109 api::settings_private::PrefObject* prefObject = |
| 110 new api::settings_private::PrefObject(); |
| 111 |
| 112 prefObject->type = api::settings_private::PrefType::PREF_TYPE_BOOLEAN; |
| 113 prefObject->value.reset(new base::FundamentalValue(true)); |
| 114 prefObject->source = api::settings_private::PrefSource::PREF_SOURCE_USER; |
| 115 |
| 116 return RespondNow(OneArgument(prefObject->ToValue().release())); |
| 117 } |
| 118 |
| 119 } // namespace extensions |
OLD | NEW |