summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorerikkay@chromium.org <erikkay@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-06 17:23:44 +0000
committererikkay@chromium.org <erikkay@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-06 17:23:44 +0000
commit1debbbb6a7a2fb97530cfae8c59273bd43040e1b (patch)
treed2f0f71a4aecce8cca0a5e1880ca26cfb36cbabc
parenta3fbc559dc981ca0226e6a5a6e5a9067ff8b3a16 (diff)
downloadchromium_src-1debbbb6a7a2fb97530cfae8c59273bd43040e1b.zip
chromium_src-1debbbb6a7a2fb97530cfae8c59273bd43040e1b.tar.gz
chromium_src-1debbbb6a7a2fb97530cfae8c59273bd43040e1b.tar.bz2
Relax gallery test download checks so that we can test
installing hosted apps from test galleries. BUG=54408 TEST=Install a hosted app from a test gallery using the --apps-gallery-url command-line flag. Review URL: http://codereview.chromium.org/3611009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61660 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/extensions/extensions_service.cc45
1 files changed, 37 insertions, 8 deletions
diff --git a/chrome/browser/extensions/extensions_service.cc b/chrome/browser/extensions/extensions_service.cc
index ea47716..286a283 100644
--- a/chrome/browser/extensions/extensions_service.cc
+++ b/chrome/browser/extensions/extensions_service.cc
@@ -57,6 +57,7 @@
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "googleurl/src/gurl.h"
+#include "net/base/registry_controlled_domain.h"
#include "webkit/database/database_tracker.h"
#include "webkit/database/database_util.h"
@@ -164,10 +165,21 @@ bool IsGalleryDownloadURL(const GURL& download_url) {
std::string command_line_gallery_url =
CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
switches::kAppsGalleryURL);
- if (!command_line_gallery_url.empty() &&
- StartsWithASCII(download_url.spec(),
- command_line_gallery_url, false))
- return true;
+ if (!command_line_gallery_url.empty()) {
+ if (StartsWithASCII(download_url.spec(), command_line_gallery_url, false))
+ return true;
+
+ // When using the command-line gallery switch, be a bit more lenient with
+ // the check and allow hosts that match the root host.
+ std::string download_domain =
+ net::RegistryControlledDomainService::GetDomainAndRegistry(
+ download_url);
+ std::string command_line_domain =
+ net::RegistryControlledDomainService::GetDomainAndRegistry(
+ GURL(command_line_gallery_url));
+ if (download_domain == command_line_domain)
+ return true;
+ }
return false;
}
@@ -503,6 +515,9 @@ void ExtensionsServiceBackend::ReloadExtensionManifests(
// static
bool ExtensionsService::IsDownloadFromGallery(const GURL& download_url,
const GURL& referrer_url) {
+ if (referrer_url.is_empty() || !referrer_url.is_valid())
+ return false;
+
if (!IsGalleryDownloadURL(download_url))
return false;
@@ -518,10 +533,24 @@ bool ExtensionsService::IsDownloadFromGallery(const GURL& download_url,
std::string command_line_gallery_url =
CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
switches::kAppsGalleryURL);
- if (!command_line_gallery_url.empty() &&
- StartsWithASCII(referrer_url.spec(),
- command_line_gallery_url, false))
- return true;
+ if (!command_line_gallery_url.empty()) {
+ if (StartsWithASCII(referrer_url.spec(), command_line_gallery_url, false))
+ return true;
+
+ // When using the command-line gallery switch, be a bit more lenient with
+ // the check and allow hosts that match the root host.
+ // TODO(erikkay) On test galleries, the current config sometimes leaves us
+ // with an empty referrer. With the command-line flag set, maybe we should
+ // just ignore referrer altogether?
+ std::string referrer_domain =
+ net::RegistryControlledDomainService::GetDomainAndRegistry(
+ referrer_url);
+ std::string command_line_domain =
+ net::RegistryControlledDomainService::GetDomainAndRegistry(
+ GURL(command_line_gallery_url));
+ if (referrer_domain == command_line_domain)
+ return true;
+ }
return false;
}