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

Side by Side Diff: generated_files_will_not_submit/windows.cc

Issue 9309044: Supporting more APIs with json_schema_compiler (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: fixed optional properties Created 8 years, 10 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 (c) 2012 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 // GENERATED FROM THE API DEFINITION IN
6 // chrome/common/extensions/api/windows.json
7 // DO NOT EDIT.
8
9 #include "tools/json_schema_compiler/util.h"
10 #include "chrome/common/extensions/api/windows.h"
11 #include "chrome/common/extensions/api/tabs.h"
12
13
14 namespace extensions {
15 namespace api {
16 namespace windows {
17
18 //
19 // Types
20 //
21
22 Window::Window() {}
23 Window::~Window() {}
24
25 // static
26 bool Window::Populate(const Value& value, Window* out) {
27 if (!value.IsType(Value::TYPE_DICTIONARY))
28 return false;
29 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value);
30
31 std::vector<linked_ptr<tabs::Tab> > tabs_temp;
32 if(json_schema_compiler::util::GetOptionalArrayFromDictionary(*dict, "tabs", & out->tabs))
33 out->tabs.reset(new std::vector<linked_ptr<tabs::Tab> >(tabs_temp));
34 if(!dict->GetInteger("top", &out->top))
35 return false;
36 if(!dict->GetInteger("height", &out->height))
37 return false;
38 if(!dict->GetInteger("width", &out->width))
39 return false;
40 if(!dict->GetString("state", &out->state))
41 return false;
42 if(!dict->GetBoolean("focused", &out->focused))
43 return false;
44 if(!dict->GetInteger("left", &out->left))
45 return false;
46 if(!dict->GetString("type", &out->type))
47 return false;
48 if(!dict->GetInteger("id", &out->id))
49 return false;
50 if(!dict->GetBoolean("incognito", &out->incognito))
51 return false;
52 return true;
53 }
54
55 DictionaryValue* Window::ToValue() const {
56 DictionaryValue* value = new DictionaryValue();
57
58 if(tabs.get())
59 json_schema_compiler::util::SetOptionalArrayToDictionary(tabs, "tabs", value );
60 value->SetWithoutPathExpansion("top", Value::CreateIntegerValue(top));
61 value->SetWithoutPathExpansion("height", Value::CreateIntegerValue(height));
62 value->SetWithoutPathExpansion("width", Value::CreateIntegerValue(width));
63 value->SetWithoutPathExpansion("state", Value::CreateStringValue(state));
64 value->SetWithoutPathExpansion("focused", Value::CreateBooleanValue(focused));
65 value->SetWithoutPathExpansion("left", Value::CreateIntegerValue(left));
66 value->SetWithoutPathExpansion("type", Value::CreateStringValue(type));
67 value->SetWithoutPathExpansion("id", Value::CreateIntegerValue(id));
68 value->SetWithoutPathExpansion("incognito", Value::CreateBooleanValue(incognit o));
69
70 return value;
71 }
72
73
74 //
75 // Functions
76 //
77
78 Get::Params::GetInfo::GetInfo() {}
79 Get::Params::GetInfo::~GetInfo() {}
80
81 // static
82 bool Get::Params::GetInfo::Populate(const Value& value, GetInfo* out) {
83 if (!value.IsType(Value::TYPE_DICTIONARY))
84 return false;
85 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value);
86
87 bool populate_temp;
88 if(dict->GetBoolean("populate", &populate_temp))
89 out->populate.reset(new bool(populate_temp));
90 return true;
91 }
92
93
94
95 Get::Params::Params() {}
96 Get::Params::~Params() {}
97
98 // static
99 scoped_ptr<Get::Params> Get::Params::Create(const ListValue& args) {
100
101 scoped_ptr<Params> params(new Params());
102
103 if(!args.GetInteger(0, &params->window_id))
104 return scoped_ptr<Params>();
105
106 DictionaryValue* get_info_param = NULL;
107 if (!args.GetDictionary(1, &get_info_param))
108 return params.Pass();
109 params->get_info.reset(new GetInfo());
110 if(!GetInfo::Populate(*get_info_param, params->get_info.get()))
111 return params.Pass();
112
113 return params.Pass();
114 }
115
116 // static
117 Value* Get::Result::Create(const Window& window) {
118 return window.ToValue();
119 }
120
121 GetCurrent::Params::GetInfo::GetInfo() {}
122 GetCurrent::Params::GetInfo::~GetInfo() {}
123
124 // static
125 bool GetCurrent::Params::GetInfo::Populate(const Value& value, GetInfo* out) {
126 if (!value.IsType(Value::TYPE_DICTIONARY))
127 return false;
128 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value);
129
130 bool populate_temp;
131 if(dict->GetBoolean("populate", &populate_temp))
132 out->populate.reset(new bool(populate_temp));
133 return true;
134 }
135
136
137
138 GetCurrent::Params::Params() {}
139 GetCurrent::Params::~Params() {}
140
141 // static
142 scoped_ptr<GetCurrent::Params> GetCurrent::Params::Create(const ListValue& args) {
143
144 scoped_ptr<Params> params(new Params());
145
146 DictionaryValue* get_info_param = NULL;
147 if (!args.GetDictionary(0, &get_info_param))
148 return params.Pass();
149 params->get_info.reset(new GetInfo());
150 if(!GetInfo::Populate(*get_info_param, params->get_info.get()))
151 return params.Pass();
152
153 return params.Pass();
154 }
155
156 // static
157 Value* GetCurrent::Result::Create(const Window& window) {
158 return window.ToValue();
159 }
160
161 Create::Params::CreateData::CreateData() {}
162 Create::Params::CreateData::~CreateData() {}
163
164 // static
165 bool Create::Params::CreateData::Populate(const Value& value, CreateData* out) {
166 if (!value.IsType(Value::TYPE_DICTIONARY))
167 return false;
168 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value);
169
170 int tab_id_temp;
171 if(dict->GetInteger("tabId", &tab_id_temp))
172 out->tab_id.reset(new int(tab_id_temp));
173 if(!json_schema_compiler::util::GetArrayFromDictionary(*dict, "createData", &o ut->create_data_array))
174 return false;
175 int top_temp;
176 if(dict->GetInteger("top", &top_temp))
177 out->top.reset(new int(top_temp));
178 int height_temp;
179 if(dict->GetInteger("height", &height_temp))
180 out->height.reset(new int(height_temp));
181 int width_temp;
182 if(dict->GetInteger("width", &width_temp))
183 out->width.reset(new int(width_temp));
184 bool focused_temp;
185 if(dict->GetBoolean("focused", &focused_temp))
186 out->focused.reset(new bool(focused_temp));
187 int left_temp;
188 if(dict->GetInteger("left", &left_temp))
189 out->left.reset(new int(left_temp));
190 std::string type_temp;
191 if(dict->GetString("type", &type_temp))
192 out->type.reset(new std::string(type_temp));
193 bool incognito_temp;
194 if(dict->GetBoolean("incognito", &incognito_temp))
195 out->incognito.reset(new bool(incognito_temp));
196 return true;
197 }
198
199
200
201 Create::Params::Params() {}
202 Create::Params::~Params() {}
203
204 // static
205 scoped_ptr<Create::Params> Create::Params::Create(const ListValue& args) {
206
207 scoped_ptr<Params> params(new Params());
208
209 DictionaryValue* create_data_param = NULL;
210 if (!args.GetDictionary(0, &create_data_param))
211 return params.Pass();
212 params->create_data.reset(new CreateData());
213 if(!CreateData::Populate(*create_data_param, params->create_data.get()))
214 return params.Pass();
215
216 return params.Pass();
217 }
218
219 // static
220 // Contains details about the created window.
221 Value* Create::Result::Create(const Window& window) {
222 return window.ToValue();
223 }
224
225 GetAll::Params::GetInfo::GetInfo() {}
226 GetAll::Params::GetInfo::~GetInfo() {}
227
228 // static
229 bool GetAll::Params::GetInfo::Populate(const Value& value, GetInfo* out) {
230 if (!value.IsType(Value::TYPE_DICTIONARY))
231 return false;
232 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value);
233
234 bool populate_temp;
235 if(dict->GetBoolean("populate", &populate_temp))
236 out->populate.reset(new bool(populate_temp));
237 return true;
238 }
239
240
241
242 GetAll::Params::Params() {}
243 GetAll::Params::~Params() {}
244
245 // static
246 scoped_ptr<GetAll::Params> GetAll::Params::Create(const ListValue& args) {
247
248 scoped_ptr<Params> params(new Params());
249
250 DictionaryValue* get_info_param = NULL;
251 if (!args.GetDictionary(0, &get_info_param))
252 return params.Pass();
253 params->get_info.reset(new GetInfo());
254 if(!GetInfo::Populate(*get_info_param, params->get_info.get()))
255 return params.Pass();
256
257 return params.Pass();
258 }
259
260 // static
261 Value* GetAll::Result::Create(const std::vector<linked_ptr<Window> > windows) {
262 ListValue* value = new ListValue();
263 json_schema_compiler::util::SetArrayToList(windows, value);
264 return value;
265 }
266
267 Update::Params::UpdateInfo::UpdateInfo() {}
268 Update::Params::UpdateInfo::~UpdateInfo() {}
269
270 // static
271 bool Update::Params::UpdateInfo::Populate(const Value& value, UpdateInfo* out) {
272 if (!value.IsType(Value::TYPE_DICTIONARY))
273 return false;
274 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value);
275
276 int top_temp;
277 if(dict->GetInteger("top", &top_temp))
278 out->top.reset(new int(top_temp));
279 bool draw_attention_temp;
280 if(dict->GetBoolean("drawAttention", &draw_attention_temp))
281 out->draw_attention.reset(new bool(draw_attention_temp));
282 int height_temp;
283 if(dict->GetInteger("height", &height_temp))
284 out->height.reset(new int(height_temp));
285 int width_temp;
286 if(dict->GetInteger("width", &width_temp))
287 out->width.reset(new int(width_temp));
288 std::string state_temp;
289 if(dict->GetString("state", &state_temp))
290 out->state.reset(new std::string(state_temp));
291 bool focused_temp;
292 if(dict->GetBoolean("focused", &focused_temp))
293 out->focused.reset(new bool(focused_temp));
294 int left_temp;
295 if(dict->GetInteger("left", &left_temp))
296 out->left.reset(new int(left_temp));
297 return true;
298 }
299
300
301
302 Update::Params::Params() {}
303 Update::Params::~Params() {}
304
305 // static
306 scoped_ptr<Update::Params> Update::Params::Create(const ListValue& args) {
307
308 scoped_ptr<Params> params(new Params());
309
310 if(!args.GetInteger(0, &params->window_id))
311 return scoped_ptr<Params>();
312
313 DictionaryValue* update_info_param = NULL;
314 if (!args.GetDictionary(1, &update_info_param))
315 return scoped_ptr<Params>();
316 if(!UpdateInfo::Populate(*update_info_param, &params->update_info))
317 return scoped_ptr<Params>();
318
319 return params.Pass();
320 }
321
322 // static
323 Value* Update::Result::Create(const Window& window) {
324 return window.ToValue();
325 }
326
327 Remove::Params::Params() {}
328 Remove::Params::~Params() {}
329
330 // static
331 scoped_ptr<Remove::Params> Remove::Params::Create(const ListValue& args) {
332
333 scoped_ptr<Params> params(new Params());
334
335 if(!args.GetInteger(0, &params->window_id))
336 return scoped_ptr<Params>();
337
338 return params.Pass();
339 }
340
341 // static
342 Value* Remove::Result::Create() {
343 return Value::CreateNullValue();
344 }
345
346 GetLastFocused::Params::GetInfo::GetInfo() {}
347 GetLastFocused::Params::GetInfo::~GetInfo() {}
348
349 // static
350 bool GetLastFocused::Params::GetInfo::Populate(const Value& value, GetInfo* out) {
351 if (!value.IsType(Value::TYPE_DICTIONARY))
352 return false;
353 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value);
354
355 bool populate_temp;
356 if(dict->GetBoolean("populate", &populate_temp))
357 out->populate.reset(new bool(populate_temp));
358 return true;
359 }
360
361
362
363 GetLastFocused::Params::Params() {}
364 GetLastFocused::Params::~Params() {}
365
366 // static
367 scoped_ptr<GetLastFocused::Params> GetLastFocused::Params::Create(const ListValu e& args) {
368
369 scoped_ptr<Params> params(new Params());
370
371 DictionaryValue* get_info_param = NULL;
372 if (!args.GetDictionary(0, &get_info_param))
373 return params.Pass();
374 params->get_info.reset(new GetInfo());
375 if(!GetInfo::Populate(*get_info_param, params->get_info.get()))
376 return params.Pass();
377
378 return params.Pass();
379 }
380
381 // static
382 Value* GetLastFocused::Result::Create(const Window& window) {
383 return window.ToValue();
384 }
385
386 } // windows
387 } // api
388 } // extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698