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

Side by Side Diff: chrome/browser/extensions/api/settings_private/settings_private_api.cc

Issue 1015623005: chrome.settingsPrivate: Basic stub implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Extracting and logging the parameters Created 5 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 unified diff | Download patch
OLDNEW
(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") << ")";
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
26
27 // TODO(orenb): Implement with a real check and not just true.
28 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.
29 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.
30 return RespondNow(OneArgument(value));
31 }
32
33 ////////////////////////////////////////////////////////////////////////////////
34 // SettingsPrivateSetNumericPrefFunction
35
36 SettingsPrivateSetNumericPrefFunction::
37 ~SettingsPrivateSetNumericPrefFunction() {
38 }
39
40 ExtensionFunction::ResponseAction SettingsPrivateSetNumericPrefFunction::Run() {
41 scoped_ptr<api::settings_private::SetNumericPref::Params> parameters =
42 api::settings_private::SetNumericPref::Params::Create(*args_);
43 EXTENSION_FUNCTION_VALIDATE(parameters.get());
44 VLOG(1) << "chrome.settingsPrivate.setNumericPref(" << parameters->name
45 << ", " << parameters->value << ")";
46
47 // TODO(orenb): Implement with a real check and not just true.
48 VLOG(1) << "chrome.settingsPrivate.setNumericPref is not yet implemented.";
49 base::FundamentalValue* value = new base::FundamentalValue(true);
50 return RespondNow(OneArgument(value));
51 }
52
53 ////////////////////////////////////////////////////////////////////////////////
54 // SettingsPrivateSetStringPrefFunction
55
56 SettingsPrivateSetStringPrefFunction::
57 ~SettingsPrivateSetStringPrefFunction() {
58 }
59
60 ExtensionFunction::ResponseAction SettingsPrivateSetStringPrefFunction::Run() {
61 scoped_ptr<api::settings_private::SetStringPref::Params> parameters =
62 api::settings_private::SetStringPref::Params::Create(*args_);
63 EXTENSION_FUNCTION_VALIDATE(parameters.get());
64 VLOG(1) << "chrome.settingsPrivate.setStringPref(" << parameters->name
65 << ", " << parameters->value << ")";
66
67 // TODO(orenb): Implement with a real check and not just true.
68 VLOG(1) << "chrome.settingsPrivate.setStringPref is not yet implemented.";
69 base::FundamentalValue* value = new base::FundamentalValue(true);
70 return RespondNow(OneArgument(value));
71 }
72
73 ////////////////////////////////////////////////////////////////////////////////
74 // SettingsPrivateSetURLPrefFunction
75
76 SettingsPrivateSetURLPrefFunction::
77 ~SettingsPrivateSetURLPrefFunction() {
78 }
79
80 ExtensionFunction::ResponseAction SettingsPrivateSetURLPrefFunction::Run() {
81 scoped_ptr<api::settings_private::SetURLPref::Params> parameters =
82 api::settings_private::SetURLPref::Params::Create(*args_);
83 EXTENSION_FUNCTION_VALIDATE(parameters.get());
84 VLOG(1) << "chrome.settingsPrivate.setURLPref(" << parameters->name
85 << ", " << parameters->value << ")";
86
87 // TODO(orenb): Implement with a real check and not just true.
88 VLOG(1) << "chrome.settingsPrivate.setURLPref is not yet implemented.";
89 base::FundamentalValue* value = new base::FundamentalValue(true);
90 return RespondNow(OneArgument(value));
91 }
92
93 ////////////////////////////////////////////////////////////////////////////////
94 // SettingsPrivateGetAllPrefsFunction
95
96 SettingsPrivateGetAllPrefsFunction::~SettingsPrivateGetAllPrefsFunction() {
97 }
98
99 ExtensionFunction::ResponseAction SettingsPrivateGetAllPrefsFunction::Run() {
100 // TODO(orenb): Implement with real prefs.
101 VLOG(1) << "chrome.settingsPrivate.getAllPrefs is not yet implemented.";
102 base::ListValue* value = new base::ListValue();
103 return RespondNow(OneArgument(value));
104 }
105
106 ////////////////////////////////////////////////////////////////////////////////
107 // SettingsPrivateGetPrefFunction
108
109 SettingsPrivateGetPrefFunction::~SettingsPrivateGetPrefFunction() {
110 }
111
112 ExtensionFunction::ResponseAction SettingsPrivateGetPrefFunction::Run() {
113 scoped_ptr<api::settings_private::GetPref::Params> parameters =
114 api::settings_private::GetPref::Params::Create(*args_);
115 EXTENSION_FUNCTION_VALIDATE(parameters.get());
116 VLOG(1) << "chrome.settingsPrivate.getPref(" << parameters->name << ")";
117
118 // TODO(orenb): Implement with real pref.
119 VLOG(1) << "chrome.settingsPrivate.getPref is not yet implemented.";
120
121 api::settings_private::PrefObject* prefObject =
122 new api::settings_private::PrefObject();
123
124 prefObject->type = api::settings_private::PrefType::PREF_TYPE_BOOLEAN;
125 prefObject->value.reset(new base::FundamentalValue(true));
126 prefObject->source = api::settings_private::PrefSource::PREF_SOURCE_USER;
127
128 return RespondNow(OneArgument(prefObject->ToValue().release()));
129 }
130
131 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698