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