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 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() > 2) |
| 136 return scoped_ptr<Params>(); |
| 137 if (args.GetSize() < 1) |
| 138 return scoped_ptr<Params>(); |
| 139 scoped_ptr<Params> params(new Params()); |
| 140 |
| 141 if (!args.GetInteger(0, params->tab_id.get())) |
| 142 return params.Pass(); |
| 143 |
| 144 DictionaryValue* details_param = NULL; |
| 145 if (!args.GetDictionary(1, &details_param)) |
| 146 return scoped_ptr<Params>(); |
| 147 if (!Details::Populate(*details_param, ¶ms->details)) |
| 148 return scoped_ptr<Params>(); |
| 149 |
| 150 return params.Pass(); |
| 151 } |
| 152 |
| 153 // static |
| 154 Value* ExecuteScript::Result::Create() { |
| 155 return Value::CreateNullValue(); |
| 156 } |
| 157 |
| 158 Get::Params::Params() {} |
| 159 Get::Params::~Params() {} |
| 160 |
| 161 // static |
| 162 scoped_ptr<Get::Params> Get::Params::Create(const ListValue& args) { |
| 163 if (args.GetSize() < 1) |
| 164 return scoped_ptr<Params>(); |
| 165 scoped_ptr<Params> params(new Params()); |
| 166 |
| 167 if (!args.GetInteger(0, ¶ms->tab_id)) |
| 168 return scoped_ptr<Params>(); |
| 169 |
| 170 return params.Pass(); |
| 171 } |
| 172 |
| 173 // static |
| 174 Value* Get::Result::Create(const Tab& tab) { |
| 175 return tab.ToValue(); |
| 176 } |
| 177 |
| 178 // static |
| 179 Value* GetCurrent::Result::Create(const scoped_ptr<Tab>& tab) { |
| 180 return tab->ToValue(); |
| 181 } |
| 182 |
| 183 Create::Params::CreateProperties::CreateProperties() {} |
| 184 Create::Params::CreateProperties::~CreateProperties() {} |
| 185 |
| 186 // static |
| 187 bool Create::Params::CreateProperties::Populate(const Value& value, CreateProper
ties* out) { |
| 188 if (!value.IsType(Value::TYPE_DICTIONARY)) |
| 189 return false; |
| 190 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value); |
| 191 |
| 192 { |
| 193 int index_temp; |
| 194 if (dict->GetInteger("index", &index_temp)) |
| 195 out->index.reset(new int(index_temp)); |
| 196 } |
| 197 { |
| 198 int opener_tab_id_temp; |
| 199 if (dict->GetInteger("openerTabId", &opener_tab_id_temp)) |
| 200 out->opener_tab_id.reset(new int(opener_tab_id_temp)); |
| 201 } |
| 202 { |
| 203 std::string url_temp; |
| 204 if (dict->GetString("url", &url_temp)) |
| 205 out->url.reset(new std::string(url_temp)); |
| 206 } |
| 207 { |
| 208 bool selected_temp; |
| 209 if (dict->GetBoolean("selected", &selected_temp)) |
| 210 out->selected.reset(new bool(selected_temp)); |
| 211 } |
| 212 { |
| 213 bool pinned_temp; |
| 214 if (dict->GetBoolean("pinned", &pinned_temp)) |
| 215 out->pinned.reset(new bool(pinned_temp)); |
| 216 } |
| 217 { |
| 218 int window_id_temp; |
| 219 if (dict->GetInteger("windowId", &window_id_temp)) |
| 220 out->window_id.reset(new int(window_id_temp)); |
| 221 } |
| 222 { |
| 223 bool active_temp; |
| 224 if (dict->GetBoolean("active", &active_temp)) |
| 225 out->active.reset(new bool(active_temp)); |
| 226 } |
| 227 return true; |
| 228 } |
| 229 |
| 230 |
| 231 |
| 232 Create::Params::Params() {} |
| 233 Create::Params::~Params() {} |
| 234 |
| 235 // static |
| 236 scoped_ptr<Create::Params> Create::Params::Create(const ListValue& args) { |
| 237 if (args.GetSize() < 1) |
| 238 return scoped_ptr<Params>(); |
| 239 scoped_ptr<Params> params(new Params()); |
| 240 |
| 241 DictionaryValue* create_properties_param = NULL; |
| 242 if (!args.GetDictionary(0, &create_properties_param)) |
| 243 return scoped_ptr<Params>(); |
| 244 if (!CreateProperties::Populate(*create_properties_param, ¶ms->create_prop
erties)) |
| 245 return scoped_ptr<Params>(); |
| 246 |
| 247 return params.Pass(); |
| 248 } |
| 249 |
| 250 // static |
| 251 // Details about the created tab. Will contain the ID of the new tab. |
| 252 Value* Create::Result::Create(const Tab& tab) { |
| 253 return tab.ToValue(); |
| 254 } |
| 255 |
| 256 Move::Params::MoveProperties::MoveProperties() {} |
| 257 Move::Params::MoveProperties::~MoveProperties() {} |
| 258 |
| 259 // static |
| 260 bool Move::Params::MoveProperties::Populate(const Value& value, MoveProperties*
out) { |
| 261 if (!value.IsType(Value::TYPE_DICTIONARY)) |
| 262 return false; |
| 263 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value); |
| 264 |
| 265 if (!dict->GetInteger("index", &out->index)) |
| 266 return false; |
| 267 { |
| 268 int window_id_temp; |
| 269 if (dict->GetInteger("windowId", &window_id_temp)) |
| 270 out->window_id.reset(new int(window_id_temp)); |
| 271 } |
| 272 return true; |
| 273 } |
| 274 |
| 275 |
| 276 |
| 277 Move::Params::Params() {} |
| 278 Move::Params::~Params() {} |
| 279 |
| 280 // static |
| 281 scoped_ptr<Move::Params> Move::Params::Create(const ListValue& args) { |
| 282 if (args.GetSize() < 2) |
| 283 return scoped_ptr<Params>(); |
| 284 scoped_ptr<Params> params(new Params()); |
| 285 |
| 286 params->tab_ids_type = TAB_IDS_NONE; |
| 287 Value* tab_ids_value = NULL; |
| 288 if (!args.Get(0, &tab_ids_value)) |
| 289 return scoped_ptr<Params>(); |
| 290 switch (tab_ids_value->GetType()) { |
| 291 case Value::TYPE_INTEGER: { |
| 292 params->tab_ids_type = TAB_IDS_INTEGER; |
| 293 tab_ids_value->GetAsInteger(params->tab_ids_integer.get()); |
| 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 // static |
| 316 Value* Move::Result::Create(const scoped_ptr<Tab>& tabs_ref) { |
| 317 return tabs_ref->ToValue(); |
| 318 } |
| 319 Value* Move::Result::Create(const scoped_ptr<std::vector<linked_ptr<Tab> > > tab
s_array) { |
| 320 ListValue* value = new ListValue(); |
| 321 json_schema_compiler::util::SetOptionalArrayToList(tabs_array, value); |
| 322 return value; |
| 323 } |
| 324 |
| 325 Update::Params::UpdateProperties::UpdateProperties() {} |
| 326 Update::Params::UpdateProperties::~UpdateProperties() {} |
| 327 |
| 328 // static |
| 329 bool Update::Params::UpdateProperties::Populate(const Value& value, UpdateProper
ties* out) { |
| 330 if (!value.IsType(Value::TYPE_DICTIONARY)) |
| 331 return false; |
| 332 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value); |
| 333 |
| 334 { |
| 335 bool highlighted_temp; |
| 336 if (dict->GetBoolean("highlighted", &highlighted_temp)) |
| 337 out->highlighted.reset(new bool(highlighted_temp)); |
| 338 } |
| 339 { |
| 340 int opener_tab_id_temp; |
| 341 if (dict->GetInteger("openerTabId", &opener_tab_id_temp)) |
| 342 out->opener_tab_id.reset(new int(opener_tab_id_temp)); |
| 343 } |
| 344 { |
| 345 std::string url_temp; |
| 346 if (dict->GetString("url", &url_temp)) |
| 347 out->url.reset(new std::string(url_temp)); |
| 348 } |
| 349 { |
| 350 bool selected_temp; |
| 351 if (dict->GetBoolean("selected", &selected_temp)) |
| 352 out->selected.reset(new bool(selected_temp)); |
| 353 } |
| 354 { |
| 355 bool pinned_temp; |
| 356 if (dict->GetBoolean("pinned", &pinned_temp)) |
| 357 out->pinned.reset(new bool(pinned_temp)); |
| 358 } |
| 359 { |
| 360 bool active_temp; |
| 361 if (dict->GetBoolean("active", &active_temp)) |
| 362 out->active.reset(new bool(active_temp)); |
| 363 } |
| 364 return true; |
| 365 } |
| 366 |
| 367 |
| 368 |
| 369 Update::Params::Params() {} |
| 370 Update::Params::~Params() {} |
| 371 |
| 372 // static |
| 373 scoped_ptr<Update::Params> Update::Params::Create(const ListValue& args) { |
| 374 if (args.GetSize() > 2) |
| 375 return scoped_ptr<Params>(); |
| 376 if (args.GetSize() < 1) |
| 377 return scoped_ptr<Params>(); |
| 378 scoped_ptr<Params> params(new Params()); |
| 379 |
| 380 if (!args.GetInteger(0, params->tab_id.get())) |
| 381 return params.Pass(); |
| 382 |
| 383 DictionaryValue* update_properties_param = NULL; |
| 384 if (!args.GetDictionary(1, &update_properties_param)) |
| 385 return scoped_ptr<Params>(); |
| 386 if (!UpdateProperties::Populate(*update_properties_param, ¶ms->update_prop
erties)) |
| 387 return scoped_ptr<Params>(); |
| 388 |
| 389 return params.Pass(); |
| 390 } |
| 391 |
| 392 // static |
| 393 // Details about the updated tab, or <code>null</code> if the 'tabs' permission |
| 394 // has not been requested. |
| 395 Value* Update::Result::Create(const scoped_ptr<Tab>& tab) { |
| 396 return tab->ToValue(); |
| 397 } |
| 398 |
| 399 Remove::Params::Params() {} |
| 400 Remove::Params::~Params() {} |
| 401 |
| 402 // static |
| 403 scoped_ptr<Remove::Params> Remove::Params::Create(const ListValue& args) { |
| 404 if (args.GetSize() < 1) |
| 405 return scoped_ptr<Params>(); |
| 406 scoped_ptr<Params> params(new Params()); |
| 407 |
| 408 params->tab_ids_type = TAB_IDS_NONE; |
| 409 Value* tab_ids_value = NULL; |
| 410 if (!args.Get(0, &tab_ids_value)) |
| 411 return scoped_ptr<Params>(); |
| 412 switch (tab_ids_value->GetType()) { |
| 413 case Value::TYPE_INTEGER: { |
| 414 params->tab_ids_type = TAB_IDS_INTEGER; |
| 415 tab_ids_value->GetAsInteger(params->tab_ids_integer.get()); |
| 416 break; |
| 417 } |
| 418 case Value::TYPE_LIST: { |
| 419 params->tab_ids_type = TAB_IDS_ARRAY; |
| 420 if (!json_schema_compiler::util::GetOptionalArrayFromList(*static_cast<Lis
tValue*>(tab_ids_value), ¶ms->tab_ids_array)) |
| 421 return scoped_ptr<Params>(); |
| 422 break; |
| 423 } |
| 424 default: |
| 425 return scoped_ptr<Params>(); |
| 426 } |
| 427 |
| 428 return params.Pass(); |
| 429 } |
| 430 |
| 431 // static |
| 432 Value* Remove::Result::Create() { |
| 433 return Value::CreateNullValue(); |
| 434 } |
| 435 |
| 436 CaptureVisibleTab::Params::Options::Options() {} |
| 437 CaptureVisibleTab::Params::Options::~Options() {} |
| 438 |
| 439 // static |
| 440 bool CaptureVisibleTab::Params::Options::Populate(const Value& value, Options* o
ut) { |
| 441 if (!value.IsType(Value::TYPE_DICTIONARY)) |
| 442 return false; |
| 443 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value); |
| 444 |
| 445 { |
| 446 int quality_temp; |
| 447 if (dict->GetInteger("quality", &quality_temp)) |
| 448 out->quality.reset(new int(quality_temp)); |
| 449 } |
| 450 { |
| 451 std::string format_temp; |
| 452 if (dict->GetString("format", &format_temp)) |
| 453 out->format.reset(new std::string(format_temp)); |
| 454 } |
| 455 return true; |
| 456 } |
| 457 |
| 458 |
| 459 |
| 460 CaptureVisibleTab::Params::Params() {} |
| 461 CaptureVisibleTab::Params::~Params() {} |
| 462 |
| 463 // static |
| 464 scoped_ptr<CaptureVisibleTab::Params> CaptureVisibleTab::Params::Create(const Li
stValue& args) { |
| 465 if (args.GetSize() > 2) |
| 466 return scoped_ptr<Params>(); |
| 467 scoped_ptr<Params> params(new Params()); |
| 468 |
| 469 if (!args.GetInteger(0, params->window_id.get())) |
| 470 return params.Pass(); |
| 471 |
| 472 DictionaryValue* options_param = NULL; |
| 473 if (!args.GetDictionary(1, &options_param)) |
| 474 return params.Pass(); |
| 475 params->options.reset(new Options()); |
| 476 if (!Options::Populate(*options_param, params->options.get())) |
| 477 return params.Pass(); |
| 478 |
| 479 return params.Pass(); |
| 480 } |
| 481 |
| 482 // static |
| 483 // A data URL which encodes an image of the visible area of the captured tab. |
| 484 // May be assigned to the 'src' property of an HTML Image element for display. |
| 485 Value* CaptureVisibleTab::Result::Create(const std::string data_url) { |
| 486 return Value::CreateStringValue(data_url); |
| 487 } |
| 488 |
| 489 Reload::Params::ReloadProperties::ReloadProperties() {} |
| 490 Reload::Params::ReloadProperties::~ReloadProperties() {} |
| 491 |
| 492 // static |
| 493 bool Reload::Params::ReloadProperties::Populate(const Value& value, ReloadProper
ties* out) { |
| 494 if (!value.IsType(Value::TYPE_DICTIONARY)) |
| 495 return false; |
| 496 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value); |
| 497 |
| 498 { |
| 499 bool bypass_cache_temp; |
| 500 if (dict->GetBoolean("bypassCache", &bypass_cache_temp)) |
| 501 out->bypass_cache.reset(new bool(bypass_cache_temp)); |
| 502 } |
| 503 return true; |
| 504 } |
| 505 |
| 506 |
| 507 |
| 508 Reload::Params::Params() {} |
| 509 Reload::Params::~Params() {} |
| 510 |
| 511 // static |
| 512 scoped_ptr<Reload::Params> Reload::Params::Create(const ListValue& args) { |
| 513 if (args.GetSize() > 2) |
| 514 return scoped_ptr<Params>(); |
| 515 scoped_ptr<Params> params(new Params()); |
| 516 |
| 517 if (!args.GetInteger(0, params->tab_id.get())) |
| 518 return params.Pass(); |
| 519 |
| 520 DictionaryValue* reload_properties_param = NULL; |
| 521 if (!args.GetDictionary(1, &reload_properties_param)) |
| 522 return params.Pass(); |
| 523 params->reload_properties.reset(new ReloadProperties()); |
| 524 if (!ReloadProperties::Populate(*reload_properties_param, params->reload_prope
rties.get())) |
| 525 return params.Pass(); |
| 526 |
| 527 return params.Pass(); |
| 528 } |
| 529 |
| 530 // static |
| 531 Value* Reload::Result::Create() { |
| 532 return Value::CreateNullValue(); |
| 533 } |
| 534 |
| 535 DetectLanguage::Params::Params() {} |
| 536 DetectLanguage::Params::~Params() {} |
| 537 |
| 538 // static |
| 539 scoped_ptr<DetectLanguage::Params> DetectLanguage::Params::Create(const ListValu
e& args) { |
| 540 if (args.GetSize() > 1) |
| 541 return scoped_ptr<Params>(); |
| 542 scoped_ptr<Params> params(new Params()); |
| 543 |
| 544 if (!args.GetInteger(0, params->tab_id.get())) |
| 545 return params.Pass(); |
| 546 |
| 547 return params.Pass(); |
| 548 } |
| 549 |
| 550 // static |
| 551 // An ISO language code such as <code>en</code> or <code>fr</code>. For a |
| 552 // complete list of languages supported by this method, see <a |
| 553 // href='http://src.chromium.org/viewvc/chrome/trunk/src/third_party/cld/languag |
| 554 // es/internal/languages.cc'>kLanguageInfoTable</a>. The 2nd to 4th columns |
| 555 // will be checked and the first non-NULL value will be returned except for |
| 556 // Simplified Chinese for which zh-CN will be returned. For an unknown |
| 557 // language, <code>und</code> will be returned. |
| 558 Value* DetectLanguage::Result::Create(const std::string language) { |
| 559 return Value::CreateStringValue(language); |
| 560 } |
| 561 |
| 562 InsertCSS::Params::Details::Details() {} |
| 563 InsertCSS::Params::Details::~Details() {} |
| 564 |
| 565 // static |
| 566 bool InsertCSS::Params::Details::Populate(const Value& value, Details* out) { |
| 567 if (!value.IsType(Value::TYPE_DICTIONARY)) |
| 568 return false; |
| 569 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value); |
| 570 |
| 571 { |
| 572 bool all_frames_temp; |
| 573 if (dict->GetBoolean("allFrames", &all_frames_temp)) |
| 574 out->all_frames.reset(new bool(all_frames_temp)); |
| 575 } |
| 576 { |
| 577 std::string code_temp; |
| 578 if (dict->GetString("code", &code_temp)) |
| 579 out->code.reset(new std::string(code_temp)); |
| 580 } |
| 581 { |
| 582 std::string file_temp; |
| 583 if (dict->GetString("file", &file_temp)) |
| 584 out->file.reset(new std::string(file_temp)); |
| 585 } |
| 586 return true; |
| 587 } |
| 588 |
| 589 |
| 590 |
| 591 InsertCSS::Params::Params() {} |
| 592 InsertCSS::Params::~Params() {} |
| 593 |
| 594 // static |
| 595 scoped_ptr<InsertCSS::Params> InsertCSS::Params::Create(const ListValue& args) { |
| 596 if (args.GetSize() > 2) |
| 597 return scoped_ptr<Params>(); |
| 598 if (args.GetSize() < 1) |
| 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, ¶ms->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 if (!json_schema_compiler::util::GetOptionalArrayFromDictionary(*dict, "tabs",
&out->tabs_array)) |
| 629 return false; |
| 630 { |
| 631 int tabs_integer_temp; |
| 632 if (dict->GetInteger("tabs", &tabs_integer_temp)) { |
| 633 out->tabs_integer.reset(new int(tabs_integer_temp)); |
| 634 out->tabs_type = TABS_INTEGER; |
| 635 } |
| 636 } |
| 637 if (!dict->GetInteger("windowId", &out->window_id)) |
| 638 return false; |
| 639 return true; |
| 640 } |
| 641 |
| 642 |
| 643 |
| 644 Highlight::Params::Params() {} |
| 645 Highlight::Params::~Params() {} |
| 646 |
| 647 // static |
| 648 scoped_ptr<Highlight::Params> Highlight::Params::Create(const ListValue& args) { |
| 649 if (args.GetSize() < 1) |
| 650 return scoped_ptr<Params>(); |
| 651 scoped_ptr<Params> params(new Params()); |
| 652 |
| 653 DictionaryValue* highlight_info_param = NULL; |
| 654 if (!args.GetDictionary(0, &highlight_info_param)) |
| 655 return scoped_ptr<Params>(); |
| 656 if (!HighlightInfo::Populate(*highlight_info_param, ¶ms->highlight_info)) |
| 657 return scoped_ptr<Params>(); |
| 658 |
| 659 return params.Pass(); |
| 660 } |
| 661 |
| 662 // static |
| 663 // Contains details about the window whose tabs were highlighted. |
| 664 Value* Highlight::Result::Create(const windows::Window& window) { |
| 665 return window.ToValue(); |
| 666 } |
| 667 |
| 668 Query::Params::QueryInfo::QueryInfo() {} |
| 669 Query::Params::QueryInfo::~QueryInfo() {} |
| 670 |
| 671 // static |
| 672 bool Query::Params::QueryInfo::Populate(const Value& value, QueryInfo* out) { |
| 673 if (!value.IsType(Value::TYPE_DICTIONARY)) |
| 674 return false; |
| 675 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value); |
| 676 |
| 677 { |
| 678 std::string status_temp; |
| 679 if (dict->GetString("status", &status_temp)) |
| 680 out->status.reset(new std::string(status_temp)); |
| 681 } |
| 682 { |
| 683 bool pinned_temp; |
| 684 if (dict->GetBoolean("pinned", &pinned_temp)) |
| 685 out->pinned.reset(new bool(pinned_temp)); |
| 686 } |
| 687 { |
| 688 int index_temp; |
| 689 if (dict->GetInteger("index", &index_temp)) |
| 690 out->index.reset(new int(index_temp)); |
| 691 } |
| 692 { |
| 693 std::string url_temp; |
| 694 if (dict->GetString("url", &url_temp)) |
| 695 out->url.reset(new std::string(url_temp)); |
| 696 } |
| 697 { |
| 698 std::string title_temp; |
| 699 if (dict->GetString("title", &title_temp)) |
| 700 out->title.reset(new std::string(title_temp)); |
| 701 } |
| 702 { |
| 703 bool highlighted_temp; |
| 704 if (dict->GetBoolean("highlighted", &highlighted_temp)) |
| 705 out->highlighted.reset(new bool(highlighted_temp)); |
| 706 } |
| 707 { |
| 708 int window_id_temp; |
| 709 if (dict->GetInteger("windowId", &window_id_temp)) |
| 710 out->window_id.reset(new int(window_id_temp)); |
| 711 } |
| 712 { |
| 713 std::string window_type_temp; |
| 714 if (dict->GetString("windowType", &window_type_temp)) |
| 715 out->window_type.reset(new std::string(window_type_temp)); |
| 716 } |
| 717 { |
| 718 bool active_temp; |
| 719 if (dict->GetBoolean("active", &active_temp)) |
| 720 out->active.reset(new bool(active_temp)); |
| 721 } |
| 722 return true; |
| 723 } |
| 724 |
| 725 |
| 726 |
| 727 Query::Params::Params() {} |
| 728 Query::Params::~Params() {} |
| 729 |
| 730 // static |
| 731 scoped_ptr<Query::Params> Query::Params::Create(const ListValue& args) { |
| 732 if (args.GetSize() < 1) |
| 733 return scoped_ptr<Params>(); |
| 734 scoped_ptr<Params> params(new Params()); |
| 735 |
| 736 DictionaryValue* query_info_param = NULL; |
| 737 if (!args.GetDictionary(0, &query_info_param)) |
| 738 return scoped_ptr<Params>(); |
| 739 if (!QueryInfo::Populate(*query_info_param, ¶ms->query_info)) |
| 740 return scoped_ptr<Params>(); |
| 741 |
| 742 return params.Pass(); |
| 743 } |
| 744 |
| 745 // static |
| 746 Value* Query::Result::Create(const std::vector<linked_ptr<Tab> > result) { |
| 747 ListValue* value = new ListValue(); |
| 748 json_schema_compiler::util::SetArrayToList(result, value); |
| 749 return value; |
| 750 } |
| 751 |
| 752 GetSelected::Params::Params() {} |
| 753 GetSelected::Params::~Params() {} |
| 754 |
| 755 // static |
| 756 scoped_ptr<GetSelected::Params> GetSelected::Params::Create(const ListValue& arg
s) { |
| 757 if (args.GetSize() > 1) |
| 758 return scoped_ptr<Params>(); |
| 759 scoped_ptr<Params> params(new Params()); |
| 760 |
| 761 if (!args.GetInteger(0, params->window_id.get())) |
| 762 return params.Pass(); |
| 763 |
| 764 return params.Pass(); |
| 765 } |
| 766 |
| 767 // static |
| 768 Value* GetSelected::Result::Create(const Tab& tab) { |
| 769 return tab.ToValue(); |
| 770 } |
| 771 |
| 772 GetAllInWindow::Params::Params() {} |
| 773 GetAllInWindow::Params::~Params() {} |
| 774 |
| 775 // static |
| 776 scoped_ptr<GetAllInWindow::Params> GetAllInWindow::Params::Create(const ListValu
e& args) { |
| 777 if (args.GetSize() > 1) |
| 778 return scoped_ptr<Params>(); |
| 779 scoped_ptr<Params> params(new Params()); |
| 780 |
| 781 if (!args.GetInteger(0, params->window_id.get())) |
| 782 return params.Pass(); |
| 783 |
| 784 return params.Pass(); |
| 785 } |
| 786 |
| 787 // static |
| 788 Value* GetAllInWindow::Result::Create(const std::vector<linked_ptr<Tab> > tabs)
{ |
| 789 ListValue* value = new ListValue(); |
| 790 json_schema_compiler::util::SetArrayToList(tabs, value); |
| 791 return value; |
| 792 } |
| 793 |
| 794 } // tabs |
| 795 } // api |
| 796 } // extensions |
OLD | NEW |