Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(316)

Side by Side Diff: chrome/browser/extensions/api/developer_private/developer_private_api.cc

Issue 1811413002: [Extensions] Update generated code to support move operations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/api/developer_private/developer_private_api. h" 5 #include "chrome/browser/extensions/api/developer_private/developer_private_api. h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 extension_id, 381 extension_id,
382 base::Bind(&DeveloperPrivateEventRouter::BroadcastItemStateChangedHelper, 382 base::Bind(&DeveloperPrivateEventRouter::BroadcastItemStateChangedHelper,
383 weak_factory_.GetWeakPtr(), event_type, extension_id, 383 weak_factory_.GetWeakPtr(), event_type, extension_id,
384 base::Passed(std::move(info_generator)))); 384 base::Passed(std::move(info_generator))));
385 } 385 }
386 386
387 void DeveloperPrivateEventRouter::BroadcastItemStateChangedHelper( 387 void DeveloperPrivateEventRouter::BroadcastItemStateChangedHelper(
388 developer::EventType event_type, 388 developer::EventType event_type,
389 const std::string& extension_id, 389 const std::string& extension_id,
390 scoped_ptr<ExtensionInfoGenerator> info_generator, 390 scoped_ptr<ExtensionInfoGenerator> info_generator,
391 const ExtensionInfoGenerator::ExtensionInfoList& infos) { 391 ExtensionInfoGenerator::ExtensionInfoList infos) {
392 DCHECK_LE(infos.size(), 1u); 392 DCHECK_LE(infos.size(), 1u);
393 393
394 developer::EventData event_data; 394 developer::EventData event_data;
395 event_data.event_type = event_type; 395 event_data.event_type = event_type;
396 event_data.item_id = extension_id; 396 event_data.item_id = extension_id;
397 scoped_ptr<base::DictionaryValue> dict = event_data.ToValue(); 397 scoped_ptr<base::DictionaryValue> dict = event_data.ToValue();
398 398
399 if (!infos.empty()) { 399 if (!infos.empty()) {
400 // Hack: Ideally, we would use event_data.extension_info to set the 400 // Hack: Ideally, we would use event_data.extension_info to set the
401 // extension info, but since it's an optional field, it's implemented as a 401 // extension info, but since it's an optional field, it's implemented as a
402 // scoped ptr, and so ownership between that and the vector of linked ptrs 402 // scoped ptr, and so ownership between that and the vector of linked ptrs
asargent_no_longer_on_chrome 2016/03/21 21:03:13 is this part of the comment about "vector of linke
Devlin 2016/03/21 22:24:27 Good call! We can actually completely remove this
403 // here is, well, messy. Easier to just set it like this. 403 // here is, well, messy. Easier to just set it like this.
404 dict->SetWithoutPathExpansion("extensionInfo", 404 dict->SetWithoutPathExpansion("extensionInfo",
405 infos[0]->ToValue().release()); 405 infos[0].ToValue().release());
406 } 406 }
407 407
408 scoped_ptr<base::ListValue> args(new base::ListValue()); 408 scoped_ptr<base::ListValue> args(new base::ListValue());
409 args->Append(dict.release()); 409 args->Append(dict.release());
410 scoped_ptr<Event> event( 410 scoped_ptr<Event> event(
411 new Event(events::DEVELOPER_PRIVATE_ON_ITEM_STATE_CHANGED, 411 new Event(events::DEVELOPER_PRIVATE_ON_ITEM_STATE_CHANGED,
412 developer::OnItemStateChanged::kEventName, std::move(args))); 412 developer::OnItemStateChanged::kEventName, std::move(args)));
413 event_router_->BroadcastEvent(std::move(event)); 413 event_router_->BroadcastEvent(std::move(event));
414 } 414 }
415 415
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 info_generator_->CreateExtensionsInfo( 503 info_generator_->CreateExtensionsInfo(
504 include_disabled, 504 include_disabled,
505 include_terminated, 505 include_terminated,
506 base::Bind(&DeveloperPrivateGetExtensionsInfoFunction::OnInfosGenerated, 506 base::Bind(&DeveloperPrivateGetExtensionsInfoFunction::OnInfosGenerated,
507 this /* refcounted */)); 507 this /* refcounted */));
508 508
509 return RespondLater(); 509 return RespondLater();
510 } 510 }
511 511
512 void DeveloperPrivateGetExtensionsInfoFunction::OnInfosGenerated( 512 void DeveloperPrivateGetExtensionsInfoFunction::OnInfosGenerated(
513 const ExtensionInfoGenerator::ExtensionInfoList& list) { 513 ExtensionInfoGenerator::ExtensionInfoList list) {
514 Respond(ArgumentList(developer::GetExtensionsInfo::Results::Create(list))); 514 Respond(ArgumentList(developer::GetExtensionsInfo::Results::Create(list)));
515 } 515 }
516 516
517 DeveloperPrivateGetExtensionInfoFunction:: 517 DeveloperPrivateGetExtensionInfoFunction::
518 DeveloperPrivateGetExtensionInfoFunction() { 518 DeveloperPrivateGetExtensionInfoFunction() {
519 } 519 }
520 520
521 DeveloperPrivateGetExtensionInfoFunction:: 521 DeveloperPrivateGetExtensionInfoFunction::
522 ~DeveloperPrivateGetExtensionInfoFunction() { 522 ~DeveloperPrivateGetExtensionInfoFunction() {
523 } 523 }
524 524
525 ExtensionFunction::ResponseAction 525 ExtensionFunction::ResponseAction
526 DeveloperPrivateGetExtensionInfoFunction::Run() { 526 DeveloperPrivateGetExtensionInfoFunction::Run() {
527 scoped_ptr<developer::GetExtensionInfo::Params> params( 527 scoped_ptr<developer::GetExtensionInfo::Params> params(
528 developer::GetExtensionInfo::Params::Create(*args_)); 528 developer::GetExtensionInfo::Params::Create(*args_));
529 EXTENSION_FUNCTION_VALIDATE(params); 529 EXTENSION_FUNCTION_VALIDATE(params);
530 530
531 info_generator_.reset(new ExtensionInfoGenerator(browser_context())); 531 info_generator_.reset(new ExtensionInfoGenerator(browser_context()));
532 info_generator_->CreateExtensionInfo( 532 info_generator_->CreateExtensionInfo(
533 params->id, 533 params->id,
534 base::Bind(&DeveloperPrivateGetExtensionInfoFunction::OnInfosGenerated, 534 base::Bind(&DeveloperPrivateGetExtensionInfoFunction::OnInfosGenerated,
535 this /* refcounted */)); 535 this /* refcounted */));
536 536
537 return RespondLater(); 537 return RespondLater();
538 } 538 }
539 539
540 void DeveloperPrivateGetExtensionInfoFunction::OnInfosGenerated( 540 void DeveloperPrivateGetExtensionInfoFunction::OnInfosGenerated(
541 const ExtensionInfoGenerator::ExtensionInfoList& list) { 541 ExtensionInfoGenerator::ExtensionInfoList list) {
542 DCHECK_EQ(1u, list.size()); 542 DCHECK_LE(1u, list.size());
543 const linked_ptr<developer::ExtensionInfo>& info = list[0]; 543 Respond(list.empty() ? Error(kNoSuchExtensionError)
544 Respond(info.get() ? OneArgument(info->ToValue()) : 544 : OneArgument(list[0].ToValue()));
545 Error(kNoSuchExtensionError));
546 } 545 }
547 546
548 DeveloperPrivateGetItemsInfoFunction::DeveloperPrivateGetItemsInfoFunction() {} 547 DeveloperPrivateGetItemsInfoFunction::DeveloperPrivateGetItemsInfoFunction() {}
549 DeveloperPrivateGetItemsInfoFunction::~DeveloperPrivateGetItemsInfoFunction() {} 548 DeveloperPrivateGetItemsInfoFunction::~DeveloperPrivateGetItemsInfoFunction() {}
550 549
551 ExtensionFunction::ResponseAction DeveloperPrivateGetItemsInfoFunction::Run() { 550 ExtensionFunction::ResponseAction DeveloperPrivateGetItemsInfoFunction::Run() {
552 scoped_ptr<developer::GetItemsInfo::Params> params( 551 scoped_ptr<developer::GetItemsInfo::Params> params(
553 developer::GetItemsInfo::Params::Create(*args_)); 552 developer::GetItemsInfo::Params::Create(*args_));
554 EXTENSION_FUNCTION_VALIDATE(params); 553 EXTENSION_FUNCTION_VALIDATE(params);
555 554
556 info_generator_.reset(new ExtensionInfoGenerator(browser_context())); 555 info_generator_.reset(new ExtensionInfoGenerator(browser_context()));
557 info_generator_->CreateExtensionsInfo( 556 info_generator_->CreateExtensionsInfo(
558 params->include_disabled, 557 params->include_disabled,
559 params->include_terminated, 558 params->include_terminated,
560 base::Bind(&DeveloperPrivateGetItemsInfoFunction::OnInfosGenerated, 559 base::Bind(&DeveloperPrivateGetItemsInfoFunction::OnInfosGenerated,
561 this /* refcounted */)); 560 this /* refcounted */));
562 561
563 return RespondLater(); 562 return RespondLater();
564 } 563 }
565 564
566 void DeveloperPrivateGetItemsInfoFunction::OnInfosGenerated( 565 void DeveloperPrivateGetItemsInfoFunction::OnInfosGenerated(
567 const ExtensionInfoGenerator::ExtensionInfoList& list) { 566 ExtensionInfoGenerator::ExtensionInfoList list) {
568 std::vector<linked_ptr<developer::ItemInfo>> item_list; 567 std::vector<developer::ItemInfo> item_list;
569 for (const linked_ptr<developer::ExtensionInfo>& info : list) 568 for (const developer::ExtensionInfo& info : list)
570 item_list.push_back(developer_private_mangle::MangleExtensionInfo(*info)); 569 item_list.push_back(developer_private_mangle::MangleExtensionInfo(info));
571 570
572 Respond(ArgumentList(developer::GetItemsInfo::Results::Create(item_list))); 571 Respond(ArgumentList(developer::GetItemsInfo::Results::Create(item_list)));
573 } 572 }
574 573
575 DeveloperPrivateGetProfileConfigurationFunction:: 574 DeveloperPrivateGetProfileConfigurationFunction::
576 ~DeveloperPrivateGetProfileConfigurationFunction() { 575 ~DeveloperPrivateGetProfileConfigurationFunction() {
577 } 576 }
578 577
579 ExtensionFunction::ResponseAction 578 ExtensionFunction::ResponseAction
580 DeveloperPrivateGetProfileConfigurationFunction::Run() { 579 DeveloperPrivateGetProfileConfigurationFunction::Run() {
(...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after
1450 update.extension_id, update.command_name, *update.keybinding); 1449 update.extension_id, update.command_name, *update.keybinding);
1451 } 1450 }
1452 1451
1453 return RespondNow(NoArguments()); 1452 return RespondNow(NoArguments());
1454 } 1453 }
1455 1454
1456 1455
1457 } // namespace api 1456 } // namespace api
1458 1457
1459 } // namespace extensions 1458 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698