summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions
diff options
context:
space:
mode:
authorjstritar@chromium.org <jstritar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-06 19:27:33 +0000
committerjstritar@chromium.org <jstritar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-06 19:27:33 +0000
commitf5fc8ce3401b601e8195dca5a2c05c65ad476bea (patch)
tree95f636cbfc98d7e7ef1aa505d7abdd5f8fe2a6ed /chrome/browser/extensions
parent43f1b701cb9764b72351f18e89675b49f2018886 (diff)
downloadchromium_src-f5fc8ce3401b601e8195dca5a2c05c65ad476bea.zip
chromium_src-f5fc8ce3401b601e8195dca5a2c05c65ad476bea.tar.gz
chromium_src-f5fc8ce3401b601e8195dca5a2c05c65ad476bea.tar.bz2
Make sure the post install UI hooks are triggered properly when installing CRXs.
BUG=122170 TEST=ExtensionWebstorePrivateApiTest.BeginInstall Review URL: http://codereview.chromium.org/10008050 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@131165 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions')
-rw-r--r--chrome/browser/extensions/extension_webstore_private_api.cc7
-rw-r--r--chrome/browser/extensions/extension_webstore_private_api.h6
-rw-r--r--chrome/browser/extensions/extension_webstore_private_apitest.cc30
-rw-r--r--chrome/browser/extensions/webstore_installer.cc5
4 files changed, 41 insertions, 7 deletions
diff --git a/chrome/browser/extensions/extension_webstore_private_api.cc b/chrome/browser/extensions/extension_webstore_private_api.cc
index f8e3316..f53abff 100644
--- a/chrome/browser/extensions/extension_webstore_private_api.cc
+++ b/chrome/browser/extensions/extension_webstore_private_api.cc
@@ -179,6 +179,13 @@ void WebstorePrivateApi::SetTrustTestIDsForTesting(bool allow) {
trust_test_ids = allow;
}
+// static
+scoped_ptr<WebstoreInstaller::Approval>
+ WebstorePrivateApi::PopApprovalForTesting(
+ Profile* profile, const std::string& extension_id) {
+ return g_pending_approvals.Get().PopApproval(profile, extension_id);
+}
+
InstallBundleFunction::InstallBundleFunction() {}
InstallBundleFunction::~InstallBundleFunction() {}
diff --git a/chrome/browser/extensions/extension_webstore_private_api.h b/chrome/browser/extensions/extension_webstore_private_api.h
index 8a9945f..193a186 100644
--- a/chrome/browser/extensions/extension_webstore_private_api.h
+++ b/chrome/browser/extensions/extension_webstore_private_api.h
@@ -37,6 +37,12 @@ class WebstorePrivateApi {
// 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
+ // approvals are held between the calls to beginInstallWithManifest and
+ // completeInstall. This should only be used for testing.
+ static scoped_ptr<WebstoreInstaller::Approval> PopApprovalForTesting(
+ Profile* profile, const std::string& extension_id);
};
class InstallBundleFunction : public AsyncExtensionFunction,
diff --git a/chrome/browser/extensions/extension_webstore_private_apitest.cc b/chrome/browser/extensions/extension_webstore_private_apitest.cc
index 6489435..7f4e984 100644
--- a/chrome/browser/extensions/extension_webstore_private_apitest.cc
+++ b/chrome/browser/extensions/extension_webstore_private_apitest.cc
@@ -274,8 +274,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, InstallCancelled) {
ASSERT_TRUE(RunInstallTest("cancelled.html", "extension.crx"));
}
-IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest,
- IncorrectManifest1) {
+IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, IncorrectManifest1) {
WebstoreInstallListener listener;
WebstorePrivateApi::SetWebstoreInstallerDelegateForTesting(&listener);
ASSERT_TRUE(RunInstallTest("incorrect_manifest1.html", "extension.crx"));
@@ -284,8 +283,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest,
ASSERT_EQ("Manifest file is invalid.", listener.error());
}
-IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest,
- IncorrectManifest2) {
+IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, IncorrectManifest2) {
WebstoreInstallListener listener;
WebstorePrivateApi::SetWebstoreInstallerDelegateForTesting(&listener);
ASSERT_TRUE(RunInstallTest("incorrect_manifest2.html", "extension.crx"));
@@ -306,11 +304,31 @@ IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, AppInstallBubble) {
}
// Tests using the iconUrl parameter to the install function.
-IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest,
- IconUrl) {
+IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, IconUrl) {
ASSERT_TRUE(RunInstallTest("icon_url.html", "extension.crx"));
}
+// Tests that the Approvals are properly created in beginInstall.
+IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, BeginInstall) {
+ std::string appId = "iladmdjkfniedhfhcfoefgojhgaiaccc";
+ std::string extensionId = "enfkhcelefdadlmkffamgdlgplcionje";
+ ASSERT_TRUE(RunInstallTest("begin_install.html", "extension.crx"));
+
+ scoped_ptr<WebstoreInstaller::Approval> approval =
+ WebstorePrivateApi::PopApprovalForTesting(browser()->profile(), appId);
+ EXPECT_EQ(appId, approval->extension_id);
+ EXPECT_TRUE(approval->use_app_installed_bubble);
+ EXPECT_FALSE(approval->skip_post_install_ui);
+ EXPECT_EQ(browser()->profile(), approval->profile);
+
+ approval = WebstorePrivateApi::PopApprovalForTesting(
+ browser()->profile(), extensionId);
+ EXPECT_EQ(extensionId, approval->extension_id);
+ EXPECT_FALSE(approval->use_app_installed_bubble);
+ EXPECT_FALSE(approval->skip_post_install_ui);
+ EXPECT_EQ(browser()->profile(), approval->profile);
+}
+
// Tests using silentlyInstall to install extensions.
IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateBundleTest, SilentlyInstall) {
WebstorePrivateApi::SetTrustTestIDsForTesting(true);
diff --git a/chrome/browser/extensions/webstore_installer.cc b/chrome/browser/extensions/webstore_installer.cc
index 38c92b4..1455430 100644
--- a/chrome/browser/extensions/webstore_installer.cc
+++ b/chrome/browser/extensions/webstore_installer.cc
@@ -124,7 +124,10 @@ const WebstoreInstaller::Approval* WebstoreInstaller::GetAssociatedApproval(
return static_cast<const Approval*>(download.GetExternalData(kApprovalKey));
}
-WebstoreInstaller::Approval::Approval() : profile(NULL) {}
+WebstoreInstaller::Approval::Approval()
+ : profile(NULL),
+ use_app_installed_bubble(false),
+ skip_post_install_ui(false) {}
WebstoreInstaller::Approval::~Approval() {}
WebstoreInstaller::WebstoreInstaller(Profile* profile,