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

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

Issue 10540066: [pyauto] Add ability to force install an extension with experimental perms (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 months 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/test/pyautolib/pyauto.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/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 3927 matching lines...) Expand 10 before | Expand all | Expand 10 after
3938 return_value->Set("colors", theme->GetThemeColors()->DeepCopy()); 3938 return_value->Set("colors", theme->GetThemeColors()->DeepCopy());
3939 return_value->Set("tints", theme->GetThemeTints()->DeepCopy()); 3939 return_value->Set("tints", theme->GetThemeTints()->DeepCopy());
3940 } 3940 }
3941 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); 3941 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get());
3942 } 3942 }
3943 3943
3944 void TestingAutomationProvider::InstallExtension( 3944 void TestingAutomationProvider::InstallExtension(
3945 DictionaryValue* args, IPC::Message* reply_message) { 3945 DictionaryValue* args, IPC::Message* reply_message) {
3946 FilePath::StringType path_string; 3946 FilePath::StringType path_string;
3947 bool with_ui; 3947 bool with_ui;
3948 bool from_webstore = false;
3948 Browser* browser; 3949 Browser* browser;
3949 std::string error_msg; 3950 std::string error_msg;
3950 if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { 3951 if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) {
3951 AutomationJSONReply(this, reply_message).SendError(error_msg); 3952 AutomationJSONReply(this, reply_message).SendError(error_msg);
3952 return; 3953 return;
3953 } 3954 }
3954 if (!args->GetString("path", &path_string)) { 3955 if (!args->GetString("path", &path_string)) {
3955 AutomationJSONReply(this, reply_message).SendError( 3956 AutomationJSONReply(this, reply_message).SendError(
3956 "Missing or invalid 'path'"); 3957 "Missing or invalid 'path'");
3957 return; 3958 return;
3958 } 3959 }
3959 if (!args->GetBoolean("with_ui", &with_ui)) { 3960 if (!args->GetBoolean("with_ui", &with_ui)) {
3960 AutomationJSONReply(this, reply_message).SendError( 3961 AutomationJSONReply(this, reply_message).SendError(
3961 "Missing or invalid 'with_ui'"); 3962 "Missing or invalid 'with_ui'");
3962 return; 3963 return;
3963 } 3964 }
3965 args->GetBoolean("from_webstore", &from_webstore);
3966
3964 ExtensionService* service = browser->profile()->GetExtensionService(); 3967 ExtensionService* service = browser->profile()->GetExtensionService();
3965 ExtensionProcessManager* manager = 3968 ExtensionProcessManager* manager =
3966 browser->profile()->GetExtensionProcessManager(); 3969 browser->profile()->GetExtensionProcessManager();
3967 if (service && manager) { 3970 if (service && manager) {
3968 // The observer will delete itself when done. 3971 // The observer will delete itself when done.
3969 new ExtensionReadyNotificationObserver( 3972 new ExtensionReadyNotificationObserver(
3970 manager, 3973 manager,
3971 service, 3974 service,
3972 this, 3975 this,
3973 reply_message); 3976 reply_message);
3974 3977
3975 FilePath extension_path(path_string); 3978 FilePath extension_path(path_string);
3976 // If the given path has a 'crx' extension, assume it is a packed extension 3979 // If the given path has a 'crx' extension, assume it is a packed extension
3977 // and install it. Otherwise load it as an unpacked extension. 3980 // and install it. Otherwise load it as an unpacked extension.
3978 if (extension_path.MatchesExtension(FILE_PATH_LITERAL(".crx"))) { 3981 if (extension_path.MatchesExtension(FILE_PATH_LITERAL(".crx"))) {
3979 ExtensionInstallUI* client = 3982 ExtensionInstallUI* client =
3980 (with_ui ? new ExtensionInstallUI(browser->profile()) : NULL); 3983 (with_ui ? new ExtensionInstallUI(browser->profile()) : NULL);
3981 scoped_refptr<CrxInstaller> installer( 3984 scoped_refptr<CrxInstaller> installer(
3982 CrxInstaller::Create(service, client)); 3985 CrxInstaller::Create(service, client));
3983 if (!with_ui) 3986 if (!with_ui)
3984 installer->set_allow_silent_install(true); 3987 installer->set_allow_silent_install(true);
3985 installer->set_install_cause(extension_misc::INSTALL_CAUSE_AUTOMATION); 3988 installer->set_install_cause(extension_misc::INSTALL_CAUSE_AUTOMATION);
3989 if (from_webstore)
3990 installer->set_creation_flags(Extension::FROM_WEBSTORE);
3986 installer->InstallCrx(extension_path); 3991 installer->InstallCrx(extension_path);
3987 } else { 3992 } else {
3988 scoped_refptr<extensions::UnpackedInstaller> installer( 3993 scoped_refptr<extensions::UnpackedInstaller> installer(
3989 extensions::UnpackedInstaller::Create(service)); 3994 extensions::UnpackedInstaller::Create(service));
3990 installer->set_prompt_for_plugins(with_ui); 3995 installer->set_prompt_for_plugins(with_ui);
3991 installer->Load(extension_path); 3996 installer->Load(extension_path);
3992 } 3997 }
3993 } else { 3998 } else {
3994 AutomationJSONReply(this, reply_message).SendError( 3999 AutomationJSONReply(this, reply_message).SendError(
3995 "Extensions service/process manager is not available"); 4000 "Extensions service/process manager is not available");
(...skipping 2675 matching lines...) Expand 10 before | Expand all | Expand 10 after
6671 } 6676 }
6672 6677
6673 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, 6678 void TestingAutomationProvider::EnsureTabSelected(Browser* browser,
6674 WebContents* tab) { 6679 WebContents* tab) {
6675 if (browser->GetSelectedWebContents() != tab || 6680 if (browser->GetSelectedWebContents() != tab ||
6676 browser != BrowserList::GetLastActive()) { 6681 browser != BrowserList::GetLastActive()) {
6677 browser->ActivateTabAt(browser->GetIndexOfController(&tab->GetController()), 6682 browser->ActivateTabAt(browser->GetIndexOfController(&tab->GetController()),
6678 true /* user_gesture */); 6683 true /* user_gesture */);
6679 } 6684 }
6680 } 6685 }
OLDNEW
« no previous file with comments | « no previous file | chrome/test/pyautolib/pyauto.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698