| Index: chrome/browser/automation/testing_automation_provider.cc
|
| diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc
|
| index 1b2b47ab2d351e7df892c7c758608fd763f43600..73421b3cb28fb43ecfa4654960458f6f246202c5 100644
|
| --- a/chrome/browser/automation/testing_automation_provider.cc
|
| +++ b/chrome/browser/automation/testing_automation_provider.cc
|
| @@ -49,11 +49,13 @@
|
| #include "chrome/browser/download/download_service.h"
|
| #include "chrome/browser/download/download_service_factory.h"
|
| #include "chrome/browser/download/save_package_file_picker.h"
|
| +#include "chrome/browser/extensions/crx_installer.h"
|
| #include "chrome/browser/extensions/extension_browser_event_router.h"
|
| #include "chrome/browser/extensions/extension_host.h"
|
| #include "chrome/browser/extensions/extension_process_manager.h"
|
| #include "chrome/browser/extensions/extension_service.h"
|
| #include "chrome/browser/extensions/extension_updater.h"
|
| +#include "chrome/browser/extensions/unpacked_installer.h"
|
| #include "chrome/browser/history/top_sites.h"
|
| #include "chrome/browser/importer/importer_host.h"
|
| #include "chrome/browser/importer/importer_list.h"
|
| @@ -2333,6 +2335,10 @@ void TestingAutomationProvider::SendJSONRequest(int handle,
|
| &TestingAutomationProvider::SetPolicies;
|
| handler_map["GetPolicyDefinitionList"] =
|
| &TestingAutomationProvider::GetPolicyDefinitionList;
|
| + handler_map["InstallExtension"] =
|
| + &TestingAutomationProvider::InstallExtension;
|
| + handler_map["GetExtensionsInfo"] =
|
| + &TestingAutomationProvider::GetExtensionsInfo;
|
| #if defined(OS_CHROMEOS)
|
| handler_map["GetLoginInfo"] = &TestingAutomationProvider::GetLoginInfo;
|
| handler_map["ShowCreateAccountUI"] =
|
| @@ -2477,9 +2483,6 @@ void TestingAutomationProvider::SendJSONRequest(int handle,
|
| browser_handler_map["GetThemeInfo"] =
|
| &TestingAutomationProvider::GetThemeInfo;
|
|
|
| - // InstallExtension() present in pyauto.py.
|
| - browser_handler_map["GetExtensionsInfo"] =
|
| - &TestingAutomationProvider::GetExtensionsInfo;
|
| browser_handler_map["UninstallExtensionById"] =
|
| &TestingAutomationProvider::UninstallExtensionById;
|
|
|
| @@ -4285,6 +4288,45 @@ void TestingAutomationProvider::GetThemeInfo(
|
| AutomationJSONReply(this, reply_message).SendSuccess(return_value.get());
|
| }
|
|
|
| +void TestingAutomationProvider::InstallExtension(
|
| + DictionaryValue* args, IPC::Message* reply_message) {
|
| + FilePath::StringType path_string;
|
| + if (!args->GetString("path", &path_string)) {
|
| + AutomationJSONReply(this, reply_message).SendError(
|
| + "Missing or invalid 'path'");
|
| + return;
|
| + }
|
| + ExtensionService* service = profile()->GetExtensionService();
|
| + ExtensionProcessManager* manager = profile()->GetExtensionProcessManager();
|
| + if (service && manager) {
|
| + // The observer will delete itself when done.
|
| + new ExtensionReadyNotificationObserver(
|
| + manager,
|
| + service,
|
| + this,
|
| + reply_message);
|
| +
|
| + FilePath extension_path(path_string);
|
| + // If the given path has a 'crx' extension, assume it is a packed extension
|
| + // and install it. Otherwise load it as an unpacked extension.
|
| + if (extension_path.MatchesExtension(FILE_PATH_LITERAL(".crx"))) {
|
| + scoped_refptr<CrxInstaller> installer(
|
| + CrxInstaller::Create(service, NULL));
|
| + installer->set_allow_silent_install(true);
|
| + installer->set_install_cause(extension_misc::INSTALL_CAUSE_AUTOMATION);
|
| + installer->InstallCrx(extension_path);
|
| + } else {
|
| + scoped_refptr<extensions::UnpackedInstaller> installer(
|
| + extensions::UnpackedInstaller::Create(service));
|
| + installer->set_prompt_for_plugins(false);
|
| + installer->Load(extension_path);
|
| + }
|
| + } else {
|
| + AutomationJSONReply(this, reply_message).SendError(
|
| + "Extensions service/process manager is not available");
|
| + }
|
| +}
|
| +
|
| namespace {
|
|
|
| ListValue* GetHostPermissions(const Extension* ext, bool effective_perm) {
|
| @@ -4320,7 +4362,6 @@ ListValue* GetAPIPermissions(const Extension* ext) {
|
| // See GetExtensionsInfo() in chrome/test/pyautolib/pyauto.py for sample json
|
| // output.
|
| void TestingAutomationProvider::GetExtensionsInfo(
|
| - Browser* browser,
|
| DictionaryValue* args,
|
| IPC::Message* reply_message) {
|
| AutomationJSONReply reply(this, reply_message);
|
| @@ -4359,8 +4400,10 @@ void TestingAutomationProvider::GetExtensionsInfo(
|
| extension_value->Set("effective_host_permissions",
|
| GetHostPermissions(extension, true));
|
| extension_value->Set("api_permissions", GetAPIPermissions(extension));
|
| - extension_value->SetBoolean("is_component_extension",
|
| + extension_value->SetBoolean("is_component",
|
| extension->location() == Extension::COMPONENT);
|
| + extension_value->SetBoolean("is_internal",
|
| + extension->location() == Extension::INTERNAL);
|
| extension_value->SetBoolean("is_enabled", service->IsExtensionEnabled(id));
|
| extension_value->SetBoolean("allowed_in_incognito",
|
| service->IsIncognitoEnabled(id));
|
|
|