Chromium Code Reviews| 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 a3ee2689a3578345ad8a9eca09ccfc7596eb4e46..b2de8b70704110c3900b1d3c8e3bbe0c5cccbef9 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"] = |
| @@ -2478,8 +2484,6 @@ void TestingAutomationProvider::SendJSONRequest(int handle, |
| &TestingAutomationProvider::GetThemeInfo; |
| // InstallExtension() present in pyauto.py. |
|
dennis_jeffrey
2011/11/22 23:32:16
Maybe remove this comment or update it, since Inst
kkania
2011/11/23 17:31:23
Done.
|
| - browser_handler_map["GetExtensionsInfo"] = |
| - &TestingAutomationProvider::GetExtensionsInfo; |
| browser_handler_map["UninstallExtensionById"] = |
| &TestingAutomationProvider::UninstallExtensionById; |
| @@ -4285,6 +4289,43 @@ 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 (extension_path.MatchesExtension(FILE_PATH_LITERAL(".crx"))) { |
|
dennis_jeffrey
2011/11/22 23:32:16
Please add a comment to describe what's happening
kkania
2011/11/23 17:31:23
Done.
|
| + 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 { |
| + AutomationMsg_InstallExtension::WriteReplyParams(reply_message, 0); |
| + Send(reply_message); |
|
dennis_jeffrey
2011/11/22 23:32:16
What's the reason you're replying this way as comp
kkania
2011/11/23 17:31:23
oops, meant to delete that...
|
| + } |
| +} |
| + |
| namespace { |
| ListValue* GetHostPermissions(const Extension* ext, bool effective_perm) { |
| @@ -4320,7 +4361,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); |
| @@ -4361,6 +4401,8 @@ void TestingAutomationProvider::GetExtensionsInfo( |
| extension_value->Set("api_permissions", GetAPIPermissions(extension)); |
| extension_value->SetBoolean("is_component_extension", |
| extension->location() == Extension::COMPONENT); |
| + extension_value->SetBoolean("is_internal_extension", |
| + extension->location() == Extension::INTERNAL); |
| extension_value->SetBoolean("is_enabled", service->IsExtensionEnabled(id)); |
| extension_value->SetBoolean("allowed_in_incognito", |
| service->IsIncognitoEnabled(id)); |