OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/automation/testing_automation_provider.h" | 5 #include "chrome/browser/automation/testing_automation_provider.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 3676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3687 "Missing or invalid 'path'"); | 3687 "Missing or invalid 'path'"); |
3688 return; | 3688 return; |
3689 } | 3689 } |
3690 if (!args->GetBoolean("with_ui", &with_ui)) { | 3690 if (!args->GetBoolean("with_ui", &with_ui)) { |
3691 AutomationJSONReply(this, reply_message).SendError( | 3691 AutomationJSONReply(this, reply_message).SendError( |
3692 "Missing or invalid 'with_ui'"); | 3692 "Missing or invalid 'with_ui'"); |
3693 return; | 3693 return; |
3694 } | 3694 } |
3695 args->GetBoolean("from_webstore", &from_webstore); | 3695 args->GetBoolean("from_webstore", &from_webstore); |
3696 | 3696 |
3697 ExtensionService* service = browser->profile()->GetExtensionService(); | 3697 ExtensionService* service = extensions::ExtensionSystem::Get( |
| 3698 browser->profile())->extension_service(); |
3698 ExtensionProcessManager* manager = | 3699 ExtensionProcessManager* manager = |
3699 extensions::ExtensionSystem::Get(browser->profile())->process_manager(); | 3700 extensions::ExtensionSystem::Get(browser->profile())->process_manager(); |
3700 if (service && manager) { | 3701 if (service && manager) { |
3701 // The observer will delete itself when done. | 3702 // The observer will delete itself when done. |
3702 new ExtensionReadyNotificationObserver( | 3703 new ExtensionReadyNotificationObserver( |
3703 manager, | 3704 manager, |
3704 service, | 3705 service, |
3705 this, | 3706 this, |
3706 reply_message); | 3707 reply_message); |
3707 | 3708 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3768 // output. | 3769 // output. |
3769 void TestingAutomationProvider::GetExtensionsInfo(DictionaryValue* args, | 3770 void TestingAutomationProvider::GetExtensionsInfo(DictionaryValue* args, |
3770 IPC::Message* reply_message) { | 3771 IPC::Message* reply_message) { |
3771 AutomationJSONReply reply(this, reply_message); | 3772 AutomationJSONReply reply(this, reply_message); |
3772 Browser* browser; | 3773 Browser* browser; |
3773 std::string error_msg; | 3774 std::string error_msg; |
3774 if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { | 3775 if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { |
3775 reply.SendError(error_msg); | 3776 reply.SendError(error_msg); |
3776 return; | 3777 return; |
3777 } | 3778 } |
3778 ExtensionService* service = browser->profile()->GetExtensionService(); | 3779 ExtensionService* service = extensions::ExtensionSystem::Get( |
| 3780 browser->profile())->extension_service(); |
3779 if (!service) { | 3781 if (!service) { |
3780 reply.SendError("No extensions service."); | 3782 reply.SendError("No extensions service."); |
3781 return; | 3783 return; |
3782 } | 3784 } |
3783 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 3785 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); |
3784 ListValue* extensions_values = new ListValue; | 3786 ListValue* extensions_values = new ListValue; |
3785 const ExtensionSet* extensions = service->extensions(); | 3787 const ExtensionSet* extensions = service->extensions(); |
3786 const ExtensionSet* disabled_extensions = service->disabled_extensions(); | 3788 const ExtensionSet* disabled_extensions = service->disabled_extensions(); |
3787 ExtensionList all; | 3789 ExtensionList all; |
3788 all.insert(all.end(), | 3790 all.insert(all.end(), |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3843 Browser* browser; | 3845 Browser* browser; |
3844 if (!GetBrowserFromJSONArgs(args, &browser, &error)) { | 3846 if (!GetBrowserFromJSONArgs(args, &browser, &error)) { |
3845 AutomationJSONReply(this, reply_message).SendError(error); | 3847 AutomationJSONReply(this, reply_message).SendError(error); |
3846 return; | 3848 return; |
3847 } | 3849 } |
3848 if (!GetExtensionFromJSONArgs( | 3850 if (!GetExtensionFromJSONArgs( |
3849 args, "id", browser->profile(), &extension, &error)) { | 3851 args, "id", browser->profile(), &extension, &error)) { |
3850 AutomationJSONReply(this, reply_message).SendError(error); | 3852 AutomationJSONReply(this, reply_message).SendError(error); |
3851 return; | 3853 return; |
3852 } | 3854 } |
3853 ExtensionService* service = browser->profile()->GetExtensionService(); | 3855 ExtensionService* service = extensions::ExtensionSystem::Get( |
| 3856 browser->profile())->extension_service(); |
3854 if (!service) { | 3857 if (!service) { |
3855 AutomationJSONReply(this, reply_message).SendError( | 3858 AutomationJSONReply(this, reply_message).SendError( |
3856 "No extensions service."); | 3859 "No extensions service."); |
3857 return; | 3860 return; |
3858 } | 3861 } |
3859 | 3862 |
3860 // Wait for a notification indicating that the extension with the given ID | 3863 // Wait for a notification indicating that the extension with the given ID |
3861 // has been uninstalled. This observer will delete itself. | 3864 // has been uninstalled. This observer will delete itself. |
3862 new ExtensionUninstallObserver(this, reply_message, extension->id()); | 3865 new ExtensionUninstallObserver(this, reply_message, extension->id()); |
3863 service->UninstallExtension(extension->id(), false, NULL); | 3866 service->UninstallExtension(extension->id(), false, NULL); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3895 return; | 3898 return; |
3896 } | 3899 } |
3897 | 3900 |
3898 if (allow_in_incognito && !enable) { | 3901 if (allow_in_incognito && !enable) { |
3899 AutomationJSONReply(this, reply_message) | 3902 AutomationJSONReply(this, reply_message) |
3900 .SendError("Invalid state: Disabled extension " | 3903 .SendError("Invalid state: Disabled extension " |
3901 "cannot be allowed in incognito mode."); | 3904 "cannot be allowed in incognito mode."); |
3902 return; | 3905 return; |
3903 } | 3906 } |
3904 | 3907 |
3905 ExtensionService* service = browser->profile()->GetExtensionService(); | 3908 ExtensionService* service = extensions::ExtensionSystem::Get( |
| 3909 browser->profile())->extension_service(); |
3906 ExtensionProcessManager* manager = | 3910 ExtensionProcessManager* manager = |
3907 extensions::ExtensionSystem::Get(browser->profile())->process_manager(); | 3911 extensions::ExtensionSystem::Get(browser->profile())->process_manager(); |
3908 if (!service) { | 3912 if (!service) { |
3909 AutomationJSONReply(this, reply_message) | 3913 AutomationJSONReply(this, reply_message) |
3910 .SendError("No extensions service or process manager."); | 3914 .SendError("No extensions service or process manager."); |
3911 return; | 3915 return; |
3912 } | 3916 } |
3913 | 3917 |
3914 if (enable) { | 3918 if (enable) { |
3915 if (!service->IsExtensionEnabled(extension->id())) { | 3919 if (!service->IsExtensionEnabled(extension->id())) { |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4111 // Sample json output: {} | 4115 // Sample json output: {} |
4112 void TestingAutomationProvider::UpdateExtensionsNow( | 4116 void TestingAutomationProvider::UpdateExtensionsNow( |
4113 DictionaryValue* args, | 4117 DictionaryValue* args, |
4114 IPC::Message* reply_message) { | 4118 IPC::Message* reply_message) { |
4115 std::string error; | 4119 std::string error; |
4116 Browser* browser; | 4120 Browser* browser; |
4117 if (!GetBrowserFromJSONArgs(args, &browser, &error)) { | 4121 if (!GetBrowserFromJSONArgs(args, &browser, &error)) { |
4118 AutomationJSONReply(this, reply_message).SendError(error); | 4122 AutomationJSONReply(this, reply_message).SendError(error); |
4119 return; | 4123 return; |
4120 } | 4124 } |
4121 ExtensionService* service = browser->profile()->GetExtensionService(); | 4125 ExtensionService* service = extensions::ExtensionSystem::Get( |
| 4126 browser->profile())->extension_service(); |
4122 if (!service) { | 4127 if (!service) { |
4123 AutomationJSONReply(this, reply_message).SendError( | 4128 AutomationJSONReply(this, reply_message).SendError( |
4124 "No extensions service."); | 4129 "No extensions service."); |
4125 return; | 4130 return; |
4126 } | 4131 } |
4127 | 4132 |
4128 extensions::ExtensionUpdater* updater = service->updater(); | 4133 extensions::ExtensionUpdater* updater = service->updater(); |
4129 if (!updater) { | 4134 if (!updater) { |
4130 AutomationJSONReply(this, reply_message).SendError( | 4135 AutomationJSONReply(this, reply_message).SendError( |
4131 "No updater for extensions service."); | 4136 "No updater for extensions service."); |
(...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5008 Browser* browser, | 5013 Browser* browser, |
5009 DictionaryValue* args, | 5014 DictionaryValue* args, |
5010 IPC::Message* reply_message) { | 5015 IPC::Message* reply_message) { |
5011 std::string id; | 5016 std::string id; |
5012 if (!args->GetString("id", &id)) { | 5017 if (!args->GetString("id", &id)) { |
5013 AutomationJSONReply(this, reply_message).SendError( | 5018 AutomationJSONReply(this, reply_message).SendError( |
5014 "Must include string id."); | 5019 "Must include string id."); |
5015 return; | 5020 return; |
5016 } | 5021 } |
5017 | 5022 |
5018 ExtensionService* service = browser->profile()->GetExtensionService(); | 5023 ExtensionService* service = extensions::ExtensionSystem::Get( |
| 5024 browser->profile())->extension_service(); |
5019 if (!service) { | 5025 if (!service) { |
5020 AutomationJSONReply(this, reply_message).SendError( | 5026 AutomationJSONReply(this, reply_message).SendError( |
5021 "No extensions service."); | 5027 "No extensions service."); |
5022 return; | 5028 return; |
5023 } | 5029 } |
5024 | 5030 |
5025 const Extension* extension = service->GetExtensionById( | 5031 const Extension* extension = service->GetExtensionById( |
5026 id, false /* do not include disabled extensions */); | 5032 id, false /* do not include disabled extensions */); |
5027 if (!extension) { | 5033 if (!extension) { |
5028 AutomationJSONReply(this, reply_message).SendError( | 5034 AutomationJSONReply(this, reply_message).SendError( |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5066 reply.SendError("Must include string id."); | 5072 reply.SendError("Must include string id."); |
5067 return; | 5073 return; |
5068 } | 5074 } |
5069 | 5075 |
5070 std::string launch_type_str; | 5076 std::string launch_type_str; |
5071 if (!args->GetString("launch_type", &launch_type_str)) { | 5077 if (!args->GetString("launch_type", &launch_type_str)) { |
5072 reply.SendError("Must specify app launch type."); | 5078 reply.SendError("Must specify app launch type."); |
5073 return; | 5079 return; |
5074 } | 5080 } |
5075 | 5081 |
5076 ExtensionService* service = browser->profile()->GetExtensionService(); | 5082 ExtensionService* service = extensions::ExtensionSystem::Get( |
| 5083 browser->profile())->extension_service(); |
5077 if (!service) { | 5084 if (!service) { |
5078 reply.SendError("No extensions service."); | 5085 reply.SendError("No extensions service."); |
5079 return; | 5086 return; |
5080 } | 5087 } |
5081 | 5088 |
5082 const Extension* extension = service->GetExtensionById( | 5089 const Extension* extension = service->GetExtensionById( |
5083 id, true /* include disabled extensions */); | 5090 id, true /* include disabled extensions */); |
5084 if (!extension) { | 5091 if (!extension) { |
5085 reply.SendError( | 5092 reply.SendError( |
5086 StringPrintf("Extension with ID '%s' doesn't exist.", id.c_str())); | 5093 StringPrintf("Extension with ID '%s' doesn't exist.", id.c_str())); |
(...skipping 1264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6351 if (g_browser_process) | 6358 if (g_browser_process) |
6352 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); | 6359 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); |
6353 } | 6360 } |
6354 | 6361 |
6355 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, | 6362 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, |
6356 WebContents* tab) { | 6363 WebContents* tab) { |
6357 TabStripModel* tab_strip = browser->tab_strip_model(); | 6364 TabStripModel* tab_strip = browser->tab_strip_model(); |
6358 if (tab_strip->GetActiveWebContents() != tab) | 6365 if (tab_strip->GetActiveWebContents() != tab) |
6359 tab_strip->ActivateTabAt(tab_strip->GetIndexOfWebContents(tab), true); | 6366 tab_strip->ActivateTabAt(tab_strip->GetIndexOfWebContents(tab), true); |
6360 } | 6367 } |
OLD | NEW |