OLD | NEW |
(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 using base::Value; |
| 15 using base::DictionaryValue; |
| 16 using base::ListValue; |
| 17 |
| 18 namespace extensions { |
| 19 namespace api { |
| 20 namespace tabs { |
| 21 |
| 22 // |
| 23 // Types |
| 24 // |
| 25 |
| 26 Tab::Tab() {} |
| 27 Tab::~Tab() {} |
| 28 |
| 29 // static |
| 30 bool Tab::Populate(const Value& value, Tab* out) { |
| 31 if (!value.IsType(Value::TYPE_DICTIONARY)) |
| 32 return false; |
| 33 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value); |
| 34 |
| 35 Value* status_value = NULL; |
| 36 if (dict->GetWithoutPathExpansion("status", &status_value)) { |
| 37 { |
| 38 if (!status_value->IsType(Value::TYPE_STRING)) |
| 39 return false; |
| 40 std::string temp; |
| 41 if (status_value->GetAsString(&temp)) |
| 42 out->status.reset(new std::string(temp)); |
| 43 } |
| 44 } |
| 45 |
| 46 Value* index_value = NULL; |
| 47 if (!dict->GetWithoutPathExpansion("index", &index_value)) |
| 48 return false; |
| 49 { |
| 50 if (!index_value->IsType(Value::TYPE_INTEGER)) |
| 51 return false; |
| 52 if (!index_value->GetAsInteger(&out->index)) |
| 53 return false; |
| 54 } |
| 55 |
| 56 Value* opener_tab_id_value = NULL; |
| 57 if (dict->GetWithoutPathExpansion("openerTabId", &opener_tab_id_value)) { |
| 58 { |
| 59 if (!opener_tab_id_value->IsType(Value::TYPE_INTEGER)) |
| 60 return false; |
| 61 int temp; |
| 62 if (opener_tab_id_value->GetAsInteger(&temp)) |
| 63 out->opener_tab_id.reset(new int(temp)); |
| 64 } |
| 65 } |
| 66 |
| 67 Value* pinned_value = NULL; |
| 68 if (!dict->GetWithoutPathExpansion("pinned", &pinned_value)) |
| 69 return false; |
| 70 { |
| 71 if (!pinned_value->IsType(Value::TYPE_BOOLEAN)) |
| 72 return false; |
| 73 if (!pinned_value->GetAsBoolean(&out->pinned)) |
| 74 return false; |
| 75 } |
| 76 |
| 77 Value* title_value = NULL; |
| 78 if (dict->GetWithoutPathExpansion("title", &title_value)) { |
| 79 { |
| 80 if (!title_value->IsType(Value::TYPE_STRING)) |
| 81 return false; |
| 82 std::string temp; |
| 83 if (title_value->GetAsString(&temp)) |
| 84 out->title.reset(new std::string(temp)); |
| 85 } |
| 86 } |
| 87 |
| 88 Value* url_value = NULL; |
| 89 if (!dict->GetWithoutPathExpansion("url", &url_value)) |
| 90 return false; |
| 91 { |
| 92 if (!url_value->IsType(Value::TYPE_STRING)) |
| 93 return false; |
| 94 if (!url_value->GetAsString(&out->url)) |
| 95 return false; |
| 96 } |
| 97 |
| 98 Value* selected_value = NULL; |
| 99 if (!dict->GetWithoutPathExpansion("selected", &selected_value)) |
| 100 return false; |
| 101 { |
| 102 if (!selected_value->IsType(Value::TYPE_BOOLEAN)) |
| 103 return false; |
| 104 if (!selected_value->GetAsBoolean(&out->selected)) |
| 105 return false; |
| 106 } |
| 107 |
| 108 Value* highlighted_value = NULL; |
| 109 if (!dict->GetWithoutPathExpansion("highlighted", &highlighted_value)) |
| 110 return false; |
| 111 { |
| 112 if (!highlighted_value->IsType(Value::TYPE_BOOLEAN)) |
| 113 return false; |
| 114 if (!highlighted_value->GetAsBoolean(&out->highlighted)) |
| 115 return false; |
| 116 } |
| 117 |
| 118 Value* window_id_value = NULL; |
| 119 if (!dict->GetWithoutPathExpansion("windowId", &window_id_value)) |
| 120 return false; |
| 121 { |
| 122 if (!window_id_value->IsType(Value::TYPE_INTEGER)) |
| 123 return false; |
| 124 if (!window_id_value->GetAsInteger(&out->window_id)) |
| 125 return false; |
| 126 } |
| 127 |
| 128 Value* active_value = NULL; |
| 129 if (!dict->GetWithoutPathExpansion("active", &active_value)) |
| 130 return false; |
| 131 { |
| 132 if (!active_value->IsType(Value::TYPE_BOOLEAN)) |
| 133 return false; |
| 134 if (!active_value->GetAsBoolean(&out->active)) |
| 135 return false; |
| 136 } |
| 137 |
| 138 Value* fav_icon_url_value = NULL; |
| 139 if (dict->GetWithoutPathExpansion("favIconUrl", &fav_icon_url_value)) { |
| 140 { |
| 141 if (!fav_icon_url_value->IsType(Value::TYPE_STRING)) |
| 142 return false; |
| 143 std::string temp; |
| 144 if (fav_icon_url_value->GetAsString(&temp)) |
| 145 out->fav_icon_url.reset(new std::string(temp)); |
| 146 } |
| 147 } |
| 148 |
| 149 Value* id_value = NULL; |
| 150 if (!dict->GetWithoutPathExpansion("id", &id_value)) |
| 151 return false; |
| 152 { |
| 153 if (!id_value->IsType(Value::TYPE_INTEGER)) |
| 154 return false; |
| 155 if (!id_value->GetAsInteger(&out->id)) |
| 156 return false; |
| 157 } |
| 158 |
| 159 Value* incognito_value = NULL; |
| 160 if (!dict->GetWithoutPathExpansion("incognito", &incognito_value)) |
| 161 return false; |
| 162 { |
| 163 if (!incognito_value->IsType(Value::TYPE_BOOLEAN)) |
| 164 return false; |
| 165 if (!incognito_value->GetAsBoolean(&out->incognito)) |
| 166 return false; |
| 167 } |
| 168 |
| 169 return true; |
| 170 } |
| 171 |
| 172 scoped_ptr<DictionaryValue> Tab::ToValue() const { |
| 173 scoped_ptr<DictionaryValue> value(new DictionaryValue()); |
| 174 |
| 175 if (status.get()) |
| 176 value->SetWithoutPathExpansion("status", Value::CreateStringValue(*status)); |
| 177 value->SetWithoutPathExpansion("index", Value::CreateIntegerValue(index)); |
| 178 if (opener_tab_id.get()) |
| 179 value->SetWithoutPathExpansion("openerTabId", Value::CreateIntegerValue(*ope
ner_tab_id)); |
| 180 value->SetWithoutPathExpansion("pinned", Value::CreateBooleanValue(pinned)); |
| 181 if (title.get()) |
| 182 value->SetWithoutPathExpansion("title", Value::CreateStringValue(*title)); |
| 183 value->SetWithoutPathExpansion("url", Value::CreateStringValue(url)); |
| 184 value->SetWithoutPathExpansion("selected", Value::CreateBooleanValue(selected)
); |
| 185 value->SetWithoutPathExpansion("highlighted", Value::CreateBooleanValue(highli
ghted)); |
| 186 value->SetWithoutPathExpansion("windowId", Value::CreateIntegerValue(window_id
)); |
| 187 value->SetWithoutPathExpansion("active", Value::CreateBooleanValue(active)); |
| 188 if (fav_icon_url.get()) |
| 189 value->SetWithoutPathExpansion("favIconUrl", Value::CreateStringValue(*fav_i
con_url)); |
| 190 value->SetWithoutPathExpansion("id", Value::CreateIntegerValue(id)); |
| 191 value->SetWithoutPathExpansion("incognito", Value::CreateBooleanValue(incognit
o)); |
| 192 |
| 193 return value.Pass(); |
| 194 } |
| 195 |
| 196 |
| 197 // |
| 198 // Functions |
| 199 // |
| 200 |
| 201 ExecuteScript::Params::Details::Details() {} |
| 202 ExecuteScript::Params::Details::~Details() {} |
| 203 |
| 204 // static |
| 205 bool ExecuteScript::Params::Details::Populate(const Value& value, Details* out)
{ |
| 206 if (!value.IsType(Value::TYPE_DICTIONARY)) |
| 207 return false; |
| 208 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value); |
| 209 |
| 210 Value* all_frames_value = NULL; |
| 211 if (dict->GetWithoutPathExpansion("allFrames", &all_frames_value)) { |
| 212 { |
| 213 if (!all_frames_value->IsType(Value::TYPE_BOOLEAN)) |
| 214 return false; |
| 215 bool temp; |
| 216 if (all_frames_value->GetAsBoolean(&temp)) |
| 217 out->all_frames.reset(new bool(temp)); |
| 218 } |
| 219 } |
| 220 |
| 221 Value* code_value = NULL; |
| 222 if (dict->GetWithoutPathExpansion("code", &code_value)) { |
| 223 { |
| 224 if (!code_value->IsType(Value::TYPE_STRING)) |
| 225 return false; |
| 226 std::string temp; |
| 227 if (code_value->GetAsString(&temp)) |
| 228 out->code.reset(new std::string(temp)); |
| 229 } |
| 230 } |
| 231 |
| 232 Value* file_value = NULL; |
| 233 if (dict->GetWithoutPathExpansion("file", &file_value)) { |
| 234 { |
| 235 if (!file_value->IsType(Value::TYPE_STRING)) |
| 236 return false; |
| 237 std::string temp; |
| 238 if (file_value->GetAsString(&temp)) |
| 239 out->file.reset(new std::string(temp)); |
| 240 } |
| 241 } |
| 242 |
| 243 return true; |
| 244 } |
| 245 |
| 246 |
| 247 |
| 248 ExecuteScript::Params::Params() {} |
| 249 ExecuteScript::Params::~Params() {} |
| 250 |
| 251 // static |
| 252 scoped_ptr<ExecuteScript::Params> ExecuteScript::Params::Create(const ListValue&
args) { |
| 253 if (args.GetSize() < 1 || args.GetSize() > 2) |
| 254 return scoped_ptr<Params>(); |
| 255 scoped_ptr<Params> params(new Params()); |
| 256 |
| 257 Value* tab_id_value = NULL; |
| 258 if (!args.Get(0, &tab_id_value) || tab_id_value->IsType(Value::TYPE_NULL)) |
| 259 return params.Pass(); |
| 260 { |
| 261 if (!tab_id_value->IsType(Value::TYPE_INTEGER)) |
| 262 return scoped_ptr<Params>(); |
| 263 int temp; |
| 264 if (tab_id_value->GetAsInteger(&temp)) |
| 265 params->tab_id.reset(new int(temp)); |
| 266 } |
| 267 |
| 268 Value* details_value = NULL; |
| 269 if (!args.Get(1, &details_value) || details_value->IsType(Value::TYPE_NULL)) |
| 270 return scoped_ptr<Params>(); |
| 271 { |
| 272 if (!details_value->IsType(Value::TYPE_DICTIONARY)) |
| 273 return scoped_ptr<Params>(); |
| 274 DictionaryValue* dictionary = NULL; |
| 275 if (!details_value->GetAsDictionary(&dictionary)) |
| 276 return scoped_ptr<Params>(); |
| 277 if (!Details::Populate(*dictionary, ¶ms->details)) |
| 278 return scoped_ptr<Params>(); |
| 279 } |
| 280 |
| 281 return params.Pass(); |
| 282 } |
| 283 |
| 284 |
| 285 Value* ExecuteScript::Result::Create() { |
| 286 return Value::CreateNullValue(); |
| 287 } |
| 288 |
| 289 Get::Params::Params() {} |
| 290 Get::Params::~Params() {} |
| 291 |
| 292 // static |
| 293 scoped_ptr<Get::Params> Get::Params::Create(const ListValue& args) { |
| 294 if (args.GetSize() != 1) |
| 295 return scoped_ptr<Params>(); |
| 296 scoped_ptr<Params> params(new Params()); |
| 297 |
| 298 Value* tab_id_value = NULL; |
| 299 if (!args.Get(0, &tab_id_value) || tab_id_value->IsType(Value::TYPE_NULL)) |
| 300 return scoped_ptr<Params>(); |
| 301 { |
| 302 if (!tab_id_value->IsType(Value::TYPE_INTEGER)) |
| 303 return scoped_ptr<Params>(); |
| 304 if (!tab_id_value->GetAsInteger(¶ms->tab_id)) |
| 305 return scoped_ptr<Params>(); |
| 306 } |
| 307 |
| 308 return params.Pass(); |
| 309 } |
| 310 |
| 311 |
| 312 Value* Get::Result::Create(const Tab& tab) { |
| 313 return tab.ToValue().release(); |
| 314 } |
| 315 |
| 316 Value* GetCurrent::Result::Create(const Tab& tab) { |
| 317 return tab.ToValue().release(); |
| 318 } |
| 319 |
| 320 Create::Params::CreateProperties::CreateProperties() {} |
| 321 Create::Params::CreateProperties::~CreateProperties() {} |
| 322 |
| 323 // static |
| 324 bool Create::Params::CreateProperties::Populate(const Value& value, CreateProper
ties* out) { |
| 325 if (!value.IsType(Value::TYPE_DICTIONARY)) |
| 326 return false; |
| 327 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value); |
| 328 |
| 329 Value* index_value = NULL; |
| 330 if (dict->GetWithoutPathExpansion("index", &index_value)) { |
| 331 { |
| 332 if (!index_value->IsType(Value::TYPE_INTEGER)) |
| 333 return false; |
| 334 int temp; |
| 335 if (index_value->GetAsInteger(&temp)) |
| 336 out->index.reset(new int(temp)); |
| 337 } |
| 338 } |
| 339 |
| 340 Value* opener_tab_id_value = NULL; |
| 341 if (dict->GetWithoutPathExpansion("openerTabId", &opener_tab_id_value)) { |
| 342 { |
| 343 if (!opener_tab_id_value->IsType(Value::TYPE_INTEGER)) |
| 344 return false; |
| 345 int temp; |
| 346 if (opener_tab_id_value->GetAsInteger(&temp)) |
| 347 out->opener_tab_id.reset(new int(temp)); |
| 348 } |
| 349 } |
| 350 |
| 351 Value* url_value = NULL; |
| 352 if (dict->GetWithoutPathExpansion("url", &url_value)) { |
| 353 { |
| 354 if (!url_value->IsType(Value::TYPE_STRING)) |
| 355 return false; |
| 356 std::string temp; |
| 357 if (url_value->GetAsString(&temp)) |
| 358 out->url.reset(new std::string(temp)); |
| 359 } |
| 360 } |
| 361 |
| 362 Value* selected_value = NULL; |
| 363 if (dict->GetWithoutPathExpansion("selected", &selected_value)) { |
| 364 { |
| 365 if (!selected_value->IsType(Value::TYPE_BOOLEAN)) |
| 366 return false; |
| 367 bool temp; |
| 368 if (selected_value->GetAsBoolean(&temp)) |
| 369 out->selected.reset(new bool(temp)); |
| 370 } |
| 371 } |
| 372 |
| 373 Value* pinned_value = NULL; |
| 374 if (dict->GetWithoutPathExpansion("pinned", &pinned_value)) { |
| 375 { |
| 376 if (!pinned_value->IsType(Value::TYPE_BOOLEAN)) |
| 377 return false; |
| 378 bool temp; |
| 379 if (pinned_value->GetAsBoolean(&temp)) |
| 380 out->pinned.reset(new bool(temp)); |
| 381 } |
| 382 } |
| 383 |
| 384 Value* window_id_value = NULL; |
| 385 if (dict->GetWithoutPathExpansion("windowId", &window_id_value)) { |
| 386 { |
| 387 if (!window_id_value->IsType(Value::TYPE_INTEGER)) |
| 388 return false; |
| 389 int temp; |
| 390 if (window_id_value->GetAsInteger(&temp)) |
| 391 out->window_id.reset(new int(temp)); |
| 392 } |
| 393 } |
| 394 |
| 395 Value* active_value = NULL; |
| 396 if (dict->GetWithoutPathExpansion("active", &active_value)) { |
| 397 { |
| 398 if (!active_value->IsType(Value::TYPE_BOOLEAN)) |
| 399 return false; |
| 400 bool temp; |
| 401 if (active_value->GetAsBoolean(&temp)) |
| 402 out->active.reset(new bool(temp)); |
| 403 } |
| 404 } |
| 405 |
| 406 return true; |
| 407 } |
| 408 |
| 409 |
| 410 |
| 411 Create::Params::Params() {} |
| 412 Create::Params::~Params() {} |
| 413 |
| 414 // static |
| 415 scoped_ptr<Create::Params> Create::Params::Create(const ListValue& args) { |
| 416 if (args.GetSize() != 1) |
| 417 return scoped_ptr<Params>(); |
| 418 scoped_ptr<Params> params(new Params()); |
| 419 |
| 420 Value* create_properties_value = NULL; |
| 421 if (!args.Get(0, &create_properties_value) || create_properties_value->IsType(
Value::TYPE_NULL)) |
| 422 return scoped_ptr<Params>(); |
| 423 { |
| 424 if (!create_properties_value->IsType(Value::TYPE_DICTIONARY)) |
| 425 return scoped_ptr<Params>(); |
| 426 DictionaryValue* dictionary = NULL; |
| 427 if (!create_properties_value->GetAsDictionary(&dictionary)) |
| 428 return scoped_ptr<Params>(); |
| 429 if (!CreateProperties::Populate(*dictionary, ¶ms->create_properties)) |
| 430 return scoped_ptr<Params>(); |
| 431 } |
| 432 |
| 433 return params.Pass(); |
| 434 } |
| 435 |
| 436 |
| 437 Value* Create::Result::Create(const Tab& tab) { |
| 438 return tab.ToValue().release(); |
| 439 } |
| 440 |
| 441 Move::Params::MoveProperties::MoveProperties() {} |
| 442 Move::Params::MoveProperties::~MoveProperties() {} |
| 443 |
| 444 // static |
| 445 bool Move::Params::MoveProperties::Populate(const Value& value, MoveProperties*
out) { |
| 446 if (!value.IsType(Value::TYPE_DICTIONARY)) |
| 447 return false; |
| 448 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value); |
| 449 |
| 450 Value* index_value = NULL; |
| 451 if (!dict->GetWithoutPathExpansion("index", &index_value)) |
| 452 return false; |
| 453 { |
| 454 if (!index_value->IsType(Value::TYPE_INTEGER)) |
| 455 return false; |
| 456 if (!index_value->GetAsInteger(&out->index)) |
| 457 return false; |
| 458 } |
| 459 |
| 460 Value* window_id_value = NULL; |
| 461 if (dict->GetWithoutPathExpansion("windowId", &window_id_value)) { |
| 462 { |
| 463 if (!window_id_value->IsType(Value::TYPE_INTEGER)) |
| 464 return false; |
| 465 int temp; |
| 466 if (window_id_value->GetAsInteger(&temp)) |
| 467 out->window_id.reset(new int(temp)); |
| 468 } |
| 469 } |
| 470 |
| 471 return true; |
| 472 } |
| 473 |
| 474 |
| 475 |
| 476 Move::Params::Params() {} |
| 477 Move::Params::~Params() {} |
| 478 |
| 479 // static |
| 480 scoped_ptr<Move::Params> Move::Params::Create(const ListValue& args) { |
| 481 if (args.GetSize() != 2) |
| 482 return scoped_ptr<Params>(); |
| 483 scoped_ptr<Params> params(new Params()); |
| 484 |
| 485 Value* tab_ids_value = NULL; |
| 486 if (!args.Get(0, &tab_ids_value) || tab_ids_value->IsType(Value::TYPE_NULL)) |
| 487 return scoped_ptr<Params>(); |
| 488 params->tab_ids_type = TAB_IDS_NONE; |
| 489 switch (tab_ids_value->GetType()) { |
| 490 case Value::TYPE_INTEGER: { |
| 491 { |
| 492 int temp; |
| 493 if (tab_ids_value->GetAsInteger(&temp)) |
| 494 params->tab_ids_integer.reset(new int(temp)); |
| 495 } |
| 496 params->tab_ids_type = TAB_IDS_INTEGER; |
| 497 break; |
| 498 } |
| 499 case Value::TYPE_LIST: { |
| 500 { |
| 501 ListValue* list = NULL; |
| 502 if (!tab_ids_value->GetAsList(&list)) |
| 503 return scoped_ptr<Params>(); |
| 504 if (!json_schema_compiler::util::PopulateOptionalArrayFromList(*list, &p
arams->tab_ids_array)) |
| 505 return scoped_ptr<Params>(); |
| 506 } |
| 507 params->tab_ids_type = TAB_IDS_ARRAY; |
| 508 break; |
| 509 } |
| 510 default: |
| 511 return scoped_ptr<Params>(); |
| 512 } |
| 513 |
| 514 Value* move_properties_value = NULL; |
| 515 if (!args.Get(1, &move_properties_value) || move_properties_value->IsType(Valu
e::TYPE_NULL)) |
| 516 return scoped_ptr<Params>(); |
| 517 { |
| 518 if (!move_properties_value->IsType(Value::TYPE_DICTIONARY)) |
| 519 return scoped_ptr<Params>(); |
| 520 DictionaryValue* dictionary = NULL; |
| 521 if (!move_properties_value->GetAsDictionary(&dictionary)) |
| 522 return scoped_ptr<Params>(); |
| 523 if (!MoveProperties::Populate(*dictionary, ¶ms->move_properties)) |
| 524 return scoped_ptr<Params>(); |
| 525 } |
| 526 |
| 527 return params.Pass(); |
| 528 } |
| 529 |
| 530 |
| 531 Value* Move::Result::Create(const Tab& tabs_ref) { |
| 532 return tabs_ref.ToValue().release(); |
| 533 } |
| 534 Value* Move::Result::Create(const std::vector<linked_ptr<Tab> >& tabs_array) { |
| 535 ListValue* value = new ListValue(); |
| 536 json_schema_compiler::util::PopulateListFromArray(tabs_array, value); |
| 537 return value; |
| 538 } |
| 539 |
| 540 Update::Params::UpdateProperties::UpdateProperties() {} |
| 541 Update::Params::UpdateProperties::~UpdateProperties() {} |
| 542 |
| 543 // static |
| 544 bool Update::Params::UpdateProperties::Populate(const Value& value, UpdateProper
ties* out) { |
| 545 if (!value.IsType(Value::TYPE_DICTIONARY)) |
| 546 return false; |
| 547 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value); |
| 548 |
| 549 Value* highlighted_value = NULL; |
| 550 if (dict->GetWithoutPathExpansion("highlighted", &highlighted_value)) { |
| 551 { |
| 552 if (!highlighted_value->IsType(Value::TYPE_BOOLEAN)) |
| 553 return false; |
| 554 bool temp; |
| 555 if (highlighted_value->GetAsBoolean(&temp)) |
| 556 out->highlighted.reset(new bool(temp)); |
| 557 } |
| 558 } |
| 559 |
| 560 Value* opener_tab_id_value = NULL; |
| 561 if (dict->GetWithoutPathExpansion("openerTabId", &opener_tab_id_value)) { |
| 562 { |
| 563 if (!opener_tab_id_value->IsType(Value::TYPE_INTEGER)) |
| 564 return false; |
| 565 int temp; |
| 566 if (opener_tab_id_value->GetAsInteger(&temp)) |
| 567 out->opener_tab_id.reset(new int(temp)); |
| 568 } |
| 569 } |
| 570 |
| 571 Value* url_value = NULL; |
| 572 if (dict->GetWithoutPathExpansion("url", &url_value)) { |
| 573 { |
| 574 if (!url_value->IsType(Value::TYPE_STRING)) |
| 575 return false; |
| 576 std::string temp; |
| 577 if (url_value->GetAsString(&temp)) |
| 578 out->url.reset(new std::string(temp)); |
| 579 } |
| 580 } |
| 581 |
| 582 Value* selected_value = NULL; |
| 583 if (dict->GetWithoutPathExpansion("selected", &selected_value)) { |
| 584 { |
| 585 if (!selected_value->IsType(Value::TYPE_BOOLEAN)) |
| 586 return false; |
| 587 bool temp; |
| 588 if (selected_value->GetAsBoolean(&temp)) |
| 589 out->selected.reset(new bool(temp)); |
| 590 } |
| 591 } |
| 592 |
| 593 Value* pinned_value = NULL; |
| 594 if (dict->GetWithoutPathExpansion("pinned", &pinned_value)) { |
| 595 { |
| 596 if (!pinned_value->IsType(Value::TYPE_BOOLEAN)) |
| 597 return false; |
| 598 bool temp; |
| 599 if (pinned_value->GetAsBoolean(&temp)) |
| 600 out->pinned.reset(new bool(temp)); |
| 601 } |
| 602 } |
| 603 |
| 604 Value* active_value = NULL; |
| 605 if (dict->GetWithoutPathExpansion("active", &active_value)) { |
| 606 { |
| 607 if (!active_value->IsType(Value::TYPE_BOOLEAN)) |
| 608 return false; |
| 609 bool temp; |
| 610 if (active_value->GetAsBoolean(&temp)) |
| 611 out->active.reset(new bool(temp)); |
| 612 } |
| 613 } |
| 614 |
| 615 return true; |
| 616 } |
| 617 |
| 618 |
| 619 |
| 620 Update::Params::Params() {} |
| 621 Update::Params::~Params() {} |
| 622 |
| 623 // static |
| 624 scoped_ptr<Update::Params> Update::Params::Create(const ListValue& args) { |
| 625 if (args.GetSize() < 1 || args.GetSize() > 2) |
| 626 return scoped_ptr<Params>(); |
| 627 scoped_ptr<Params> params(new Params()); |
| 628 |
| 629 Value* tab_id_value = NULL; |
| 630 if (!args.Get(0, &tab_id_value) || tab_id_value->IsType(Value::TYPE_NULL)) |
| 631 return params.Pass(); |
| 632 { |
| 633 if (!tab_id_value->IsType(Value::TYPE_INTEGER)) |
| 634 return scoped_ptr<Params>(); |
| 635 int temp; |
| 636 if (tab_id_value->GetAsInteger(&temp)) |
| 637 params->tab_id.reset(new int(temp)); |
| 638 } |
| 639 |
| 640 Value* update_properties_value = NULL; |
| 641 if (!args.Get(1, &update_properties_value) || update_properties_value->IsType(
Value::TYPE_NULL)) |
| 642 return scoped_ptr<Params>(); |
| 643 { |
| 644 if (!update_properties_value->IsType(Value::TYPE_DICTIONARY)) |
| 645 return scoped_ptr<Params>(); |
| 646 DictionaryValue* dictionary = NULL; |
| 647 if (!update_properties_value->GetAsDictionary(&dictionary)) |
| 648 return scoped_ptr<Params>(); |
| 649 if (!UpdateProperties::Populate(*dictionary, ¶ms->update_properties)) |
| 650 return scoped_ptr<Params>(); |
| 651 } |
| 652 |
| 653 return params.Pass(); |
| 654 } |
| 655 |
| 656 |
| 657 Value* Update::Result::Create(const Tab& tab) { |
| 658 return tab.ToValue().release(); |
| 659 } |
| 660 |
| 661 Remove::Params::Params() {} |
| 662 Remove::Params::~Params() {} |
| 663 |
| 664 // static |
| 665 scoped_ptr<Remove::Params> Remove::Params::Create(const ListValue& args) { |
| 666 if (args.GetSize() != 1) |
| 667 return scoped_ptr<Params>(); |
| 668 scoped_ptr<Params> params(new Params()); |
| 669 |
| 670 Value* tab_ids_value = NULL; |
| 671 if (!args.Get(0, &tab_ids_value) || tab_ids_value->IsType(Value::TYPE_NULL)) |
| 672 return scoped_ptr<Params>(); |
| 673 params->tab_ids_type = TAB_IDS_NONE; |
| 674 switch (tab_ids_value->GetType()) { |
| 675 case Value::TYPE_INTEGER: { |
| 676 { |
| 677 int temp; |
| 678 if (tab_ids_value->GetAsInteger(&temp)) |
| 679 params->tab_ids_integer.reset(new int(temp)); |
| 680 } |
| 681 params->tab_ids_type = TAB_IDS_INTEGER; |
| 682 break; |
| 683 } |
| 684 case Value::TYPE_LIST: { |
| 685 { |
| 686 ListValue* list = NULL; |
| 687 if (!tab_ids_value->GetAsList(&list)) |
| 688 return scoped_ptr<Params>(); |
| 689 if (!json_schema_compiler::util::PopulateOptionalArrayFromList(*list, &p
arams->tab_ids_array)) |
| 690 return scoped_ptr<Params>(); |
| 691 } |
| 692 params->tab_ids_type = TAB_IDS_ARRAY; |
| 693 break; |
| 694 } |
| 695 default: |
| 696 return scoped_ptr<Params>(); |
| 697 } |
| 698 |
| 699 return params.Pass(); |
| 700 } |
| 701 |
| 702 |
| 703 Value* Remove::Result::Create() { |
| 704 return Value::CreateNullValue(); |
| 705 } |
| 706 |
| 707 CaptureVisibleTab::Params::Options::Options() {} |
| 708 CaptureVisibleTab::Params::Options::~Options() {} |
| 709 |
| 710 // static |
| 711 bool CaptureVisibleTab::Params::Options::Populate(const Value& value, Options* o
ut) { |
| 712 if (!value.IsType(Value::TYPE_DICTIONARY)) |
| 713 return false; |
| 714 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value); |
| 715 |
| 716 Value* quality_value = NULL; |
| 717 if (dict->GetWithoutPathExpansion("quality", &quality_value)) { |
| 718 { |
| 719 if (!quality_value->IsType(Value::TYPE_INTEGER)) |
| 720 return false; |
| 721 int temp; |
| 722 if (quality_value->GetAsInteger(&temp)) |
| 723 out->quality.reset(new int(temp)); |
| 724 } |
| 725 } |
| 726 |
| 727 Value* format_value = NULL; |
| 728 if (dict->GetWithoutPathExpansion("format", &format_value)) { |
| 729 { |
| 730 if (!format_value->IsType(Value::TYPE_STRING)) |
| 731 return false; |
| 732 std::string temp; |
| 733 if (format_value->GetAsString(&temp)) |
| 734 out->format.reset(new std::string(temp)); |
| 735 } |
| 736 } |
| 737 |
| 738 return true; |
| 739 } |
| 740 |
| 741 |
| 742 |
| 743 CaptureVisibleTab::Params::Params() {} |
| 744 CaptureVisibleTab::Params::~Params() {} |
| 745 |
| 746 // static |
| 747 scoped_ptr<CaptureVisibleTab::Params> CaptureVisibleTab::Params::Create(const Li
stValue& args) { |
| 748 if (args.GetSize() > 2) |
| 749 return scoped_ptr<Params>(); |
| 750 scoped_ptr<Params> params(new Params()); |
| 751 |
| 752 Value* window_id_value = NULL; |
| 753 if (!args.Get(0, &window_id_value) || window_id_value->IsType(Value::TYPE_NULL
)) |
| 754 return params.Pass(); |
| 755 { |
| 756 if (!window_id_value->IsType(Value::TYPE_INTEGER)) |
| 757 return scoped_ptr<Params>(); |
| 758 int temp; |
| 759 if (window_id_value->GetAsInteger(&temp)) |
| 760 params->window_id.reset(new int(temp)); |
| 761 } |
| 762 |
| 763 Value* options_value = NULL; |
| 764 if (!args.Get(1, &options_value) || options_value->IsType(Value::TYPE_NULL)) |
| 765 return params.Pass(); |
| 766 { |
| 767 if (!options_value->IsType(Value::TYPE_DICTIONARY)) |
| 768 return scoped_ptr<Params>(); |
| 769 DictionaryValue* dictionary = NULL; |
| 770 if (!options_value->GetAsDictionary(&dictionary)) |
| 771 return scoped_ptr<Params>(); |
| 772 scoped_ptr<Options> temp(new Options()); |
| 773 if (!Options::Populate(*dictionary, temp.get())) |
| 774 return scoped_ptr<Params>(); |
| 775 params->options = temp.Pass(); |
| 776 } |
| 777 |
| 778 return params.Pass(); |
| 779 } |
| 780 |
| 781 |
| 782 Value* CaptureVisibleTab::Result::Create(const std::string data_url) { |
| 783 return Value::CreateStringValue(data_url); |
| 784 } |
| 785 |
| 786 Reload::Params::ReloadProperties::ReloadProperties() {} |
| 787 Reload::Params::ReloadProperties::~ReloadProperties() {} |
| 788 |
| 789 // static |
| 790 bool Reload::Params::ReloadProperties::Populate(const Value& value, ReloadProper
ties* out) { |
| 791 if (!value.IsType(Value::TYPE_DICTIONARY)) |
| 792 return false; |
| 793 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value); |
| 794 |
| 795 Value* bypass_cache_value = NULL; |
| 796 if (dict->GetWithoutPathExpansion("bypassCache", &bypass_cache_value)) { |
| 797 { |
| 798 if (!bypass_cache_value->IsType(Value::TYPE_BOOLEAN)) |
| 799 return false; |
| 800 bool temp; |
| 801 if (bypass_cache_value->GetAsBoolean(&temp)) |
| 802 out->bypass_cache.reset(new bool(temp)); |
| 803 } |
| 804 } |
| 805 |
| 806 return true; |
| 807 } |
| 808 |
| 809 |
| 810 |
| 811 Reload::Params::Params() {} |
| 812 Reload::Params::~Params() {} |
| 813 |
| 814 // static |
| 815 scoped_ptr<Reload::Params> Reload::Params::Create(const ListValue& args) { |
| 816 if (args.GetSize() > 2) |
| 817 return scoped_ptr<Params>(); |
| 818 scoped_ptr<Params> params(new Params()); |
| 819 |
| 820 Value* tab_id_value = NULL; |
| 821 if (!args.Get(0, &tab_id_value) || tab_id_value->IsType(Value::TYPE_NULL)) |
| 822 return params.Pass(); |
| 823 { |
| 824 if (!tab_id_value->IsType(Value::TYPE_INTEGER)) |
| 825 return scoped_ptr<Params>(); |
| 826 int temp; |
| 827 if (tab_id_value->GetAsInteger(&temp)) |
| 828 params->tab_id.reset(new int(temp)); |
| 829 } |
| 830 |
| 831 Value* reload_properties_value = NULL; |
| 832 if (!args.Get(1, &reload_properties_value) || reload_properties_value->IsType(
Value::TYPE_NULL)) |
| 833 return params.Pass(); |
| 834 { |
| 835 if (!reload_properties_value->IsType(Value::TYPE_DICTIONARY)) |
| 836 return scoped_ptr<Params>(); |
| 837 DictionaryValue* dictionary = NULL; |
| 838 if (!reload_properties_value->GetAsDictionary(&dictionary)) |
| 839 return scoped_ptr<Params>(); |
| 840 scoped_ptr<ReloadProperties> temp(new ReloadProperties()); |
| 841 if (!ReloadProperties::Populate(*dictionary, temp.get())) |
| 842 return scoped_ptr<Params>(); |
| 843 params->reload_properties = temp.Pass(); |
| 844 } |
| 845 |
| 846 return params.Pass(); |
| 847 } |
| 848 |
| 849 |
| 850 Value* Reload::Result::Create() { |
| 851 return Value::CreateNullValue(); |
| 852 } |
| 853 |
| 854 DetectLanguage::Params::Params() {} |
| 855 DetectLanguage::Params::~Params() {} |
| 856 |
| 857 // static |
| 858 scoped_ptr<DetectLanguage::Params> DetectLanguage::Params::Create(const ListValu
e& args) { |
| 859 if (args.GetSize() > 1) |
| 860 return scoped_ptr<Params>(); |
| 861 scoped_ptr<Params> params(new Params()); |
| 862 |
| 863 Value* tab_id_value = NULL; |
| 864 if (!args.Get(0, &tab_id_value) || tab_id_value->IsType(Value::TYPE_NULL)) |
| 865 return params.Pass(); |
| 866 { |
| 867 if (!tab_id_value->IsType(Value::TYPE_INTEGER)) |
| 868 return scoped_ptr<Params>(); |
| 869 int temp; |
| 870 if (tab_id_value->GetAsInteger(&temp)) |
| 871 params->tab_id.reset(new int(temp)); |
| 872 } |
| 873 |
| 874 return params.Pass(); |
| 875 } |
| 876 |
| 877 |
| 878 Value* DetectLanguage::Result::Create(const std::string language) { |
| 879 return Value::CreateStringValue(language); |
| 880 } |
| 881 |
| 882 InsertCSS::Params::Details::Details() {} |
| 883 InsertCSS::Params::Details::~Details() {} |
| 884 |
| 885 // static |
| 886 bool InsertCSS::Params::Details::Populate(const Value& value, Details* out) { |
| 887 if (!value.IsType(Value::TYPE_DICTIONARY)) |
| 888 return false; |
| 889 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value); |
| 890 |
| 891 Value* all_frames_value = NULL; |
| 892 if (dict->GetWithoutPathExpansion("allFrames", &all_frames_value)) { |
| 893 { |
| 894 if (!all_frames_value->IsType(Value::TYPE_BOOLEAN)) |
| 895 return false; |
| 896 bool temp; |
| 897 if (all_frames_value->GetAsBoolean(&temp)) |
| 898 out->all_frames.reset(new bool(temp)); |
| 899 } |
| 900 } |
| 901 |
| 902 Value* code_value = NULL; |
| 903 if (dict->GetWithoutPathExpansion("code", &code_value)) { |
| 904 { |
| 905 if (!code_value->IsType(Value::TYPE_STRING)) |
| 906 return false; |
| 907 std::string temp; |
| 908 if (code_value->GetAsString(&temp)) |
| 909 out->code.reset(new std::string(temp)); |
| 910 } |
| 911 } |
| 912 |
| 913 Value* file_value = NULL; |
| 914 if (dict->GetWithoutPathExpansion("file", &file_value)) { |
| 915 { |
| 916 if (!file_value->IsType(Value::TYPE_STRING)) |
| 917 return false; |
| 918 std::string temp; |
| 919 if (file_value->GetAsString(&temp)) |
| 920 out->file.reset(new std::string(temp)); |
| 921 } |
| 922 } |
| 923 |
| 924 return true; |
| 925 } |
| 926 |
| 927 |
| 928 |
| 929 InsertCSS::Params::Params() {} |
| 930 InsertCSS::Params::~Params() {} |
| 931 |
| 932 // static |
| 933 scoped_ptr<InsertCSS::Params> InsertCSS::Params::Create(const ListValue& args) { |
| 934 if (args.GetSize() < 1 || args.GetSize() > 2) |
| 935 return scoped_ptr<Params>(); |
| 936 scoped_ptr<Params> params(new Params()); |
| 937 |
| 938 Value* tab_id_value = NULL; |
| 939 if (!args.Get(0, &tab_id_value) || tab_id_value->IsType(Value::TYPE_NULL)) |
| 940 return params.Pass(); |
| 941 { |
| 942 if (!tab_id_value->IsType(Value::TYPE_INTEGER)) |
| 943 return scoped_ptr<Params>(); |
| 944 int temp; |
| 945 if (tab_id_value->GetAsInteger(&temp)) |
| 946 params->tab_id.reset(new int(temp)); |
| 947 } |
| 948 |
| 949 Value* details_value = NULL; |
| 950 if (!args.Get(1, &details_value) || details_value->IsType(Value::TYPE_NULL)) |
| 951 return scoped_ptr<Params>(); |
| 952 { |
| 953 if (!details_value->IsType(Value::TYPE_DICTIONARY)) |
| 954 return scoped_ptr<Params>(); |
| 955 DictionaryValue* dictionary = NULL; |
| 956 if (!details_value->GetAsDictionary(&dictionary)) |
| 957 return scoped_ptr<Params>(); |
| 958 if (!Details::Populate(*dictionary, ¶ms->details)) |
| 959 return scoped_ptr<Params>(); |
| 960 } |
| 961 |
| 962 return params.Pass(); |
| 963 } |
| 964 |
| 965 |
| 966 Value* InsertCSS::Result::Create() { |
| 967 return Value::CreateNullValue(); |
| 968 } |
| 969 |
| 970 Highlight::Params::HighlightInfo::HighlightInfo() {} |
| 971 Highlight::Params::HighlightInfo::~HighlightInfo() {} |
| 972 |
| 973 // static |
| 974 bool Highlight::Params::HighlightInfo::Populate(const Value& value, HighlightInf
o* out) { |
| 975 if (!value.IsType(Value::TYPE_DICTIONARY)) |
| 976 return false; |
| 977 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value); |
| 978 |
| 979 Value* tabs_value = NULL; |
| 980 if (!dict->GetWithoutPathExpansion("tabs", &tabs_value)) |
| 981 return false; |
| 982 out->tabs_type = TABS_NONE; |
| 983 switch (tabs_value->GetType()) { |
| 984 case Value::TYPE_LIST: { |
| 985 { |
| 986 ListValue* list = NULL; |
| 987 if (!tabs_value->GetAsList(&list)) |
| 988 return false; |
| 989 if (!json_schema_compiler::util::PopulateOptionalArrayFromList(*list, &o
ut->tabs_array)) |
| 990 return false; |
| 991 } |
| 992 out->tabs_type = TABS_ARRAY; |
| 993 break; |
| 994 } |
| 995 case Value::TYPE_INTEGER: { |
| 996 { |
| 997 int temp; |
| 998 if (tabs_value->GetAsInteger(&temp)) |
| 999 out->tabs_integer.reset(new int(temp)); |
| 1000 } |
| 1001 out->tabs_type = TABS_INTEGER; |
| 1002 break; |
| 1003 } |
| 1004 default: |
| 1005 return false; |
| 1006 } |
| 1007 |
| 1008 Value* window_id_value = NULL; |
| 1009 if (!dict->GetWithoutPathExpansion("windowId", &window_id_value)) |
| 1010 return false; |
| 1011 { |
| 1012 if (!window_id_value->IsType(Value::TYPE_INTEGER)) |
| 1013 return false; |
| 1014 if (!window_id_value->GetAsInteger(&out->window_id)) |
| 1015 return false; |
| 1016 } |
| 1017 |
| 1018 return true; |
| 1019 } |
| 1020 |
| 1021 |
| 1022 |
| 1023 Highlight::Params::Params() {} |
| 1024 Highlight::Params::~Params() {} |
| 1025 |
| 1026 // static |
| 1027 scoped_ptr<Highlight::Params> Highlight::Params::Create(const ListValue& args) { |
| 1028 if (args.GetSize() != 1) |
| 1029 return scoped_ptr<Params>(); |
| 1030 scoped_ptr<Params> params(new Params()); |
| 1031 |
| 1032 Value* highlight_info_value = NULL; |
| 1033 if (!args.Get(0, &highlight_info_value) || highlight_info_value->IsType(Value:
:TYPE_NULL)) |
| 1034 return scoped_ptr<Params>(); |
| 1035 { |
| 1036 if (!highlight_info_value->IsType(Value::TYPE_DICTIONARY)) |
| 1037 return scoped_ptr<Params>(); |
| 1038 DictionaryValue* dictionary = NULL; |
| 1039 if (!highlight_info_value->GetAsDictionary(&dictionary)) |
| 1040 return scoped_ptr<Params>(); |
| 1041 if (!HighlightInfo::Populate(*dictionary, ¶ms->highlight_info)) |
| 1042 return scoped_ptr<Params>(); |
| 1043 } |
| 1044 |
| 1045 return params.Pass(); |
| 1046 } |
| 1047 |
| 1048 |
| 1049 Value* Highlight::Result::Create(const windows::Window& window) { |
| 1050 return window.ToValue().release(); |
| 1051 } |
| 1052 |
| 1053 Query::Params::QueryInfo::QueryInfo() {} |
| 1054 Query::Params::QueryInfo::~QueryInfo() {} |
| 1055 |
| 1056 // static |
| 1057 bool Query::Params::QueryInfo::Populate(const Value& value, QueryInfo* out) { |
| 1058 if (!value.IsType(Value::TYPE_DICTIONARY)) |
| 1059 return false; |
| 1060 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value); |
| 1061 |
| 1062 Value* status_value = NULL; |
| 1063 if (dict->GetWithoutPathExpansion("status", &status_value)) { |
| 1064 { |
| 1065 if (!status_value->IsType(Value::TYPE_STRING)) |
| 1066 return false; |
| 1067 std::string temp; |
| 1068 if (status_value->GetAsString(&temp)) |
| 1069 out->status.reset(new std::string(temp)); |
| 1070 } |
| 1071 } |
| 1072 |
| 1073 Value* pinned_value = NULL; |
| 1074 if (dict->GetWithoutPathExpansion("pinned", &pinned_value)) { |
| 1075 { |
| 1076 if (!pinned_value->IsType(Value::TYPE_BOOLEAN)) |
| 1077 return false; |
| 1078 bool temp; |
| 1079 if (pinned_value->GetAsBoolean(&temp)) |
| 1080 out->pinned.reset(new bool(temp)); |
| 1081 } |
| 1082 } |
| 1083 |
| 1084 Value* index_value = NULL; |
| 1085 if (dict->GetWithoutPathExpansion("index", &index_value)) { |
| 1086 { |
| 1087 if (!index_value->IsType(Value::TYPE_INTEGER)) |
| 1088 return false; |
| 1089 int temp; |
| 1090 if (index_value->GetAsInteger(&temp)) |
| 1091 out->index.reset(new int(temp)); |
| 1092 } |
| 1093 } |
| 1094 |
| 1095 Value* url_value = NULL; |
| 1096 if (dict->GetWithoutPathExpansion("url", &url_value)) { |
| 1097 { |
| 1098 if (!url_value->IsType(Value::TYPE_STRING)) |
| 1099 return false; |
| 1100 std::string temp; |
| 1101 if (url_value->GetAsString(&temp)) |
| 1102 out->url.reset(new std::string(temp)); |
| 1103 } |
| 1104 } |
| 1105 |
| 1106 Value* title_value = NULL; |
| 1107 if (dict->GetWithoutPathExpansion("title", &title_value)) { |
| 1108 { |
| 1109 if (!title_value->IsType(Value::TYPE_STRING)) |
| 1110 return false; |
| 1111 std::string temp; |
| 1112 if (title_value->GetAsString(&temp)) |
| 1113 out->title.reset(new std::string(temp)); |
| 1114 } |
| 1115 } |
| 1116 |
| 1117 Value* highlighted_value = NULL; |
| 1118 if (dict->GetWithoutPathExpansion("highlighted", &highlighted_value)) { |
| 1119 { |
| 1120 if (!highlighted_value->IsType(Value::TYPE_BOOLEAN)) |
| 1121 return false; |
| 1122 bool temp; |
| 1123 if (highlighted_value->GetAsBoolean(&temp)) |
| 1124 out->highlighted.reset(new bool(temp)); |
| 1125 } |
| 1126 } |
| 1127 |
| 1128 Value* window_id_value = NULL; |
| 1129 if (dict->GetWithoutPathExpansion("windowId", &window_id_value)) { |
| 1130 { |
| 1131 if (!window_id_value->IsType(Value::TYPE_INTEGER)) |
| 1132 return false; |
| 1133 int temp; |
| 1134 if (window_id_value->GetAsInteger(&temp)) |
| 1135 out->window_id.reset(new int(temp)); |
| 1136 } |
| 1137 } |
| 1138 |
| 1139 Value* window_type_value = NULL; |
| 1140 if (dict->GetWithoutPathExpansion("windowType", &window_type_value)) { |
| 1141 { |
| 1142 if (!window_type_value->IsType(Value::TYPE_STRING)) |
| 1143 return false; |
| 1144 std::string temp; |
| 1145 if (window_type_value->GetAsString(&temp)) |
| 1146 out->window_type.reset(new std::string(temp)); |
| 1147 } |
| 1148 } |
| 1149 |
| 1150 Value* active_value = NULL; |
| 1151 if (dict->GetWithoutPathExpansion("active", &active_value)) { |
| 1152 { |
| 1153 if (!active_value->IsType(Value::TYPE_BOOLEAN)) |
| 1154 return false; |
| 1155 bool temp; |
| 1156 if (active_value->GetAsBoolean(&temp)) |
| 1157 out->active.reset(new bool(temp)); |
| 1158 } |
| 1159 } |
| 1160 |
| 1161 return true; |
| 1162 } |
| 1163 |
| 1164 |
| 1165 |
| 1166 Query::Params::Params() {} |
| 1167 Query::Params::~Params() {} |
| 1168 |
| 1169 // static |
| 1170 scoped_ptr<Query::Params> Query::Params::Create(const ListValue& args) { |
| 1171 if (args.GetSize() != 1) |
| 1172 return scoped_ptr<Params>(); |
| 1173 scoped_ptr<Params> params(new Params()); |
| 1174 |
| 1175 Value* query_info_value = NULL; |
| 1176 if (!args.Get(0, &query_info_value) || query_info_value->IsType(Value::TYPE_NU
LL)) |
| 1177 return scoped_ptr<Params>(); |
| 1178 { |
| 1179 if (!query_info_value->IsType(Value::TYPE_DICTIONARY)) |
| 1180 return scoped_ptr<Params>(); |
| 1181 DictionaryValue* dictionary = NULL; |
| 1182 if (!query_info_value->GetAsDictionary(&dictionary)) |
| 1183 return scoped_ptr<Params>(); |
| 1184 if (!QueryInfo::Populate(*dictionary, ¶ms->query_info)) |
| 1185 return scoped_ptr<Params>(); |
| 1186 } |
| 1187 |
| 1188 return params.Pass(); |
| 1189 } |
| 1190 |
| 1191 |
| 1192 Value* Query::Result::Create(const std::vector<linked_ptr<Tab> >& result) { |
| 1193 ListValue* value = new ListValue(); |
| 1194 json_schema_compiler::util::PopulateListFromArray(result, value); |
| 1195 return value; |
| 1196 } |
| 1197 |
| 1198 GetSelected::Params::Params() {} |
| 1199 GetSelected::Params::~Params() {} |
| 1200 |
| 1201 // static |
| 1202 scoped_ptr<GetSelected::Params> GetSelected::Params::Create(const ListValue& arg
s) { |
| 1203 if (args.GetSize() > 1) |
| 1204 return scoped_ptr<Params>(); |
| 1205 scoped_ptr<Params> params(new Params()); |
| 1206 |
| 1207 Value* window_id_value = NULL; |
| 1208 if (!args.Get(0, &window_id_value) || window_id_value->IsType(Value::TYPE_NULL
)) |
| 1209 return params.Pass(); |
| 1210 { |
| 1211 if (!window_id_value->IsType(Value::TYPE_INTEGER)) |
| 1212 return scoped_ptr<Params>(); |
| 1213 int temp; |
| 1214 if (window_id_value->GetAsInteger(&temp)) |
| 1215 params->window_id.reset(new int(temp)); |
| 1216 } |
| 1217 |
| 1218 return params.Pass(); |
| 1219 } |
| 1220 |
| 1221 |
| 1222 Value* GetSelected::Result::Create(const Tab& tab) { |
| 1223 return tab.ToValue().release(); |
| 1224 } |
| 1225 |
| 1226 GetAllInWindow::Params::Params() {} |
| 1227 GetAllInWindow::Params::~Params() {} |
| 1228 |
| 1229 // static |
| 1230 scoped_ptr<GetAllInWindow::Params> GetAllInWindow::Params::Create(const ListValu
e& args) { |
| 1231 if (args.GetSize() > 1) |
| 1232 return scoped_ptr<Params>(); |
| 1233 scoped_ptr<Params> params(new Params()); |
| 1234 |
| 1235 Value* window_id_value = NULL; |
| 1236 if (!args.Get(0, &window_id_value) || window_id_value->IsType(Value::TYPE_NULL
)) |
| 1237 return params.Pass(); |
| 1238 { |
| 1239 if (!window_id_value->IsType(Value::TYPE_INTEGER)) |
| 1240 return scoped_ptr<Params>(); |
| 1241 int temp; |
| 1242 if (window_id_value->GetAsInteger(&temp)) |
| 1243 params->window_id.reset(new int(temp)); |
| 1244 } |
| 1245 |
| 1246 return params.Pass(); |
| 1247 } |
| 1248 |
| 1249 |
| 1250 Value* GetAllInWindow::Result::Create(const std::vector<linked_ptr<Tab> >& tabs)
{ |
| 1251 ListValue* value = new ListValue(); |
| 1252 json_schema_compiler::util::PopulateListFromArray(tabs, value); |
| 1253 return value; |
| 1254 } |
| 1255 |
| 1256 } // tabs |
| 1257 } // api |
| 1258 } // extensions |
OLD | NEW |