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

Side by Side Diff: chrome/browser/automation/testing_automation_provider.cc

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

Powered by Google App Engine
This is Rietveld 408576698