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/windows.json |
| 7 // DO NOT EDIT. |
| 8 |
| 9 #include "tools/json_schema_compiler/util.h" |
| 10 #include "chrome/common/extensions/api/windows.h" |
| 11 #include "chrome/common/extensions/api/tabs.h" |
| 12 |
| 13 |
| 14 using base::Value; |
| 15 using base::DictionaryValue; |
| 16 using base::ListValue; |
| 17 |
| 18 namespace extensions { |
| 19 namespace api { |
| 20 namespace windows { |
| 21 |
| 22 // |
| 23 // Types |
| 24 // |
| 25 |
| 26 Window::Window() {} |
| 27 Window::~Window() {} |
| 28 |
| 29 // static |
| 30 bool Window::Populate(const Value& value, Window* out) { |
| 31 if (!value.IsType(Value::TYPE_DICTIONARY)) |
| 32 return false; |
| 33 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value); |
| 34 |
| 35 Value* tabs_value = NULL; |
| 36 if (dict->GetWithoutPathExpansion("tabs", &tabs_value)) { |
| 37 { |
| 38 if (!tabs_value->IsType(Value::TYPE_LIST)) |
| 39 return false; |
| 40 ListValue* list = NULL; |
| 41 if (!tabs_value->GetAsList(&list)) |
| 42 return false; |
| 43 if (!json_schema_compiler::util::PopulateOptionalArrayFromList(*list, &out
->tabs)) |
| 44 return false; |
| 45 } |
| 46 } |
| 47 |
| 48 Value* top_value = NULL; |
| 49 if (!dict->GetWithoutPathExpansion("top", &top_value)) |
| 50 return false; |
| 51 { |
| 52 if (!top_value->IsType(Value::TYPE_INTEGER)) |
| 53 return false; |
| 54 if (!top_value->GetAsInteger(&out->top)) |
| 55 return false; |
| 56 } |
| 57 |
| 58 Value* height_value = NULL; |
| 59 if (!dict->GetWithoutPathExpansion("height", &height_value)) |
| 60 return false; |
| 61 { |
| 62 if (!height_value->IsType(Value::TYPE_INTEGER)) |
| 63 return false; |
| 64 if (!height_value->GetAsInteger(&out->height)) |
| 65 return false; |
| 66 } |
| 67 |
| 68 Value* width_value = NULL; |
| 69 if (!dict->GetWithoutPathExpansion("width", &width_value)) |
| 70 return false; |
| 71 { |
| 72 if (!width_value->IsType(Value::TYPE_INTEGER)) |
| 73 return false; |
| 74 if (!width_value->GetAsInteger(&out->width)) |
| 75 return false; |
| 76 } |
| 77 |
| 78 Value* state_value = NULL; |
| 79 if (!dict->GetWithoutPathExpansion("state", &state_value)) |
| 80 return false; |
| 81 { |
| 82 if (!state_value->IsType(Value::TYPE_STRING)) |
| 83 return false; |
| 84 if (!state_value->GetAsString(&out->state)) |
| 85 return false; |
| 86 } |
| 87 |
| 88 Value* focused_value = NULL; |
| 89 if (!dict->GetWithoutPathExpansion("focused", &focused_value)) |
| 90 return false; |
| 91 { |
| 92 if (!focused_value->IsType(Value::TYPE_BOOLEAN)) |
| 93 return false; |
| 94 if (!focused_value->GetAsBoolean(&out->focused)) |
| 95 return false; |
| 96 } |
| 97 |
| 98 Value* left_value = NULL; |
| 99 if (!dict->GetWithoutPathExpansion("left", &left_value)) |
| 100 return false; |
| 101 { |
| 102 if (!left_value->IsType(Value::TYPE_INTEGER)) |
| 103 return false; |
| 104 if (!left_value->GetAsInteger(&out->left)) |
| 105 return false; |
| 106 } |
| 107 |
| 108 Value* type_value = NULL; |
| 109 if (!dict->GetWithoutPathExpansion("type", &type_value)) |
| 110 return false; |
| 111 { |
| 112 if (!type_value->IsType(Value::TYPE_STRING)) |
| 113 return false; |
| 114 if (!type_value->GetAsString(&out->type)) |
| 115 return false; |
| 116 } |
| 117 |
| 118 Value* id_value = NULL; |
| 119 if (!dict->GetWithoutPathExpansion("id", &id_value)) |
| 120 return false; |
| 121 { |
| 122 if (!id_value->IsType(Value::TYPE_INTEGER)) |
| 123 return false; |
| 124 if (!id_value->GetAsInteger(&out->id)) |
| 125 return false; |
| 126 } |
| 127 |
| 128 Value* incognito_value = NULL; |
| 129 if (!dict->GetWithoutPathExpansion("incognito", &incognito_value)) |
| 130 return false; |
| 131 { |
| 132 if (!incognito_value->IsType(Value::TYPE_BOOLEAN)) |
| 133 return false; |
| 134 if (!incognito_value->GetAsBoolean(&out->incognito)) |
| 135 return false; |
| 136 } |
| 137 |
| 138 return true; |
| 139 } |
| 140 |
| 141 scoped_ptr<DictionaryValue> Window::ToValue() const { |
| 142 scoped_ptr<DictionaryValue> value(new DictionaryValue()); |
| 143 |
| 144 if (tabs.get()) |
| 145 json_schema_compiler::util::PopulateDictionaryFromOptionalArray(tabs, "tabs"
, value.get()); |
| 146 value->SetWithoutPathExpansion("top", Value::CreateIntegerValue(top)); |
| 147 value->SetWithoutPathExpansion("height", Value::CreateIntegerValue(height)); |
| 148 value->SetWithoutPathExpansion("width", Value::CreateIntegerValue(width)); |
| 149 value->SetWithoutPathExpansion("state", Value::CreateStringValue(state)); |
| 150 value->SetWithoutPathExpansion("focused", Value::CreateBooleanValue(focused)); |
| 151 value->SetWithoutPathExpansion("left", Value::CreateIntegerValue(left)); |
| 152 value->SetWithoutPathExpansion("type", Value::CreateStringValue(type)); |
| 153 value->SetWithoutPathExpansion("id", Value::CreateIntegerValue(id)); |
| 154 value->SetWithoutPathExpansion("incognito", Value::CreateBooleanValue(incognit
o)); |
| 155 |
| 156 return value.Pass(); |
| 157 } |
| 158 |
| 159 |
| 160 // |
| 161 // Functions |
| 162 // |
| 163 |
| 164 Get::Params::GetInfo::GetInfo() {} |
| 165 Get::Params::GetInfo::~GetInfo() {} |
| 166 |
| 167 // static |
| 168 bool Get::Params::GetInfo::Populate(const Value& value, GetInfo* out) { |
| 169 if (!value.IsType(Value::TYPE_DICTIONARY)) |
| 170 return false; |
| 171 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value); |
| 172 |
| 173 Value* populate_value = NULL; |
| 174 if (dict->GetWithoutPathExpansion("populate", &populate_value)) { |
| 175 { |
| 176 if (!populate_value->IsType(Value::TYPE_BOOLEAN)) |
| 177 return false; |
| 178 bool temp; |
| 179 if (populate_value->GetAsBoolean(&temp)) |
| 180 out->populate.reset(new bool(temp)); |
| 181 } |
| 182 } |
| 183 |
| 184 return true; |
| 185 } |
| 186 |
| 187 |
| 188 |
| 189 Get::Params::Params() {} |
| 190 Get::Params::~Params() {} |
| 191 |
| 192 // static |
| 193 scoped_ptr<Get::Params> Get::Params::Create(const ListValue& args) { |
| 194 if (args.GetSize() < 1 || args.GetSize() > 2) |
| 195 return scoped_ptr<Params>(); |
| 196 scoped_ptr<Params> params(new Params()); |
| 197 |
| 198 Value* window_id_value = NULL; |
| 199 if (!args.Get(0, &window_id_value) || window_id_value->IsType(Value::TYPE_NULL
)) |
| 200 return scoped_ptr<Params>(); |
| 201 { |
| 202 if (!window_id_value->IsType(Value::TYPE_INTEGER)) |
| 203 return scoped_ptr<Params>(); |
| 204 if (!window_id_value->GetAsInteger(¶ms->window_id)) |
| 205 return scoped_ptr<Params>(); |
| 206 } |
| 207 |
| 208 Value* get_info_value = NULL; |
| 209 if (!args.Get(1, &get_info_value) || get_info_value->IsType(Value::TYPE_NULL)) |
| 210 return params.Pass(); |
| 211 { |
| 212 if (!get_info_value->IsType(Value::TYPE_DICTIONARY)) |
| 213 return scoped_ptr<Params>(); |
| 214 DictionaryValue* dictionary = NULL; |
| 215 if (!get_info_value->GetAsDictionary(&dictionary)) |
| 216 return scoped_ptr<Params>(); |
| 217 scoped_ptr<GetInfo> temp(new GetInfo()); |
| 218 if (!GetInfo::Populate(*dictionary, temp.get())) |
| 219 return scoped_ptr<Params>(); |
| 220 params->get_info = temp.Pass(); |
| 221 } |
| 222 |
| 223 return params.Pass(); |
| 224 } |
| 225 |
| 226 |
| 227 Value* Get::Result::Create(const Window& window) { |
| 228 return window.ToValue().release(); |
| 229 } |
| 230 |
| 231 GetCurrent::Params::GetInfo::GetInfo() {} |
| 232 GetCurrent::Params::GetInfo::~GetInfo() {} |
| 233 |
| 234 // static |
| 235 bool GetCurrent::Params::GetInfo::Populate(const Value& value, GetInfo* out) { |
| 236 if (!value.IsType(Value::TYPE_DICTIONARY)) |
| 237 return false; |
| 238 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value); |
| 239 |
| 240 Value* populate_value = NULL; |
| 241 if (dict->GetWithoutPathExpansion("populate", &populate_value)) { |
| 242 { |
| 243 if (!populate_value->IsType(Value::TYPE_BOOLEAN)) |
| 244 return false; |
| 245 bool temp; |
| 246 if (populate_value->GetAsBoolean(&temp)) |
| 247 out->populate.reset(new bool(temp)); |
| 248 } |
| 249 } |
| 250 |
| 251 return true; |
| 252 } |
| 253 |
| 254 |
| 255 |
| 256 GetCurrent::Params::Params() {} |
| 257 GetCurrent::Params::~Params() {} |
| 258 |
| 259 // static |
| 260 scoped_ptr<GetCurrent::Params> GetCurrent::Params::Create(const ListValue& args)
{ |
| 261 if (args.GetSize() > 1) |
| 262 return scoped_ptr<Params>(); |
| 263 scoped_ptr<Params> params(new Params()); |
| 264 |
| 265 Value* get_info_value = NULL; |
| 266 if (!args.Get(0, &get_info_value) || get_info_value->IsType(Value::TYPE_NULL)) |
| 267 return params.Pass(); |
| 268 { |
| 269 if (!get_info_value->IsType(Value::TYPE_DICTIONARY)) |
| 270 return scoped_ptr<Params>(); |
| 271 DictionaryValue* dictionary = NULL; |
| 272 if (!get_info_value->GetAsDictionary(&dictionary)) |
| 273 return scoped_ptr<Params>(); |
| 274 scoped_ptr<GetInfo> temp(new GetInfo()); |
| 275 if (!GetInfo::Populate(*dictionary, temp.get())) |
| 276 return scoped_ptr<Params>(); |
| 277 params->get_info = temp.Pass(); |
| 278 } |
| 279 |
| 280 return params.Pass(); |
| 281 } |
| 282 |
| 283 |
| 284 Value* GetCurrent::Result::Create(const Window& window) { |
| 285 return window.ToValue().release(); |
| 286 } |
| 287 |
| 288 Create::Params::CreateData::CreateData() {} |
| 289 Create::Params::CreateData::~CreateData() {} |
| 290 |
| 291 // static |
| 292 bool Create::Params::CreateData::Populate(const Value& value, CreateData* out) { |
| 293 if (!value.IsType(Value::TYPE_DICTIONARY)) |
| 294 return false; |
| 295 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value); |
| 296 |
| 297 Value* tab_id_value = NULL; |
| 298 if (dict->GetWithoutPathExpansion("tabId", &tab_id_value)) { |
| 299 { |
| 300 if (!tab_id_value->IsType(Value::TYPE_INTEGER)) |
| 301 return false; |
| 302 int temp; |
| 303 if (tab_id_value->GetAsInteger(&temp)) |
| 304 out->tab_id.reset(new int(temp)); |
| 305 } |
| 306 } |
| 307 |
| 308 Value* url_value = NULL; |
| 309 if (dict->GetWithoutPathExpansion("url", &url_value)) { |
| 310 { |
| 311 if (!url_value->IsType(Value::TYPE_STRING)) |
| 312 return false; |
| 313 std::string temp; |
| 314 if (url_value->GetAsString(&temp)) |
| 315 out->url.reset(new std::string(temp)); |
| 316 } |
| 317 } |
| 318 |
| 319 Value* top_value = NULL; |
| 320 if (dict->GetWithoutPathExpansion("top", &top_value)) { |
| 321 { |
| 322 if (!top_value->IsType(Value::TYPE_INTEGER)) |
| 323 return false; |
| 324 int temp; |
| 325 if (top_value->GetAsInteger(&temp)) |
| 326 out->top.reset(new int(temp)); |
| 327 } |
| 328 } |
| 329 |
| 330 Value* height_value = NULL; |
| 331 if (dict->GetWithoutPathExpansion("height", &height_value)) { |
| 332 { |
| 333 if (!height_value->IsType(Value::TYPE_INTEGER)) |
| 334 return false; |
| 335 int temp; |
| 336 if (height_value->GetAsInteger(&temp)) |
| 337 out->height.reset(new int(temp)); |
| 338 } |
| 339 } |
| 340 |
| 341 Value* width_value = NULL; |
| 342 if (dict->GetWithoutPathExpansion("width", &width_value)) { |
| 343 { |
| 344 if (!width_value->IsType(Value::TYPE_INTEGER)) |
| 345 return false; |
| 346 int temp; |
| 347 if (width_value->GetAsInteger(&temp)) |
| 348 out->width.reset(new int(temp)); |
| 349 } |
| 350 } |
| 351 |
| 352 Value* focused_value = NULL; |
| 353 if (dict->GetWithoutPathExpansion("focused", &focused_value)) { |
| 354 { |
| 355 if (!focused_value->IsType(Value::TYPE_BOOLEAN)) |
| 356 return false; |
| 357 bool temp; |
| 358 if (focused_value->GetAsBoolean(&temp)) |
| 359 out->focused.reset(new bool(temp)); |
| 360 } |
| 361 } |
| 362 |
| 363 Value* left_value = NULL; |
| 364 if (dict->GetWithoutPathExpansion("left", &left_value)) { |
| 365 { |
| 366 if (!left_value->IsType(Value::TYPE_INTEGER)) |
| 367 return false; |
| 368 int temp; |
| 369 if (left_value->GetAsInteger(&temp)) |
| 370 out->left.reset(new int(temp)); |
| 371 } |
| 372 } |
| 373 |
| 374 Value* type_value = NULL; |
| 375 if (dict->GetWithoutPathExpansion("type", &type_value)) { |
| 376 { |
| 377 if (!type_value->IsType(Value::TYPE_STRING)) |
| 378 return false; |
| 379 std::string temp; |
| 380 if (type_value->GetAsString(&temp)) |
| 381 out->type.reset(new std::string(temp)); |
| 382 } |
| 383 } |
| 384 |
| 385 Value* incognito_value = NULL; |
| 386 if (dict->GetWithoutPathExpansion("incognito", &incognito_value)) { |
| 387 { |
| 388 if (!incognito_value->IsType(Value::TYPE_BOOLEAN)) |
| 389 return false; |
| 390 bool temp; |
| 391 if (incognito_value->GetAsBoolean(&temp)) |
| 392 out->incognito.reset(new bool(temp)); |
| 393 } |
| 394 } |
| 395 |
| 396 return true; |
| 397 } |
| 398 |
| 399 |
| 400 |
| 401 Create::Params::Params() {} |
| 402 Create::Params::~Params() {} |
| 403 |
| 404 // static |
| 405 scoped_ptr<Create::Params> Create::Params::Create(const ListValue& args) { |
| 406 if (args.GetSize() > 1) |
| 407 return scoped_ptr<Params>(); |
| 408 scoped_ptr<Params> params(new Params()); |
| 409 |
| 410 Value* create_data_value = NULL; |
| 411 if (!args.Get(0, &create_data_value) || create_data_value->IsType(Value::TYPE_
NULL)) |
| 412 return params.Pass(); |
| 413 { |
| 414 if (!create_data_value->IsType(Value::TYPE_DICTIONARY)) |
| 415 return scoped_ptr<Params>(); |
| 416 DictionaryValue* dictionary = NULL; |
| 417 if (!create_data_value->GetAsDictionary(&dictionary)) |
| 418 return scoped_ptr<Params>(); |
| 419 scoped_ptr<CreateData> temp(new CreateData()); |
| 420 if (!CreateData::Populate(*dictionary, temp.get())) |
| 421 return scoped_ptr<Params>(); |
| 422 params->create_data = temp.Pass(); |
| 423 } |
| 424 |
| 425 return params.Pass(); |
| 426 } |
| 427 |
| 428 |
| 429 Value* Create::Result::Create(const Window& window) { |
| 430 return window.ToValue().release(); |
| 431 } |
| 432 |
| 433 GetAll::Params::GetInfo::GetInfo() {} |
| 434 GetAll::Params::GetInfo::~GetInfo() {} |
| 435 |
| 436 // static |
| 437 bool GetAll::Params::GetInfo::Populate(const Value& value, GetInfo* out) { |
| 438 if (!value.IsType(Value::TYPE_DICTIONARY)) |
| 439 return false; |
| 440 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value); |
| 441 |
| 442 Value* populate_value = NULL; |
| 443 if (dict->GetWithoutPathExpansion("populate", &populate_value)) { |
| 444 { |
| 445 if (!populate_value->IsType(Value::TYPE_BOOLEAN)) |
| 446 return false; |
| 447 bool temp; |
| 448 if (populate_value->GetAsBoolean(&temp)) |
| 449 out->populate.reset(new bool(temp)); |
| 450 } |
| 451 } |
| 452 |
| 453 return true; |
| 454 } |
| 455 |
| 456 |
| 457 |
| 458 GetAll::Params::Params() {} |
| 459 GetAll::Params::~Params() {} |
| 460 |
| 461 // static |
| 462 scoped_ptr<GetAll::Params> GetAll::Params::Create(const ListValue& args) { |
| 463 if (args.GetSize() > 1) |
| 464 return scoped_ptr<Params>(); |
| 465 scoped_ptr<Params> params(new Params()); |
| 466 |
| 467 Value* get_info_value = NULL; |
| 468 if (!args.Get(0, &get_info_value) || get_info_value->IsType(Value::TYPE_NULL)) |
| 469 return params.Pass(); |
| 470 { |
| 471 if (!get_info_value->IsType(Value::TYPE_DICTIONARY)) |
| 472 return scoped_ptr<Params>(); |
| 473 DictionaryValue* dictionary = NULL; |
| 474 if (!get_info_value->GetAsDictionary(&dictionary)) |
| 475 return scoped_ptr<Params>(); |
| 476 scoped_ptr<GetInfo> temp(new GetInfo()); |
| 477 if (!GetInfo::Populate(*dictionary, temp.get())) |
| 478 return scoped_ptr<Params>(); |
| 479 params->get_info = temp.Pass(); |
| 480 } |
| 481 |
| 482 return params.Pass(); |
| 483 } |
| 484 |
| 485 |
| 486 Value* GetAll::Result::Create(const std::vector<linked_ptr<Window> >& windows) { |
| 487 ListValue* value = new ListValue(); |
| 488 json_schema_compiler::util::PopulateListFromArray(windows, value); |
| 489 return value; |
| 490 } |
| 491 |
| 492 Update::Params::UpdateInfo::UpdateInfo() {} |
| 493 Update::Params::UpdateInfo::~UpdateInfo() {} |
| 494 |
| 495 // static |
| 496 bool Update::Params::UpdateInfo::Populate(const Value& value, UpdateInfo* out) { |
| 497 if (!value.IsType(Value::TYPE_DICTIONARY)) |
| 498 return false; |
| 499 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value); |
| 500 |
| 501 Value* top_value = NULL; |
| 502 if (dict->GetWithoutPathExpansion("top", &top_value)) { |
| 503 { |
| 504 if (!top_value->IsType(Value::TYPE_INTEGER)) |
| 505 return false; |
| 506 int temp; |
| 507 if (top_value->GetAsInteger(&temp)) |
| 508 out->top.reset(new int(temp)); |
| 509 } |
| 510 } |
| 511 |
| 512 Value* draw_attention_value = NULL; |
| 513 if (dict->GetWithoutPathExpansion("drawAttention", &draw_attention_value)) { |
| 514 { |
| 515 if (!draw_attention_value->IsType(Value::TYPE_BOOLEAN)) |
| 516 return false; |
| 517 bool temp; |
| 518 if (draw_attention_value->GetAsBoolean(&temp)) |
| 519 out->draw_attention.reset(new bool(temp)); |
| 520 } |
| 521 } |
| 522 |
| 523 Value* height_value = NULL; |
| 524 if (dict->GetWithoutPathExpansion("height", &height_value)) { |
| 525 { |
| 526 if (!height_value->IsType(Value::TYPE_INTEGER)) |
| 527 return false; |
| 528 int temp; |
| 529 if (height_value->GetAsInteger(&temp)) |
| 530 out->height.reset(new int(temp)); |
| 531 } |
| 532 } |
| 533 |
| 534 Value* width_value = NULL; |
| 535 if (dict->GetWithoutPathExpansion("width", &width_value)) { |
| 536 { |
| 537 if (!width_value->IsType(Value::TYPE_INTEGER)) |
| 538 return false; |
| 539 int temp; |
| 540 if (width_value->GetAsInteger(&temp)) |
| 541 out->width.reset(new int(temp)); |
| 542 } |
| 543 } |
| 544 |
| 545 Value* state_value = NULL; |
| 546 if (dict->GetWithoutPathExpansion("state", &state_value)) { |
| 547 { |
| 548 if (!state_value->IsType(Value::TYPE_STRING)) |
| 549 return false; |
| 550 std::string temp; |
| 551 if (state_value->GetAsString(&temp)) |
| 552 out->state.reset(new std::string(temp)); |
| 553 } |
| 554 } |
| 555 |
| 556 Value* focused_value = NULL; |
| 557 if (dict->GetWithoutPathExpansion("focused", &focused_value)) { |
| 558 { |
| 559 if (!focused_value->IsType(Value::TYPE_BOOLEAN)) |
| 560 return false; |
| 561 bool temp; |
| 562 if (focused_value->GetAsBoolean(&temp)) |
| 563 out->focused.reset(new bool(temp)); |
| 564 } |
| 565 } |
| 566 |
| 567 Value* left_value = NULL; |
| 568 if (dict->GetWithoutPathExpansion("left", &left_value)) { |
| 569 { |
| 570 if (!left_value->IsType(Value::TYPE_INTEGER)) |
| 571 return false; |
| 572 int temp; |
| 573 if (left_value->GetAsInteger(&temp)) |
| 574 out->left.reset(new int(temp)); |
| 575 } |
| 576 } |
| 577 |
| 578 return true; |
| 579 } |
| 580 |
| 581 |
| 582 |
| 583 Update::Params::Params() {} |
| 584 Update::Params::~Params() {} |
| 585 |
| 586 // static |
| 587 scoped_ptr<Update::Params> Update::Params::Create(const ListValue& args) { |
| 588 if (args.GetSize() != 2) |
| 589 return scoped_ptr<Params>(); |
| 590 scoped_ptr<Params> params(new Params()); |
| 591 |
| 592 Value* window_id_value = NULL; |
| 593 if (!args.Get(0, &window_id_value) || window_id_value->IsType(Value::TYPE_NULL
)) |
| 594 return scoped_ptr<Params>(); |
| 595 { |
| 596 if (!window_id_value->IsType(Value::TYPE_INTEGER)) |
| 597 return scoped_ptr<Params>(); |
| 598 if (!window_id_value->GetAsInteger(¶ms->window_id)) |
| 599 return scoped_ptr<Params>(); |
| 600 } |
| 601 |
| 602 Value* update_info_value = NULL; |
| 603 if (!args.Get(1, &update_info_value) || update_info_value->IsType(Value::TYPE_
NULL)) |
| 604 return scoped_ptr<Params>(); |
| 605 { |
| 606 if (!update_info_value->IsType(Value::TYPE_DICTIONARY)) |
| 607 return scoped_ptr<Params>(); |
| 608 DictionaryValue* dictionary = NULL; |
| 609 if (!update_info_value->GetAsDictionary(&dictionary)) |
| 610 return scoped_ptr<Params>(); |
| 611 if (!UpdateInfo::Populate(*dictionary, ¶ms->update_info)) |
| 612 return scoped_ptr<Params>(); |
| 613 } |
| 614 |
| 615 return params.Pass(); |
| 616 } |
| 617 |
| 618 |
| 619 Value* Update::Result::Create(const Window& window) { |
| 620 return window.ToValue().release(); |
| 621 } |
| 622 |
| 623 Remove::Params::Params() {} |
| 624 Remove::Params::~Params() {} |
| 625 |
| 626 // static |
| 627 scoped_ptr<Remove::Params> Remove::Params::Create(const ListValue& args) { |
| 628 if (args.GetSize() != 1) |
| 629 return scoped_ptr<Params>(); |
| 630 scoped_ptr<Params> params(new Params()); |
| 631 |
| 632 Value* window_id_value = NULL; |
| 633 if (!args.Get(0, &window_id_value) || window_id_value->IsType(Value::TYPE_NULL
)) |
| 634 return scoped_ptr<Params>(); |
| 635 { |
| 636 if (!window_id_value->IsType(Value::TYPE_INTEGER)) |
| 637 return scoped_ptr<Params>(); |
| 638 if (!window_id_value->GetAsInteger(¶ms->window_id)) |
| 639 return scoped_ptr<Params>(); |
| 640 } |
| 641 |
| 642 return params.Pass(); |
| 643 } |
| 644 |
| 645 |
| 646 Value* Remove::Result::Create() { |
| 647 return Value::CreateNullValue(); |
| 648 } |
| 649 |
| 650 GetLastFocused::Params::GetInfo::GetInfo() {} |
| 651 GetLastFocused::Params::GetInfo::~GetInfo() {} |
| 652 |
| 653 // static |
| 654 bool GetLastFocused::Params::GetInfo::Populate(const Value& value, GetInfo* out)
{ |
| 655 if (!value.IsType(Value::TYPE_DICTIONARY)) |
| 656 return false; |
| 657 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value); |
| 658 |
| 659 Value* populate_value = NULL; |
| 660 if (dict->GetWithoutPathExpansion("populate", &populate_value)) { |
| 661 { |
| 662 if (!populate_value->IsType(Value::TYPE_BOOLEAN)) |
| 663 return false; |
| 664 bool temp; |
| 665 if (populate_value->GetAsBoolean(&temp)) |
| 666 out->populate.reset(new bool(temp)); |
| 667 } |
| 668 } |
| 669 |
| 670 return true; |
| 671 } |
| 672 |
| 673 |
| 674 |
| 675 GetLastFocused::Params::Params() {} |
| 676 GetLastFocused::Params::~Params() {} |
| 677 |
| 678 // static |
| 679 scoped_ptr<GetLastFocused::Params> GetLastFocused::Params::Create(const ListValu
e& args) { |
| 680 if (args.GetSize() > 1) |
| 681 return scoped_ptr<Params>(); |
| 682 scoped_ptr<Params> params(new Params()); |
| 683 |
| 684 Value* get_info_value = NULL; |
| 685 if (!args.Get(0, &get_info_value) || get_info_value->IsType(Value::TYPE_NULL)) |
| 686 return params.Pass(); |
| 687 { |
| 688 if (!get_info_value->IsType(Value::TYPE_DICTIONARY)) |
| 689 return scoped_ptr<Params>(); |
| 690 DictionaryValue* dictionary = NULL; |
| 691 if (!get_info_value->GetAsDictionary(&dictionary)) |
| 692 return scoped_ptr<Params>(); |
| 693 scoped_ptr<GetInfo> temp(new GetInfo()); |
| 694 if (!GetInfo::Populate(*dictionary, temp.get())) |
| 695 return scoped_ptr<Params>(); |
| 696 params->get_info = temp.Pass(); |
| 697 } |
| 698 |
| 699 return params.Pass(); |
| 700 } |
| 701 |
| 702 |
| 703 Value* GetLastFocused::Result::Create(const Window& window) { |
| 704 return window.ToValue().release(); |
| 705 } |
| 706 |
| 707 } // windows |
| 708 } // api |
| 709 } // extensions |
OLD | NEW |