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

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: more rework 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 if (!json_schema_compiler::util::GetOptionalArrayFromDictionary(*dict, "tabs", &out->tabs))
32 return false;
33 if (!dict->GetInteger("top", &out->top))
34 return false;
35 if (!dict->GetInteger("height", &out->height))
36 return false;
37 if (!dict->GetInteger("width", &out->width))
38 return false;
39 if (!dict->GetString("state", &out->state))
40 return false;
41 if (!dict->GetBoolean("focused", &out->focused))
42 return false;
43 if (!dict->GetInteger("left", &out->left))
44 return false;
45 if (!dict->GetString("type", &out->type))
46 return false;
47 if (!dict->GetInteger("id", &out->id))
48 return false;
49 if (!dict->GetBoolean("incognito", &out->incognito))
50 return false;
51 return true;
52 }
53
54 DictionaryValue* Window::ToValue() const {
55 DictionaryValue* value = new DictionaryValue();
56
57 if (tabs.get())
58 json_schema_compiler::util::SetOptionalArrayToDictionary(tabs, "tabs", value );
59 value->SetWithoutPathExpansion("top", Value::CreateIntegerValue(top));
60 value->SetWithoutPathExpansion("height", Value::CreateIntegerValue(height));
61 value->SetWithoutPathExpansion("width", Value::CreateIntegerValue(width));
62 value->SetWithoutPathExpansion("state", Value::CreateStringValue(state));
63 value->SetWithoutPathExpansion("focused", Value::CreateBooleanValue(focused));
64 value->SetWithoutPathExpansion("left", Value::CreateIntegerValue(left));
65 value->SetWithoutPathExpansion("type", Value::CreateStringValue(type));
66 value->SetWithoutPathExpansion("id", Value::CreateIntegerValue(id));
67 value->SetWithoutPathExpansion("incognito", Value::CreateBooleanValue(incognit o));
68
69 return value;
70 }
71
72
73 //
74 // Functions
75 //
76
77 Get::Params::GetInfo::GetInfo() {}
78 Get::Params::GetInfo::~GetInfo() {}
79
80 // static
81 bool Get::Params::GetInfo::Populate(const Value& value, GetInfo* out) {
82 if (!value.IsType(Value::TYPE_DICTIONARY))
83 return false;
84 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value);
85
86 {
87 bool populate_temp;
88 if (dict->GetBoolean("populate", &populate_temp))
89 out->populate.reset(new bool(populate_temp));
90 }
91 return true;
92 }
93
94
95
96 Get::Params::Params() {}
97 Get::Params::~Params() {}
98
99 // static
100 scoped_ptr<Get::Params> Get::Params::Create(const ListValue& args) {
101 if (args.GetSize() < 1 || args.GetSize() > 2)
102 return scoped_ptr<Params>();
103 scoped_ptr<Params> params(new Params());
104
105 if (!args.GetInteger(0, &params->window_id))
106 return scoped_ptr<Params>();
107
108 DictionaryValue* get_info_param = NULL;
109 if (!args.GetDictionary(1, &get_info_param))
110 return params.Pass();
111 params->get_info.reset(new GetInfo());
112 if (!GetInfo::Populate(*get_info_param, params->get_info.get()))
113 return params.Pass();
114
115 return params.Pass();
116 }
117
118 // static
119 Value* Get::Result::Create(const Window& window) {
120 return window.ToValue();
121 }
122
123 GetCurrent::Params::GetInfo::GetInfo() {}
124 GetCurrent::Params::GetInfo::~GetInfo() {}
125
126 // static
127 bool GetCurrent::Params::GetInfo::Populate(const Value& value, GetInfo* out) {
128 if (!value.IsType(Value::TYPE_DICTIONARY))
129 return false;
130 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value);
131
132 {
133 bool populate_temp;
134 if (dict->GetBoolean("populate", &populate_temp))
135 out->populate.reset(new bool(populate_temp));
136 }
137 return true;
138 }
139
140
141
142 GetCurrent::Params::Params() {}
143 GetCurrent::Params::~Params() {}
144
145 // static
146 scoped_ptr<GetCurrent::Params> GetCurrent::Params::Create(const ListValue& args) {
147 if (args.GetSize() > 1)
148 return scoped_ptr<Params>();
149 scoped_ptr<Params> params(new Params());
150
151 DictionaryValue* get_info_param = NULL;
152 if (!args.GetDictionary(0, &get_info_param))
153 return params.Pass();
154 params->get_info.reset(new GetInfo());
155 if (!GetInfo::Populate(*get_info_param, params->get_info.get()))
156 return params.Pass();
157
158 return params.Pass();
159 }
160
161 // static
162 Value* GetCurrent::Result::Create(const Window& window) {
163 return window.ToValue();
164 }
165
166 Create::Params::CreateData::CreateData() {}
167 Create::Params::CreateData::~CreateData() {}
168
169 // static
170 bool Create::Params::CreateData::Populate(const Value& value, CreateData* out) {
171 if (!value.IsType(Value::TYPE_DICTIONARY))
172 return false;
173 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value);
174
175 {
176 int tab_id_temp;
177 if (dict->GetInteger("tabId", &tab_id_temp))
178 out->tab_id.reset(new int(tab_id_temp));
179 }
180 {
181 std::string url_temp;
182 if (dict->GetString("url", &url_temp))
183 out->url.reset(new std::string(url_temp));
184 }
185 {
186 int top_temp;
187 if (dict->GetInteger("top", &top_temp))
188 out->top.reset(new int(top_temp));
189 }
190 {
191 int height_temp;
192 if (dict->GetInteger("height", &height_temp))
193 out->height.reset(new int(height_temp));
194 }
195 {
196 int width_temp;
197 if (dict->GetInteger("width", &width_temp))
198 out->width.reset(new int(width_temp));
199 }
200 {
201 bool focused_temp;
202 if (dict->GetBoolean("focused", &focused_temp))
203 out->focused.reset(new bool(focused_temp));
204 }
205 {
206 int left_temp;
207 if (dict->GetInteger("left", &left_temp))
208 out->left.reset(new int(left_temp));
209 }
210 {
211 std::string type_temp;
212 if (dict->GetString("type", &type_temp))
213 out->type.reset(new std::string(type_temp));
214 }
215 {
216 bool incognito_temp;
217 if (dict->GetBoolean("incognito", &incognito_temp))
218 out->incognito.reset(new bool(incognito_temp));
219 }
220 return true;
221 }
222
223
224
225 Create::Params::Params() {}
226 Create::Params::~Params() {}
227
228 // static
229 scoped_ptr<Create::Params> Create::Params::Create(const ListValue& args) {
230 if (args.GetSize() > 1)
231 return scoped_ptr<Params>();
232 scoped_ptr<Params> params(new Params());
233
234 DictionaryValue* create_data_param = NULL;
235 if (!args.GetDictionary(0, &create_data_param))
236 return params.Pass();
237 params->create_data.reset(new CreateData());
238 if (!CreateData::Populate(*create_data_param, params->create_data.get()))
239 return params.Pass();
240
241 return params.Pass();
242 }
243
244 // static
245 // Contains details about the created window.
246 Value* Create::Result::Create(const scoped_ptr<Window>& window) {
247 return window->ToValue();
248 }
249
250 GetAll::Params::GetInfo::GetInfo() {}
251 GetAll::Params::GetInfo::~GetInfo() {}
252
253 // static
254 bool GetAll::Params::GetInfo::Populate(const Value& value, GetInfo* out) {
255 if (!value.IsType(Value::TYPE_DICTIONARY))
256 return false;
257 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value);
258
259 {
260 bool populate_temp;
261 if (dict->GetBoolean("populate", &populate_temp))
262 out->populate.reset(new bool(populate_temp));
263 }
264 return true;
265 }
266
267
268
269 GetAll::Params::Params() {}
270 GetAll::Params::~Params() {}
271
272 // static
273 scoped_ptr<GetAll::Params> GetAll::Params::Create(const ListValue& args) {
274 if (args.GetSize() > 1)
275 return scoped_ptr<Params>();
276 scoped_ptr<Params> params(new Params());
277
278 DictionaryValue* get_info_param = NULL;
279 if (!args.GetDictionary(0, &get_info_param))
280 return params.Pass();
281 params->get_info.reset(new GetInfo());
282 if (!GetInfo::Populate(*get_info_param, params->get_info.get()))
283 return params.Pass();
284
285 return params.Pass();
286 }
287
288 // static
289 Value* GetAll::Result::Create(const std::vector<linked_ptr<Window> > windows) {
290 ListValue* value = new ListValue();
291 json_schema_compiler::util::SetArrayToList(windows, value);
292 return value;
293 }
294
295 Update::Params::UpdateInfo::UpdateInfo() {}
296 Update::Params::UpdateInfo::~UpdateInfo() {}
297
298 // static
299 bool Update::Params::UpdateInfo::Populate(const Value& value, UpdateInfo* out) {
300 if (!value.IsType(Value::TYPE_DICTIONARY))
301 return false;
302 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value);
303
304 {
305 int top_temp;
306 if (dict->GetInteger("top", &top_temp))
307 out->top.reset(new int(top_temp));
308 }
309 {
310 bool draw_attention_temp;
311 if (dict->GetBoolean("drawAttention", &draw_attention_temp))
312 out->draw_attention.reset(new bool(draw_attention_temp));
313 }
314 {
315 int height_temp;
316 if (dict->GetInteger("height", &height_temp))
317 out->height.reset(new int(height_temp));
318 }
319 {
320 int width_temp;
321 if (dict->GetInteger("width", &width_temp))
322 out->width.reset(new int(width_temp));
323 }
324 {
325 std::string state_temp;
326 if (dict->GetString("state", &state_temp))
327 out->state.reset(new std::string(state_temp));
328 }
329 {
330 bool focused_temp;
331 if (dict->GetBoolean("focused", &focused_temp))
332 out->focused.reset(new bool(focused_temp));
333 }
334 {
335 int left_temp;
336 if (dict->GetInteger("left", &left_temp))
337 out->left.reset(new int(left_temp));
338 }
339 return true;
340 }
341
342
343
344 Update::Params::Params() {}
345 Update::Params::~Params() {}
346
347 // static
348 scoped_ptr<Update::Params> Update::Params::Create(const ListValue& args) {
349 if (args.GetSize() != 2)
350 return scoped_ptr<Params>();
351 scoped_ptr<Params> params(new Params());
352
353 if (!args.GetInteger(0, &params->window_id))
354 return scoped_ptr<Params>();
355
356 DictionaryValue* update_info_param = NULL;
357 if (!args.GetDictionary(1, &update_info_param))
358 return scoped_ptr<Params>();
359 if (!UpdateInfo::Populate(*update_info_param, &params->update_info))
360 return scoped_ptr<Params>();
361
362 return params.Pass();
363 }
364
365 // static
366 Value* Update::Result::Create(const Window& window) {
367 return window.ToValue();
368 }
369
370 Remove::Params::Params() {}
371 Remove::Params::~Params() {}
372
373 // static
374 scoped_ptr<Remove::Params> Remove::Params::Create(const ListValue& args) {
375 if (args.GetSize() != 1)
376 return scoped_ptr<Params>();
377 scoped_ptr<Params> params(new Params());
378
379 if (!args.GetInteger(0, &params->window_id))
380 return scoped_ptr<Params>();
381
382 return params.Pass();
383 }
384
385 // static
386 Value* Remove::Result::Create() {
387 return Value::CreateNullValue();
388 }
389
390 GetLastFocused::Params::GetInfo::GetInfo() {}
391 GetLastFocused::Params::GetInfo::~GetInfo() {}
392
393 // static
394 bool GetLastFocused::Params::GetInfo::Populate(const Value& value, GetInfo* out) {
395 if (!value.IsType(Value::TYPE_DICTIONARY))
396 return false;
397 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value);
398
399 {
400 bool populate_temp;
401 if (dict->GetBoolean("populate", &populate_temp))
402 out->populate.reset(new bool(populate_temp));
403 }
404 return true;
405 }
406
407
408
409 GetLastFocused::Params::Params() {}
410 GetLastFocused::Params::~Params() {}
411
412 // static
413 scoped_ptr<GetLastFocused::Params> GetLastFocused::Params::Create(const ListValu e& args) {
414 if (args.GetSize() > 1)
415 return scoped_ptr<Params>();
416 scoped_ptr<Params> params(new Params());
417
418 DictionaryValue* get_info_param = NULL;
419 if (!args.GetDictionary(0, &get_info_param))
420 return params.Pass();
421 params->get_info.reset(new GetInfo());
422 if (!GetInfo::Populate(*get_info_param, params->get_info.get()))
423 return params.Pass();
424
425 return params.Pass();
426 }
427
428 // static
429 Value* GetLastFocused::Result::Create(const Window& window) {
430 return window.ToValue();
431 }
432
433 } // windows
434 } // api
435 } // extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698