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

Side by Side Diff: generated_files_will_not_submit/tabs.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/tabs.json
7 // DO NOT EDIT.
8
9 #include "tools/json_schema_compiler/util.h"
10 #include "chrome/common/extensions/api/tabs.h"
11 #include "chrome/common/extensions/api/windows.h"
12
13
14 namespace extensions {
15 namespace api {
16 namespace tabs {
17
18 //
19 // Types
20 //
21
22 Tab::Tab() {}
23 Tab::~Tab() {}
24
25 // static
26 bool Tab::Populate(const Value& value, Tab* out) {
27 if (!value.IsType(Value::TYPE_DICTIONARY))
28 return false;
29 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value);
30
31 {
32 std::string status_temp;
33 if (dict->GetString("status", &status_temp))
34 out->status.reset(new std::string(status_temp));
35 }
36 if (!dict->GetInteger("index", &out->index))
37 return false;
38 {
39 int opener_tab_id_temp;
40 if (dict->GetInteger("openerTabId", &opener_tab_id_temp))
41 out->opener_tab_id.reset(new int(opener_tab_id_temp));
42 }
43 if (!dict->GetBoolean("pinned", &out->pinned))
44 return false;
45 {
46 std::string title_temp;
47 if (dict->GetString("title", &title_temp))
48 out->title.reset(new std::string(title_temp));
49 }
50 if (!dict->GetString("url", &out->url))
51 return false;
52 if (!dict->GetBoolean("selected", &out->selected))
53 return false;
54 if (!dict->GetBoolean("highlighted", &out->highlighted))
55 return false;
56 if (!dict->GetInteger("windowId", &out->window_id))
57 return false;
58 if (!dict->GetBoolean("active", &out->active))
59 return false;
60 {
61 std::string fav_icon_url_temp;
62 if (dict->GetString("favIconUrl", &fav_icon_url_temp))
63 out->fav_icon_url.reset(new std::string(fav_icon_url_temp));
64 }
65 if (!dict->GetInteger("id", &out->id))
66 return false;
67 if (!dict->GetBoolean("incognito", &out->incognito))
68 return false;
69 return true;
70 }
71
72 DictionaryValue* Tab::ToValue() const {
73 DictionaryValue* value = new DictionaryValue();
74
75 if (status.get())
76 value->SetWithoutPathExpansion("status", Value::CreateStringValue(*status));
77 value->SetWithoutPathExpansion("index", Value::CreateIntegerValue(index));
78 if (opener_tab_id.get())
79 value->SetWithoutPathExpansion("openerTabId", Value::CreateIntegerValue(*ope ner_tab_id));
80 value->SetWithoutPathExpansion("pinned", Value::CreateBooleanValue(pinned));
81 if (title.get())
82 value->SetWithoutPathExpansion("title", Value::CreateStringValue(*title));
83 value->SetWithoutPathExpansion("url", Value::CreateStringValue(url));
84 value->SetWithoutPathExpansion("selected", Value::CreateBooleanValue(selected) );
85 value->SetWithoutPathExpansion("highlighted", Value::CreateBooleanValue(highli ghted));
86 value->SetWithoutPathExpansion("windowId", Value::CreateIntegerValue(window_id ));
87 value->SetWithoutPathExpansion("active", Value::CreateBooleanValue(active));
88 if (fav_icon_url.get())
89 value->SetWithoutPathExpansion("favIconUrl", Value::CreateStringValue(*fav_i con_url));
90 value->SetWithoutPathExpansion("id", Value::CreateIntegerValue(id));
91 value->SetWithoutPathExpansion("incognito", Value::CreateBooleanValue(incognit o));
92
93 return value;
94 }
95
96
97 //
98 // Functions
99 //
100
101 ExecuteScript::Params::Details::Details() {}
102 ExecuteScript::Params::Details::~Details() {}
103
104 // static
105 bool ExecuteScript::Params::Details::Populate(const Value& value, Details* out) {
106 if (!value.IsType(Value::TYPE_DICTIONARY))
107 return false;
108 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value);
109
110 {
111 bool all_frames_temp;
112 if (dict->GetBoolean("allFrames", &all_frames_temp))
113 out->all_frames.reset(new bool(all_frames_temp));
114 }
115 {
116 std::string code_temp;
117 if (dict->GetString("code", &code_temp))
118 out->code.reset(new std::string(code_temp));
119 }
120 {
121 std::string file_temp;
122 if (dict->GetString("file", &file_temp))
123 out->file.reset(new std::string(file_temp));
124 }
125 return true;
126 }
127
128
129
130 ExecuteScript::Params::Params() {}
131 ExecuteScript::Params::~Params() {}
132
133 // static
134 scoped_ptr<ExecuteScript::Params> ExecuteScript::Params::Create(const ListValue& args) {
135 if (args.GetSize() < 1 || args.GetSize() > 2)
136 return scoped_ptr<Params>();
137 scoped_ptr<Params> params(new Params());
138
139 if (!args.GetInteger(0, params->tab_id.get()))
140 return params.Pass();
141
142 DictionaryValue* details_param = NULL;
143 if (!args.GetDictionary(1, &details_param))
144 return scoped_ptr<Params>();
145 if (!Details::Populate(*details_param, &params->details))
146 return scoped_ptr<Params>();
147
148 return params.Pass();
149 }
150
151 // static
152 Value* ExecuteScript::Result::Create() {
153 return Value::CreateNullValue();
154 }
155
156 Get::Params::Params() {}
157 Get::Params::~Params() {}
158
159 // static
160 scoped_ptr<Get::Params> Get::Params::Create(const ListValue& args) {
161 if (args.GetSize() != 1)
162 return scoped_ptr<Params>();
163 scoped_ptr<Params> params(new Params());
164
165 if (!args.GetInteger(0, &params->tab_id))
166 return scoped_ptr<Params>();
167
168 return params.Pass();
169 }
170
171 // static
172 Value* Get::Result::Create(const Tab& tab) {
173 return tab.ToValue();
174 }
175
176 // static
177 Value* GetCurrent::Result::Create(const scoped_ptr<Tab>& tab) {
178 return tab->ToValue();
179 }
180
181 Create::Params::CreateProperties::CreateProperties() {}
182 Create::Params::CreateProperties::~CreateProperties() {}
183
184 // static
185 bool Create::Params::CreateProperties::Populate(const Value& value, CreateProper ties* out) {
186 if (!value.IsType(Value::TYPE_DICTIONARY))
187 return false;
188 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value);
189
190 {
191 int index_temp;
192 if (dict->GetInteger("index", &index_temp))
193 out->index.reset(new int(index_temp));
194 }
195 {
196 int opener_tab_id_temp;
197 if (dict->GetInteger("openerTabId", &opener_tab_id_temp))
198 out->opener_tab_id.reset(new int(opener_tab_id_temp));
199 }
200 {
201 std::string url_temp;
202 if (dict->GetString("url", &url_temp))
203 out->url.reset(new std::string(url_temp));
204 }
205 {
206 bool selected_temp;
207 if (dict->GetBoolean("selected", &selected_temp))
208 out->selected.reset(new bool(selected_temp));
209 }
210 {
211 bool pinned_temp;
212 if (dict->GetBoolean("pinned", &pinned_temp))
213 out->pinned.reset(new bool(pinned_temp));
214 }
215 {
216 int window_id_temp;
217 if (dict->GetInteger("windowId", &window_id_temp))
218 out->window_id.reset(new int(window_id_temp));
219 }
220 {
221 bool active_temp;
222 if (dict->GetBoolean("active", &active_temp))
223 out->active.reset(new bool(active_temp));
224 }
225 return true;
226 }
227
228
229
230 Create::Params::Params() {}
231 Create::Params::~Params() {}
232
233 // static
234 scoped_ptr<Create::Params> Create::Params::Create(const ListValue& args) {
235 if (args.GetSize() != 1)
236 return scoped_ptr<Params>();
237 scoped_ptr<Params> params(new Params());
238
239 DictionaryValue* create_properties_param = NULL;
240 if (!args.GetDictionary(0, &create_properties_param))
241 return scoped_ptr<Params>();
242 if (!CreateProperties::Populate(*create_properties_param, &params->create_prop erties))
243 return scoped_ptr<Params>();
244
245 return params.Pass();
246 }
247
248 // static
249 // Details about the created tab. Will contain the ID of the new tab.
250 Value* Create::Result::Create(const Tab& tab) {
251 return tab.ToValue();
252 }
253
254 Move::Params::MoveProperties::MoveProperties() {}
255 Move::Params::MoveProperties::~MoveProperties() {}
256
257 // static
258 bool Move::Params::MoveProperties::Populate(const Value& value, MoveProperties* out) {
259 if (!value.IsType(Value::TYPE_DICTIONARY))
260 return false;
261 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value);
262
263 if (!dict->GetInteger("index", &out->index))
264 return false;
265 {
266 int window_id_temp;
267 if (dict->GetInteger("windowId", &window_id_temp))
268 out->window_id.reset(new int(window_id_temp));
269 }
270 return true;
271 }
272
273
274
275 Move::Params::Params() {}
276 Move::Params::~Params() {}
277
278 // static
279 scoped_ptr<Move::Params> Move::Params::Create(const ListValue& args) {
280 if (args.GetSize() != 2)
281 return scoped_ptr<Params>();
282 scoped_ptr<Params> params(new Params());
283
284 Value* tab_ids_value = NULL;
285 if (!args.Get(0, &tab_ids_value))
286 return scoped_ptr<Params>();
287
288 params->tab_ids_type = TAB_IDS_NONE;
289 switch (tab_ids_value->GetType()) {
290 case Value::TYPE_INTEGER: {
291 params->tab_ids_type = TAB_IDS_INTEGER;
292 params->tab_ids_integer.reset(new int());
293 if (!tab_ids_value->GetAsInteger(params->tab_ids_integer.get()))
294 return scoped_ptr<Params>();
295 break;
296 }
297 case Value::TYPE_LIST: {
298 params->tab_ids_type = TAB_IDS_ARRAY;
299 if (!json_schema_compiler::util::GetOptionalArrayFromList(*static_cast<Lis tValue*>(tab_ids_value), &params->tab_ids_array))
300 return scoped_ptr<Params>();
301 break;
302 }
303 default:
304 return scoped_ptr<Params>();
305 }
306
307 DictionaryValue* move_properties_param = NULL;
308 if (!args.GetDictionary(1, &move_properties_param))
309 return scoped_ptr<Params>();
310 if (!MoveProperties::Populate(*move_properties_param, &params->move_properties ))
311 return scoped_ptr<Params>();
312
313 return params.Pass();
314 }
315
316 // static
317 Value* Move::Result::Create(const scoped_ptr<Tab>& tabs_ref) {
318 return tabs_ref->ToValue();
319 }
320 Value* Move::Result::Create(const scoped_ptr<std::vector<linked_ptr<Tab> > > tab s_array) {
321 ListValue* value = new ListValue();
322 json_schema_compiler::util::SetOptionalArrayToList(tabs_array, value);
323 return value;
324 }
325
326 Update::Params::UpdateProperties::UpdateProperties() {}
327 Update::Params::UpdateProperties::~UpdateProperties() {}
328
329 // static
330 bool Update::Params::UpdateProperties::Populate(const Value& value, UpdateProper ties* out) {
331 if (!value.IsType(Value::TYPE_DICTIONARY))
332 return false;
333 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value);
334
335 {
336 bool highlighted_temp;
337 if (dict->GetBoolean("highlighted", &highlighted_temp))
338 out->highlighted.reset(new bool(highlighted_temp));
339 }
340 {
341 int opener_tab_id_temp;
342 if (dict->GetInteger("openerTabId", &opener_tab_id_temp))
343 out->opener_tab_id.reset(new int(opener_tab_id_temp));
344 }
345 {
346 std::string url_temp;
347 if (dict->GetString("url", &url_temp))
348 out->url.reset(new std::string(url_temp));
349 }
350 {
351 bool selected_temp;
352 if (dict->GetBoolean("selected", &selected_temp))
353 out->selected.reset(new bool(selected_temp));
354 }
355 {
356 bool pinned_temp;
357 if (dict->GetBoolean("pinned", &pinned_temp))
358 out->pinned.reset(new bool(pinned_temp));
359 }
360 {
361 bool active_temp;
362 if (dict->GetBoolean("active", &active_temp))
363 out->active.reset(new bool(active_temp));
364 }
365 return true;
366 }
367
368
369
370 Update::Params::Params() {}
371 Update::Params::~Params() {}
372
373 // static
374 scoped_ptr<Update::Params> Update::Params::Create(const ListValue& args) {
375 if (args.GetSize() < 1 || args.GetSize() > 2)
376 return scoped_ptr<Params>();
377 scoped_ptr<Params> params(new Params());
378
379 if (!args.GetInteger(0, params->tab_id.get()))
380 return params.Pass();
381
382 DictionaryValue* update_properties_param = NULL;
383 if (!args.GetDictionary(1, &update_properties_param))
384 return scoped_ptr<Params>();
385 if (!UpdateProperties::Populate(*update_properties_param, &params->update_prop erties))
386 return scoped_ptr<Params>();
387
388 return params.Pass();
389 }
390
391 // static
392 // Details about the updated tab, or <code>null</code> if the 'tabs' permission
393 // has not been requested.
394 Value* Update::Result::Create(const scoped_ptr<Tab>& tab) {
395 return tab->ToValue();
396 }
397
398 Remove::Params::Params() {}
399 Remove::Params::~Params() {}
400
401 // static
402 scoped_ptr<Remove::Params> Remove::Params::Create(const ListValue& args) {
403 if (args.GetSize() != 1)
404 return scoped_ptr<Params>();
405 scoped_ptr<Params> params(new Params());
406
407 Value* tab_ids_value = NULL;
408 if (!args.Get(0, &tab_ids_value))
409 return scoped_ptr<Params>();
410
411 params->tab_ids_type = TAB_IDS_NONE;
412 switch (tab_ids_value->GetType()) {
413 case Value::TYPE_INTEGER: {
414 params->tab_ids_type = TAB_IDS_INTEGER;
415 params->tab_ids_integer.reset(new int());
416 if (!tab_ids_value->GetAsInteger(params->tab_ids_integer.get()))
417 return scoped_ptr<Params>();
418 break;
419 }
420 case Value::TYPE_LIST: {
421 params->tab_ids_type = TAB_IDS_ARRAY;
422 if (!json_schema_compiler::util::GetOptionalArrayFromList(*static_cast<Lis tValue*>(tab_ids_value), &params->tab_ids_array))
423 return scoped_ptr<Params>();
424 break;
425 }
426 default:
427 return scoped_ptr<Params>();
428 }
429
430 return params.Pass();
431 }
432
433 // static
434 Value* Remove::Result::Create() {
435 return Value::CreateNullValue();
436 }
437
438 CaptureVisibleTab::Params::Options::Options() {}
439 CaptureVisibleTab::Params::Options::~Options() {}
440
441 // static
442 bool CaptureVisibleTab::Params::Options::Populate(const Value& value, Options* o ut) {
443 if (!value.IsType(Value::TYPE_DICTIONARY))
444 return false;
445 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value);
446
447 {
448 int quality_temp;
449 if (dict->GetInteger("quality", &quality_temp))
450 out->quality.reset(new int(quality_temp));
451 }
452 {
453 std::string format_temp;
454 if (dict->GetString("format", &format_temp))
455 out->format.reset(new std::string(format_temp));
456 }
457 return true;
458 }
459
460
461
462 CaptureVisibleTab::Params::Params() {}
463 CaptureVisibleTab::Params::~Params() {}
464
465 // static
466 scoped_ptr<CaptureVisibleTab::Params> CaptureVisibleTab::Params::Create(const Li stValue& args) {
467 if (args.GetSize() > 2)
468 return scoped_ptr<Params>();
469 scoped_ptr<Params> params(new Params());
470
471 if (!args.GetInteger(0, params->window_id.get()))
472 return params.Pass();
473
474 DictionaryValue* options_param = NULL;
475 if (!args.GetDictionary(1, &options_param))
476 return params.Pass();
477 params->options.reset(new Options());
478 if (!Options::Populate(*options_param, params->options.get()))
479 return params.Pass();
480
481 return params.Pass();
482 }
483
484 // static
485 // A data URL which encodes an image of the visible area of the captured tab.
486 // May be assigned to the 'src' property of an HTML Image element for display.
487 Value* CaptureVisibleTab::Result::Create(const std::string data_url) {
488 return Value::CreateStringValue(data_url);
489 }
490
491 Reload::Params::ReloadProperties::ReloadProperties() {}
492 Reload::Params::ReloadProperties::~ReloadProperties() {}
493
494 // static
495 bool Reload::Params::ReloadProperties::Populate(const Value& value, ReloadProper ties* out) {
496 if (!value.IsType(Value::TYPE_DICTIONARY))
497 return false;
498 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value);
499
500 {
501 bool bypass_cache_temp;
502 if (dict->GetBoolean("bypassCache", &bypass_cache_temp))
503 out->bypass_cache.reset(new bool(bypass_cache_temp));
504 }
505 return true;
506 }
507
508
509
510 Reload::Params::Params() {}
511 Reload::Params::~Params() {}
512
513 // static
514 scoped_ptr<Reload::Params> Reload::Params::Create(const ListValue& args) {
515 if (args.GetSize() > 2)
516 return scoped_ptr<Params>();
517 scoped_ptr<Params> params(new Params());
518
519 if (!args.GetInteger(0, params->tab_id.get()))
520 return params.Pass();
521
522 DictionaryValue* reload_properties_param = NULL;
523 if (!args.GetDictionary(1, &reload_properties_param))
524 return params.Pass();
525 params->reload_properties.reset(new ReloadProperties());
526 if (!ReloadProperties::Populate(*reload_properties_param, params->reload_prope rties.get()))
527 return params.Pass();
528
529 return params.Pass();
530 }
531
532 // static
533 Value* Reload::Result::Create() {
534 return Value::CreateNullValue();
535 }
536
537 DetectLanguage::Params::Params() {}
538 DetectLanguage::Params::~Params() {}
539
540 // static
541 scoped_ptr<DetectLanguage::Params> DetectLanguage::Params::Create(const ListValu e& args) {
542 if (args.GetSize() > 1)
543 return scoped_ptr<Params>();
544 scoped_ptr<Params> params(new Params());
545
546 if (!args.GetInteger(0, params->tab_id.get()))
547 return params.Pass();
548
549 return params.Pass();
550 }
551
552 // static
553 // An ISO language code such as <code>en</code> or <code>fr</code>. For a
554 // complete list of languages supported by this method, see <a
555 // href='http://src.chromium.org/viewvc/chrome/trunk/src/third_party/cld/languag
556 // es/internal/languages.cc'>kLanguageInfoTable</a>. The 2nd to 4th columns
557 // will be checked and the first non-NULL value will be returned except for
558 // Simplified Chinese for which zh-CN will be returned. For an unknown
559 // language, <code>und</code> will be returned.
560 Value* DetectLanguage::Result::Create(const std::string language) {
561 return Value::CreateStringValue(language);
562 }
563
564 InsertCSS::Params::Details::Details() {}
565 InsertCSS::Params::Details::~Details() {}
566
567 // static
568 bool InsertCSS::Params::Details::Populate(const Value& value, Details* out) {
569 if (!value.IsType(Value::TYPE_DICTIONARY))
570 return false;
571 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value);
572
573 {
574 bool all_frames_temp;
575 if (dict->GetBoolean("allFrames", &all_frames_temp))
576 out->all_frames.reset(new bool(all_frames_temp));
577 }
578 {
579 std::string code_temp;
580 if (dict->GetString("code", &code_temp))
581 out->code.reset(new std::string(code_temp));
582 }
583 {
584 std::string file_temp;
585 if (dict->GetString("file", &file_temp))
586 out->file.reset(new std::string(file_temp));
587 }
588 return true;
589 }
590
591
592
593 InsertCSS::Params::Params() {}
594 InsertCSS::Params::~Params() {}
595
596 // static
597 scoped_ptr<InsertCSS::Params> InsertCSS::Params::Create(const ListValue& args) {
598 if (args.GetSize() < 1 || args.GetSize() > 2)
599 return scoped_ptr<Params>();
600 scoped_ptr<Params> params(new Params());
601
602 if (!args.GetInteger(0, params->tab_id.get()))
603 return params.Pass();
604
605 DictionaryValue* details_param = NULL;
606 if (!args.GetDictionary(1, &details_param))
607 return scoped_ptr<Params>();
608 if (!Details::Populate(*details_param, &params->details))
609 return scoped_ptr<Params>();
610
611 return params.Pass();
612 }
613
614 // static
615 Value* InsertCSS::Result::Create() {
616 return Value::CreateNullValue();
617 }
618
619 Highlight::Params::HighlightInfo::HighlightInfo() {}
620 Highlight::Params::HighlightInfo::~HighlightInfo() {}
621
622 // static
623 bool Highlight::Params::HighlightInfo::Populate(const Value& value, HighlightInf o* out) {
624 if (!value.IsType(Value::TYPE_DICTIONARY))
625 return false;
626 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value);
627
628 Value* tabs_value = NULL;
629 if (!(dict->Get("tabs", &tabs_value)))
630 return false;
631
632 out->tabs_type = TABS_NONE;
633 switch (tabs_value->GetType()) {
634 case Value::TYPE_LIST: {
635 out->tabs_type = TABS_ARRAY;
636 if (!json_schema_compiler::util::GetOptionalArrayFromList(*static_cast<Lis tValue*>(tabs_value), &out->tabs_array))
637 return false;
638 break;
639 }
640 case Value::TYPE_INTEGER: {
641 out->tabs_type = TABS_INTEGER;
642 out->tabs_integer.reset(new int());
643 if (!tabs_value->GetAsInteger(out->tabs_integer.get()))
644 return false;
645 break;
646 }
647 default:
648 return false;
649 }
650 if (!dict->GetInteger("windowId", &out->window_id))
651 return false;
652 return true;
653 }
654
655
656
657 Highlight::Params::Params() {}
658 Highlight::Params::~Params() {}
659
660 // static
661 scoped_ptr<Highlight::Params> Highlight::Params::Create(const ListValue& args) {
662 if (args.GetSize() != 1)
663 return scoped_ptr<Params>();
664 scoped_ptr<Params> params(new Params());
665
666 DictionaryValue* highlight_info_param = NULL;
667 if (!args.GetDictionary(0, &highlight_info_param))
668 return scoped_ptr<Params>();
669 if (!HighlightInfo::Populate(*highlight_info_param, &params->highlight_info))
670 return scoped_ptr<Params>();
671
672 return params.Pass();
673 }
674
675 // static
676 // Contains details about the window whose tabs were highlighted.
677 Value* Highlight::Result::Create(const windows::Window& window) {
678 return window.ToValue();
679 }
680
681 Query::Params::QueryInfo::QueryInfo() {}
682 Query::Params::QueryInfo::~QueryInfo() {}
683
684 // static
685 bool Query::Params::QueryInfo::Populate(const Value& value, QueryInfo* out) {
686 if (!value.IsType(Value::TYPE_DICTIONARY))
687 return false;
688 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value);
689
690 {
691 std::string status_temp;
692 if (dict->GetString("status", &status_temp))
693 out->status.reset(new std::string(status_temp));
694 }
695 {
696 bool pinned_temp;
697 if (dict->GetBoolean("pinned", &pinned_temp))
698 out->pinned.reset(new bool(pinned_temp));
699 }
700 {
701 int index_temp;
702 if (dict->GetInteger("index", &index_temp))
703 out->index.reset(new int(index_temp));
704 }
705 {
706 std::string url_temp;
707 if (dict->GetString("url", &url_temp))
708 out->url.reset(new std::string(url_temp));
709 }
710 {
711 std::string title_temp;
712 if (dict->GetString("title", &title_temp))
713 out->title.reset(new std::string(title_temp));
714 }
715 {
716 bool highlighted_temp;
717 if (dict->GetBoolean("highlighted", &highlighted_temp))
718 out->highlighted.reset(new bool(highlighted_temp));
719 }
720 {
721 int window_id_temp;
722 if (dict->GetInteger("windowId", &window_id_temp))
723 out->window_id.reset(new int(window_id_temp));
724 }
725 {
726 std::string window_type_temp;
727 if (dict->GetString("windowType", &window_type_temp))
728 out->window_type.reset(new std::string(window_type_temp));
729 }
730 {
731 bool active_temp;
732 if (dict->GetBoolean("active", &active_temp))
733 out->active.reset(new bool(active_temp));
734 }
735 return true;
736 }
737
738
739
740 Query::Params::Params() {}
741 Query::Params::~Params() {}
742
743 // static
744 scoped_ptr<Query::Params> Query::Params::Create(const ListValue& args) {
745 if (args.GetSize() != 1)
746 return scoped_ptr<Params>();
747 scoped_ptr<Params> params(new Params());
748
749 DictionaryValue* query_info_param = NULL;
750 if (!args.GetDictionary(0, &query_info_param))
751 return scoped_ptr<Params>();
752 if (!QueryInfo::Populate(*query_info_param, &params->query_info))
753 return scoped_ptr<Params>();
754
755 return params.Pass();
756 }
757
758 // static
759 Value* Query::Result::Create(const std::vector<linked_ptr<Tab> > result) {
760 ListValue* value = new ListValue();
761 json_schema_compiler::util::SetArrayToList(result, value);
762 return value;
763 }
764
765 GetSelected::Params::Params() {}
766 GetSelected::Params::~Params() {}
767
768 // static
769 scoped_ptr<GetSelected::Params> GetSelected::Params::Create(const ListValue& arg s) {
770 if (args.GetSize() > 1)
771 return scoped_ptr<Params>();
772 scoped_ptr<Params> params(new Params());
773
774 if (!args.GetInteger(0, params->window_id.get()))
775 return params.Pass();
776
777 return params.Pass();
778 }
779
780 // static
781 Value* GetSelected::Result::Create(const Tab& tab) {
782 return tab.ToValue();
783 }
784
785 GetAllInWindow::Params::Params() {}
786 GetAllInWindow::Params::~Params() {}
787
788 // static
789 scoped_ptr<GetAllInWindow::Params> GetAllInWindow::Params::Create(const ListValu e& args) {
790 if (args.GetSize() > 1)
791 return scoped_ptr<Params>();
792 scoped_ptr<Params> params(new Params());
793
794 if (!args.GetInteger(0, params->window_id.get()))
795 return params.Pass();
796
797 return params.Pass();
798 }
799
800 // static
801 Value* GetAllInWindow::Result::Create(const std::vector<linked_ptr<Tab> > tabs) {
802 ListValue* value = new ListValue();
803 json_schema_compiler::util::SetArrayToList(tabs, value);
804 return value;
805 }
806
807 } // tabs
808 } // api
809 } // extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698