| OLD | NEW | 
|     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  Loading... | 
|   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(); |  | 
|   398  |  | 
|   399   if (!infos.empty()) { |   397   if (!infos.empty()) { | 
|   400     // Hack: Ideally, we would use event_data.extension_info to set the |   398     event_data.extension_info.reset( | 
|   401     // extension info, but since it's an optional field, it's implemented as a |   399         new developer::ExtensionInfo(std::move(infos[0]))); | 
|   402     // scoped ptr, and so ownership between that and the vector of linked ptrs |  | 
|   403     // here is, well, messy. Easier to just set it like this. |  | 
|   404     dict->SetWithoutPathExpansion("extensionInfo", |  | 
|   405                                   infos[0]->ToValue().release()); |  | 
|   406   } |   400   } | 
|   407  |   401  | 
|   408   scoped_ptr<base::ListValue> args(new base::ListValue()); |   402   scoped_ptr<base::ListValue> args(new base::ListValue()); | 
|   409   args->Append(dict.release()); |   403   args->Append(event_data.ToValue()); | 
|   410   scoped_ptr<Event> event( |   404   scoped_ptr<Event> event( | 
|   411       new Event(events::DEVELOPER_PRIVATE_ON_ITEM_STATE_CHANGED, |   405       new Event(events::DEVELOPER_PRIVATE_ON_ITEM_STATE_CHANGED, | 
|   412                 developer::OnItemStateChanged::kEventName, std::move(args))); |   406                 developer::OnItemStateChanged::kEventName, std::move(args))); | 
|   413   event_router_->BroadcastEvent(std::move(event)); |   407   event_router_->BroadcastEvent(std::move(event)); | 
|   414 } |   408 } | 
|   415  |   409  | 
|   416 void DeveloperPrivateAPI::SetLastUnpackedDirectory(const base::FilePath& path) { |   410 void DeveloperPrivateAPI::SetLastUnpackedDirectory(const base::FilePath& path) { | 
|   417   last_unpacked_directory_ = path; |   411   last_unpacked_directory_ = path; | 
|   418 } |   412 } | 
|   419  |   413  | 
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   503   info_generator_->CreateExtensionsInfo( |   497   info_generator_->CreateExtensionsInfo( | 
|   504       include_disabled, |   498       include_disabled, | 
|   505       include_terminated, |   499       include_terminated, | 
|   506       base::Bind(&DeveloperPrivateGetExtensionsInfoFunction::OnInfosGenerated, |   500       base::Bind(&DeveloperPrivateGetExtensionsInfoFunction::OnInfosGenerated, | 
|   507                  this /* refcounted */)); |   501                  this /* refcounted */)); | 
|   508  |   502  | 
|   509   return RespondLater(); |   503   return RespondLater(); | 
|   510 } |   504 } | 
|   511  |   505  | 
|   512 void DeveloperPrivateGetExtensionsInfoFunction::OnInfosGenerated( |   506 void DeveloperPrivateGetExtensionsInfoFunction::OnInfosGenerated( | 
|   513     const ExtensionInfoGenerator::ExtensionInfoList& list) { |   507     ExtensionInfoGenerator::ExtensionInfoList list) { | 
|   514   Respond(ArgumentList(developer::GetExtensionsInfo::Results::Create(list))); |   508   Respond(ArgumentList(developer::GetExtensionsInfo::Results::Create(list))); | 
|   515 } |   509 } | 
|   516  |   510  | 
|   517 DeveloperPrivateGetExtensionInfoFunction:: |   511 DeveloperPrivateGetExtensionInfoFunction:: | 
|   518 DeveloperPrivateGetExtensionInfoFunction() { |   512 DeveloperPrivateGetExtensionInfoFunction() { | 
|   519 } |   513 } | 
|   520  |   514  | 
|   521 DeveloperPrivateGetExtensionInfoFunction:: |   515 DeveloperPrivateGetExtensionInfoFunction:: | 
|   522 ~DeveloperPrivateGetExtensionInfoFunction() { |   516 ~DeveloperPrivateGetExtensionInfoFunction() { | 
|   523 } |   517 } | 
|   524  |   518  | 
|   525 ExtensionFunction::ResponseAction |   519 ExtensionFunction::ResponseAction | 
|   526 DeveloperPrivateGetExtensionInfoFunction::Run() { |   520 DeveloperPrivateGetExtensionInfoFunction::Run() { | 
|   527   scoped_ptr<developer::GetExtensionInfo::Params> params( |   521   scoped_ptr<developer::GetExtensionInfo::Params> params( | 
|   528       developer::GetExtensionInfo::Params::Create(*args_)); |   522       developer::GetExtensionInfo::Params::Create(*args_)); | 
|   529   EXTENSION_FUNCTION_VALIDATE(params); |   523   EXTENSION_FUNCTION_VALIDATE(params); | 
|   530  |   524  | 
|   531   info_generator_.reset(new ExtensionInfoGenerator(browser_context())); |   525   info_generator_.reset(new ExtensionInfoGenerator(browser_context())); | 
|   532   info_generator_->CreateExtensionInfo( |   526   info_generator_->CreateExtensionInfo( | 
|   533       params->id, |   527       params->id, | 
|   534       base::Bind(&DeveloperPrivateGetExtensionInfoFunction::OnInfosGenerated, |   528       base::Bind(&DeveloperPrivateGetExtensionInfoFunction::OnInfosGenerated, | 
|   535                  this /* refcounted */)); |   529                  this /* refcounted */)); | 
|   536  |   530  | 
|   537   return RespondLater(); |   531   return RespondLater(); | 
|   538 } |   532 } | 
|   539  |   533  | 
|   540 void DeveloperPrivateGetExtensionInfoFunction::OnInfosGenerated( |   534 void DeveloperPrivateGetExtensionInfoFunction::OnInfosGenerated( | 
|   541     const ExtensionInfoGenerator::ExtensionInfoList& list) { |   535     ExtensionInfoGenerator::ExtensionInfoList list) { | 
|   542   DCHECK_EQ(1u, list.size()); |   536   DCHECK_LE(1u, list.size()); | 
|   543   const linked_ptr<developer::ExtensionInfo>& info = list[0]; |   537   Respond(list.empty() ? Error(kNoSuchExtensionError) | 
|   544   Respond(info.get() ? OneArgument(info->ToValue()) : |   538                        : OneArgument(list[0].ToValue())); | 
|   545       Error(kNoSuchExtensionError)); |  | 
|   546 } |   539 } | 
|   547  |   540  | 
|   548 DeveloperPrivateGetItemsInfoFunction::DeveloperPrivateGetItemsInfoFunction() {} |   541 DeveloperPrivateGetItemsInfoFunction::DeveloperPrivateGetItemsInfoFunction() {} | 
|   549 DeveloperPrivateGetItemsInfoFunction::~DeveloperPrivateGetItemsInfoFunction() {} |   542 DeveloperPrivateGetItemsInfoFunction::~DeveloperPrivateGetItemsInfoFunction() {} | 
|   550  |   543  | 
|   551 ExtensionFunction::ResponseAction DeveloperPrivateGetItemsInfoFunction::Run() { |   544 ExtensionFunction::ResponseAction DeveloperPrivateGetItemsInfoFunction::Run() { | 
|   552   scoped_ptr<developer::GetItemsInfo::Params> params( |   545   scoped_ptr<developer::GetItemsInfo::Params> params( | 
|   553       developer::GetItemsInfo::Params::Create(*args_)); |   546       developer::GetItemsInfo::Params::Create(*args_)); | 
|   554   EXTENSION_FUNCTION_VALIDATE(params); |   547   EXTENSION_FUNCTION_VALIDATE(params); | 
|   555  |   548  | 
|   556   info_generator_.reset(new ExtensionInfoGenerator(browser_context())); |   549   info_generator_.reset(new ExtensionInfoGenerator(browser_context())); | 
|   557   info_generator_->CreateExtensionsInfo( |   550   info_generator_->CreateExtensionsInfo( | 
|   558       params->include_disabled, |   551       params->include_disabled, | 
|   559       params->include_terminated, |   552       params->include_terminated, | 
|   560       base::Bind(&DeveloperPrivateGetItemsInfoFunction::OnInfosGenerated, |   553       base::Bind(&DeveloperPrivateGetItemsInfoFunction::OnInfosGenerated, | 
|   561                  this /* refcounted */)); |   554                  this /* refcounted */)); | 
|   562  |   555  | 
|   563   return RespondLater(); |   556   return RespondLater(); | 
|   564 } |   557 } | 
|   565  |   558  | 
|   566 void DeveloperPrivateGetItemsInfoFunction::OnInfosGenerated( |   559 void DeveloperPrivateGetItemsInfoFunction::OnInfosGenerated( | 
|   567     const ExtensionInfoGenerator::ExtensionInfoList& list) { |   560     ExtensionInfoGenerator::ExtensionInfoList list) { | 
|   568   std::vector<linked_ptr<developer::ItemInfo>> item_list; |   561   std::vector<developer::ItemInfo> item_list; | 
|   569   for (const linked_ptr<developer::ExtensionInfo>& info : list) |   562   for (const developer::ExtensionInfo& info : list) | 
|   570     item_list.push_back(developer_private_mangle::MangleExtensionInfo(*info)); |   563     item_list.push_back(developer_private_mangle::MangleExtensionInfo(info)); | 
|   571  |   564  | 
|   572   Respond(ArgumentList(developer::GetItemsInfo::Results::Create(item_list))); |   565   Respond(ArgumentList(developer::GetItemsInfo::Results::Create(item_list))); | 
|   573 } |   566 } | 
|   574  |   567  | 
|   575 DeveloperPrivateGetProfileConfigurationFunction:: |   568 DeveloperPrivateGetProfileConfigurationFunction:: | 
|   576 ~DeveloperPrivateGetProfileConfigurationFunction() { |   569 ~DeveloperPrivateGetProfileConfigurationFunction() { | 
|   577 } |   570 } | 
|   578  |   571  | 
|   579 ExtensionFunction::ResponseAction |   572 ExtensionFunction::ResponseAction | 
|   580 DeveloperPrivateGetProfileConfigurationFunction::Run() { |   573 DeveloperPrivateGetProfileConfigurationFunction::Run() { | 
| (...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1450         update.extension_id, update.command_name, *update.keybinding); |  1443         update.extension_id, update.command_name, *update.keybinding); | 
|  1451   } |  1444   } | 
|  1452  |  1445  | 
|  1453   return RespondNow(NoArguments()); |  1446   return RespondNow(NoArguments()); | 
|  1454 } |  1447 } | 
|  1455  |  1448  | 
|  1456  |  1449  | 
|  1457 }  // namespace api |  1450 }  // namespace api | 
|  1458  |  1451  | 
|  1459 }  // namespace extensions |  1452 }  // namespace extensions | 
| OLD | NEW |