Commit 7c086875 authored by mihaip@chromium.org's avatar mihaip@chromium.org

Remove chrome.webstorePrivate.silentlyInstall.

BUG=117168

Review URL: https://chromiumcodereview.appspot.com/9959079

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@150455 0039d316-1c4b-4281-b951-d872f2087c98
parent c0169442
...@@ -111,33 +111,6 @@ ProfileSyncService* GetSyncService(Profile* profile) { ...@@ -111,33 +111,6 @@ ProfileSyncService* GetSyncService(Profile* profile) {
return ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile); return ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile);
} }
// Whitelists extension IDs for use by webstorePrivate.silentlyInstall.
bool trust_test_ids = false;
bool IsTrustedForSilentInstall(const std::string& id) {
// Trust the extensions in api_test/webstore_private/bundle when the flag
// is set.
if (trust_test_ids &&
(id == "begfmnajjkbjdgmffnjaojchoncnmngg" ||
id == "bmfoocgfinpmkmlbjhcbofejhkhlbchk" ||
id == "mpneghmdnmaolkljkipbhaienajcflfe"))
return true;
return
id == "jgoepmocgafhnchmokaimcmlojpnlkhp" || // +1 Extension
id == "cpembckmhnjipbgbnfiocbgnkpjdokdd" || // +1 Extension - dev
id == "boemmnepglcoinjcdlfcpcbmhiecichi" || // Notifications
id == "flibmgiapaohcbondaoopaalfejliklp" || // Notifications - dev
id == "nckgahadagoaajjgafhacjanaoiihapd" || // Talk
id == "eggnbpckecmjlblplehfpjjdhhidfdoj" || // Talk Beta
id == "dlppkpafhbajpcmmoheippocdidnckmm" || // Remaining are placeholders
id == "hmglfmpefabcafaimbpldpambdfomanl" ||
id == "idfijlieiecpfcjckpkliefekpokhhnd" ||
id == "jaokjbijaokooelpahnlmbciccldmfla" ||
id == "kdjeommiakphmeionoojjljlecmpaldd" ||
id == "lpdeojkfhenboeibhkjhiancceeboknd";
}
// Helper to create a dictionary with login and token properties set from // Helper to create a dictionary with login and token properties set from
// the appropriate values in the passed-in |profile|. // the appropriate values in the passed-in |profile|.
DictionaryValue* CreateLoginResult(Profile* profile) { DictionaryValue* CreateLoginResult(Profile* profile) {
...@@ -174,11 +147,6 @@ void WebstorePrivateApi::SetWebstoreInstallerDelegateForTesting( ...@@ -174,11 +147,6 @@ void WebstorePrivateApi::SetWebstoreInstallerDelegateForTesting(
test_webstore_installer_delegate = delegate; test_webstore_installer_delegate = delegate;
} }
// static
void WebstorePrivateApi::SetTrustTestIDsForTesting(bool allow) {
trust_test_ids = allow;
}
// static // static
scoped_ptr<WebstoreInstaller::Approval> scoped_ptr<WebstoreInstaller::Approval>
WebstorePrivateApi::PopApprovalForTesting( WebstorePrivateApi::PopApprovalForTesting(
...@@ -479,83 +447,6 @@ bool CompleteInstallFunction::RunImpl() { ...@@ -479,83 +447,6 @@ bool CompleteInstallFunction::RunImpl() {
return true; return true;
} }
SilentlyInstallFunction::SilentlyInstallFunction() {}
SilentlyInstallFunction::~SilentlyInstallFunction() {}
bool SilentlyInstallFunction::RunImpl() {
DictionaryValue* details = NULL;
EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &details));
CHECK(details);
EXTENSION_FUNCTION_VALIDATE(details->GetString(kIdKey, &id_));
if (!IsTrustedForSilentInstall(id_)) {
error_ = kInvalidIdError;
return false;
}
EXTENSION_FUNCTION_VALIDATE(details->GetString(kManifestKey, &manifest_));
// Matched in OnWebstoreParseFailure, OnExtensionInstall{Success,Failure}.
AddRef();
scoped_refptr<WebstoreInstallHelper> helper = new WebstoreInstallHelper(
this, id_, manifest_, std::string(), GURL(), NULL);
helper->Start();
return true;
}
void SilentlyInstallFunction::OnWebstoreParseSuccess(
const std::string& id,
const SkBitmap& icon,
base::DictionaryValue* parsed_manifest) {
CHECK_EQ(id_, id);
// This lets CrxInstaller bypass the permission confirmation UI for the
// extension. The whitelist entry gets cleared in
// CrxInstaller::ConfirmInstall.
scoped_ptr<WebstoreInstaller::Approval> approval(
WebstoreInstaller::Approval::CreateWithNoInstallPrompt(
profile(), id_, scoped_ptr<base::DictionaryValue>(parsed_manifest)));
approval->skip_post_install_ui = true;
scoped_refptr<WebstoreInstaller> installer = new WebstoreInstaller(
profile(), this,
&(dispatcher()->delegate()->GetAssociatedWebContents()->GetController()),
id_, approval.Pass(), WebstoreInstaller::FLAG_NONE);
installer->Start();
}
void SilentlyInstallFunction::OnWebstoreParseFailure(
const std::string& id,
InstallHelperResultCode result_code,
const std::string& error_message) {
CHECK_EQ(id_, id);
error_ = error_message;
SendResponse(false);
Release(); // Matches the AddRef() in RunImpl().
}
void SilentlyInstallFunction::OnExtensionInstallSuccess(const std::string& id) {
CHECK_EQ(id_, id);
SendResponse(true);
Release(); // Matches the AddRef() in RunImpl().
}
void SilentlyInstallFunction::OnExtensionInstallFailure(
const std::string& id, const std::string& error) {
CHECK_EQ(id_, id);
error_ = error;
SendResponse(false);
Release(); // Matches the AddRef() in RunImpl().
}
bool GetBrowserLoginFunction::RunImpl() { bool GetBrowserLoginFunction::RunImpl() {
SetResult(CreateLoginResult(profile_->GetOriginalProfile())); SetResult(CreateLoginResult(profile_->GetOriginalProfile()));
return true; return true;
......
...@@ -36,10 +36,6 @@ class WebstorePrivateApi { ...@@ -36,10 +36,6 @@ class WebstorePrivateApi {
static void SetWebstoreInstallerDelegateForTesting( static void SetWebstoreInstallerDelegateForTesting(
WebstoreInstaller::Delegate* delegate); WebstoreInstaller::Delegate* delegate);
// If |allow| is true, then the extension IDs used by the SilentlyInstall
// apitest will be trusted.
static void SetTrustTestIDsForTesting(bool allow);
// Gets the pending approval for the |extension_id| in |profile|. Pending // Gets the pending approval for the |extension_id| in |profile|. Pending
// approvals are held between the calls to beginInstallWithManifest and // approvals are held between the calls to beginInstallWithManifest and
// completeInstall. This should only be used for testing. // completeInstall. This should only be used for testing.
...@@ -164,40 +160,6 @@ class CompleteInstallFunction : public SyncExtensionFunction { ...@@ -164,40 +160,6 @@ class CompleteInstallFunction : public SyncExtensionFunction {
virtual bool RunImpl() OVERRIDE; virtual bool RunImpl() OVERRIDE;
}; };
class SilentlyInstallFunction : public AsyncExtensionFunction,
public WebstoreInstallHelper::Delegate,
public WebstoreInstaller::Delegate {
public:
DECLARE_EXTENSION_FUNCTION_NAME("webstorePrivate.silentlyInstall");
SilentlyInstallFunction();
// WebstoreInstallHelper::Delegate:
virtual void OnWebstoreParseSuccess(
const std::string& id,
const SkBitmap& icon,
base::DictionaryValue* parsed_manifest) OVERRIDE;
virtual void OnWebstoreParseFailure(
const std::string& id,
InstallHelperResultCode result_code,
const std::string& error_message) OVERRIDE;
// WebstoreInstaller::Delegate:
virtual void OnExtensionInstallSuccess(const std::string& id) OVERRIDE;
virtual void OnExtensionInstallFailure(const std::string& id,
const std::string& error) OVERRIDE;
protected:
virtual ~SilentlyInstallFunction();
// ExtensionFunction:
virtual bool RunImpl() OVERRIDE;
private:
std::string id_;
std::string manifest_;
};
class GetBrowserLoginFunction : public SyncExtensionFunction { class GetBrowserLoginFunction : public SyncExtensionFunction {
public: public:
DECLARE_EXTENSION_FUNCTION_NAME("webstorePrivate.getBrowserLogin"); DECLARE_EXTENSION_FUNCTION_NAME("webstorePrivate.getBrowserLogin");
......
...@@ -357,17 +357,6 @@ IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, InstallTheme) { ...@@ -357,17 +357,6 @@ IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, InstallTheme) {
ASSERT_EQ("iamefpfkojoapidjnbafmgkgncegbkad", listener.id()); ASSERT_EQ("iamefpfkojoapidjnbafmgkgncegbkad", listener.id());
} }
// Tests using silentlyInstall to install extensions.
IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateBundleTest, SilentlyInstall) {
WebstorePrivateApi::SetTrustTestIDsForTesting(true);
PackCRX("bmfoocgfinpmkmlbjhcbofejhkhlbchk", "extension1.json");
PackCRX("mpneghmdnmaolkljkipbhaienajcflfe", "extension2.json");
PackCRX("begfmnajjkbjdgmffnjaojchoncnmngg", "app2.json");
ASSERT_TRUE(RunPageTest(GetTestServerURL("silently_install.html").spec()));
}
// Tests successfully installing a bundle of 2 apps and 2 extensions. // Tests successfully installing a bundle of 2 apps and 2 extensions.
IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateBundleTest, InstallBundle) { IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateBundleTest, InstallBundle) {
extensions::BundleInstaller::SetAutoApproveForTesting(true); extensions::BundleInstaller::SetAutoApproveForTesting(true);
......
...@@ -322,7 +322,6 @@ void ExtensionFunctionRegistry::ResetFunctions() { ...@@ -322,7 +322,6 @@ void ExtensionFunctionRegistry::ResetFunctions() {
RegisterFunction<extensions::InstallBundleFunction>(); RegisterFunction<extensions::InstallBundleFunction>();
RegisterFunction<extensions::BeginInstallWithManifestFunction>(); RegisterFunction<extensions::BeginInstallWithManifestFunction>();
RegisterFunction<extensions::CompleteInstallFunction>(); RegisterFunction<extensions::CompleteInstallFunction>();
RegisterFunction<extensions::SilentlyInstallFunction>();
RegisterFunction<extensions::GetWebGLStatusFunction>(); RegisterFunction<extensions::GetWebGLStatusFunction>();
// WebNavigation. // WebNavigation.
......
...@@ -142,36 +142,6 @@ ...@@ -142,36 +142,6 @@
} }
] ]
}, },
{
"name": "silentlyInstall",
"description": "Silently installs the specified extension, which must already be whitelisted in Chrome.",
"parameters": [
{
"name": "details",
"type": "object",
"properties": {
"id": {
"type": "string",
"description": "The id of the extension to be installled.",
"minLength": 32,
"maxLength": 32
},
"manifest": {
"type": "string",
"description": "A string with the contents of the extension's manifest.json file. During the install process, the browser will check that the downloaded extension's manifest matches what was passed in here.",
"minLength": 1
}
}
},
{
"name": "callback",
"type": "function",
"description": "Called when the extension installation has completed. chrome.extension.lastError may be set if the extension install failed.",
"optional": "true",
"parameters": []
}
]
},
{ {
"name": "getBrowserLogin", "name": "getBrowserLogin",
"description": "Returns the logged-in sync user login if there is one, or the empty string otherwise.", "description": "Returns the logged-in sync user login if there is one, or the empty string otherwise.",
......
<!--
* Copyright (c) 2012 The Chromium Authors. All rights reserved. Use of this
* source code is governed by a BSD-style license that can be found in the
* LICENSE file.
-->
<script src="common.js"></script>
<script>
var extension1 = {
'id': 'bmfoocgfinpmkmlbjhcbofejhkhlbchk',
'manifest': getManifest('bundle/extension1.json')
};
var extension2 = {
'id': 'mpneghmdnmaolkljkipbhaienajcflfe',
'manifest': getManifest('bundle/extension2.json')
};
var extension3 = {
'id': 'begfmnajjkbjdgmffnjaojchoncnmngg',
'manifest': getManifest('bundle/app2.json')
};
runTests([
function invalidID() {
var expectedError = "Invalid id";
chrome.webstorePrivate.silentlyInstall(
{ 'id': 'dladmdjkfniedhfhcfoefgojhgaiaccc', 'manifest': getManifest() },
callbackFail(expectedError));
},
function successfulInstall() {
chrome.webstorePrivate.silentlyInstall(extension1, callbackPass(function() {
checkItemInstalled(
extension1.id,
callbackPass(function(result) { assertTrue(result); }));
}));
chrome.webstorePrivate.silentlyInstall(extension2, callbackPass(function() {
checkItemInstalled(
extension2.id,
callbackPass(function(result) { assertTrue(result); }));
chrome.webstorePrivate.silentlyInstall(
extension3, callbackPass(function() {
checkItemInstalled(
extension3.id,
callbackPass(function(result) { assertTrue(result); }));
}));
}));
}
]);
</script>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment