summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions
diff options
context:
space:
mode:
authoraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-24 17:41:39 +0000
committeraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-24 17:41:39 +0000
commit75a256796767eb2002d46080bf8474eed84cb1d2 (patch)
tree75cab986938ee6bfd6f5c5e78d98bbb026f479d5 /chrome/browser/extensions
parent4f14f81100d3f7bb283c3cb23f35f4d514e12443 (diff)
downloadchromium_src-75a256796767eb2002d46080bf8474eed84cb1d2.zip
chromium_src-75a256796767eb2002d46080bf8474eed84cb1d2.tar.gz
chromium_src-75a256796767eb2002d46080bf8474eed84cb1d2.tar.bz2
More (temporary) cleanup for theme installation:
- Modify the gallery URL to only allow SSL. - Remove the special case that allowed theme installation without --enable-extension. Now that we have the gallery special case this is not necessary anymore. - Modify the dialog language to be a little less lame. Review URL: http://codereview.chromium.org/159301 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21543 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions')
-rw-r--r--chrome/browser/extensions/extensions_service.cc56
-rw-r--r--chrome/browser/extensions/extensions_service.h3
-rw-r--r--chrome/browser/extensions/extensions_service_unittest.cc21
3 files changed, 52 insertions, 28 deletions
diff --git a/chrome/browser/extensions/extensions_service.cc b/chrome/browser/extensions/extensions_service.cc
index 9dc74e4..9872c72 100644
--- a/chrome/browser/extensions/extensions_service.cc
+++ b/chrome/browser/extensions/extensions_service.cc
@@ -61,6 +61,9 @@ const char ExtensionsService::kExtensionHeaderMagic[] = "Cr24";
const char* ExtensionsService::kInstallDirectoryName = "Extensions";
const char* ExtensionsService::kCurrentVersionFileName = "Current Version";
+const char* ExtensionsService::kGalleryURLPrefix =
+ "https://tools.google.com/chrome/";
+
const char* ExtensionsServiceBackend::kTempExtensionName = "TEMP_INSTALL";
namespace {
@@ -79,9 +82,6 @@ const char* kSignatureVerificationFailed = "Signature verification failed";
const char* kSignatureVerificationInitFailed =
"Signature verification initialization failed. This is most likely "
"caused by a public key in the wrong format (should encode algorithm).";
-
-const char* kGalleryHost = "www.google.com";
-const char* kGalleryPath = "/chrome/";
}
// This class coordinates an extension unpack task which is run in a separate
@@ -297,9 +297,9 @@ void ExtensionsService::InstallExtension(const FilePath& extension_path) {
}
void ExtensionsService::InstallExtension(const FilePath& extension_path,
- const GURL& url) {
- bool from_gallery = url.host() == kGalleryHost &&
- StartsWithASCII(url.path(), kGalleryPath, false);
+ const GURL& referrer_url) {
+ bool from_gallery = StartsWithASCII(referrer_url.spec(), kGalleryURLPrefix,
+ false);
backend_loop_->PostTask(FROM_HERE, NewRunnableMethod(backend_.get(),
&ExtensionsServiceBackend::InstallExtension, extension_path, from_gallery,
@@ -438,15 +438,18 @@ void ExtensionsService::OnLoadedInstalledExtensions() {
void ExtensionsService::OnExtensionsLoaded(ExtensionList* new_extensions) {
scoped_ptr<ExtensionList> cleanup(new_extensions);
- // Filter out any extensions that shouldn't be loaded. Themes are always
- // loaded, but other extensions are only loaded if the extensions system is
- // enabled.
+ // Filter out any extensions that shouldn't be loaded. If extensions are
+ // enabled, load everything. Otherwise load only:
+ // - themes
+ // - --load-extension
+ // - externally installed extensions
ExtensionList enabled_extensions;
for (ExtensionList::iterator iter = new_extensions->begin();
iter != new_extensions->end(); ++iter) {
- if (extensions_enabled() || (*iter)->IsTheme() ||
+ if (extensions_enabled() ||
+ (*iter)->IsTheme() ||
(*iter)->location() == Extension::LOAD ||
- (*iter)->location() == Extension::EXTERNAL_REGISTRY) {
+ Extension::IsExternalLocation((*iter)->location())) {
Extension* old = GetExtensionById((*iter)->id());
if (old) {
if ((*iter)->version()->CompareTo(*(old->version())) > 0) {
@@ -1097,25 +1100,31 @@ void ExtensionsServiceBackend::OnExtensionUnpacked(
Extension::Location location = Extension::INTERNAL;
LookupExternalExtension(extension.id(), NULL, &location);
- // We currently only allow themes and registry-installed extensions to be
- // installed.
- if (!extensions_enabled_ &&
- !extension.IsTheme() &&
- !Extension::IsExternalLocation(location)) {
+ // We allow themes from our minigallery or externally-registered
+ // extensions to be installed, even without --enable-extensions.
+ bool allow_install = false;
+ if (extensions_enabled_)
+ allow_install = true;
+
+ if (extension.IsTheme() && from_gallery)
+ allow_install = true;
+
+ if (Extension::IsExternalLocation(location))
+ allow_install = true;
+
+ if (!allow_install) {
ReportExtensionInstallError(extension_path,
- "Extensions are not enabled. Add --enable-extensions to the "
- "command-line to enable extensions.\n\n"
- "This is a temporary message and it will be removed when extensions "
- "UI is finalized.");
+ "Extensions are not enabled.");
return;
}
// TODO(extensions): Make better extensions UI. http://crbug.com/12116
- // We don't show the dialog for a few special cases:
+ // We also skip the dialog for a few special cases:
// - themes from the gallery
// - externally registered extensions
- // - during tests (!frontend->show_extension_prompts()) and updates (silent).
+ // - during tests (!frontend->show_extension_prompts())
+ // - autoupdate (silent).
bool show_dialog = true;
if (extension.IsTheme() && from_gallery)
show_dialog = false;
@@ -1130,8 +1139,7 @@ void ExtensionsServiceBackend::OnExtensionUnpacked(
#if defined(OS_WIN)
if (win_util::MessageBox(GetForegroundWindow(),
L"Are you sure you want to install this extension?\n\n"
- L"This is a temporary message and it will be removed when "
- L"extensions UI is finalized.",
+ L"You should only install extensions from sources you trust.",
l10n_util::GetString(IDS_PRODUCT_NAME).c_str(),
MB_OKCANCEL) != IDOK) {
ReportExtensionInstallError(extension_path,
diff --git a/chrome/browser/extensions/extensions_service.h b/chrome/browser/extensions/extensions_service.h
index d63073c..0a36cc8 100644
--- a/chrome/browser/extensions/extensions_service.h
+++ b/chrome/browser/extensions/extensions_service.h
@@ -183,6 +183,9 @@ class ExtensionsService
// The name of the file that the current active version number is stored in.
static const char* kCurrentVersionFileName;
+ // A special URL that allows theme installation without prompts.
+ static const char* kGalleryURLPrefix;
+
void SetExtensionsEnabled(bool enabled);
bool extensions_enabled() { return extensions_enabled_; }
diff --git a/chrome/browser/extensions/extensions_service_unittest.cc b/chrome/browser/extensions/extensions_service_unittest.cc
index a9fff40..8822a48 100644
--- a/chrome/browser/extensions/extensions_service_unittest.cc
+++ b/chrome/browser/extensions/extensions_service_unittest.cc
@@ -342,8 +342,14 @@ class ExtensionsServiceTest
void InstallExtension(const FilePath& path,
bool should_succeed) {
+ InstallExtension(path, should_succeed, GURL());
+ }
+
+ void InstallExtension(const FilePath& path,
+ bool should_succeed,
+ const GURL& referrer_url) {
ASSERT_TRUE(file_util::PathExists(path));
- service_->InstallExtension(path);
+ service_->InstallExtension(path, referrer_url);
loop_.RunAllPending();
std::vector<std::string> errors = GetErrors();
if (should_succeed) {
@@ -793,11 +799,18 @@ TEST_F(ExtensionsServiceTest, InstallTheme) {
ValidatePref(theme_crx, L"state", Extension::ENABLED);
ValidatePref(theme_crx, L"location", Extension::INTERNAL);
- // A theme when extensions are disabled. Themes can be installed even though
- // extensions are disabled.
+ // A theme when extensions are disabled. Themes cannot be installed when
+ // extensions are disabled...
SetExtensionsEnabled(false);
path = extensions_path.AppendASCII("theme2.crx");
- InstallExtension(path, true);
+ InstallExtension(path, false);
+ ValidatePrefKeyCount(pref_count);
+
+ // ... unless they come from the gallery URL.
+ SetExtensionsEnabled(false);
+ path = extensions_path.AppendASCII("theme2.crx");
+ InstallExtension(path, true, GURL(
+ std::string(ExtensionsService::kGalleryURLPrefix) + "foobar"));
ValidatePrefKeyCount(++pref_count);
ValidatePref(theme2_crx, L"state", Extension::ENABLED);
ValidatePref(theme2_crx, L"location", Extension::INTERNAL);