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