summaryrefslogtreecommitdiffstats
path: root/chrome/common/extensions
diff options
context:
space:
mode:
authorrafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-07 04:52:55 +0000
committerrafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-07 04:52:55 +0000
commitb281ab6e72be9b1df735395da6979c21712a8e5d (patch)
tree083a068bf5056e4c37790b793afe04c26d60a44e /chrome/common/extensions
parentb792af76625e5f3d9801277b628352243fdcbb18 (diff)
downloadchromium_src-b281ab6e72be9b1df735395da6979c21712a8e5d.zip
chromium_src-b281ab6e72be9b1df735395da6979c21712a8e5d.tar.gz
chromium_src-b281ab6e72be9b1df735395da6979c21712a8e5d.tar.bz2
Allow silent extension installations from the extensions gallery - Part 1.
In this episode we: -Create a new ChildProcess privilege (SILENT_INSTALL_EXTENSION) which is granted to the extension gallery pages. -Ensure that extension gallery pages are isolated into their own process which is never shared with other urls. Important: The SILENT_INSTALL_EXTENSION privilege is never granted any additional abilities in this patch, so this patch only has the effect of grouping gallery URLs into a separate process. In subsequent patch(es) we plan to (a) observe this new privilege and allow gallery urls to install extensions bypassing the normal prompts, (b) polish this UI flow [in particular, do not show the black "loading" dilaog, (c) check the id of the extension to be installed (from the crx) matches the expected id (from gallery url). BUG=27431 Review URL: http://codereview.chromium.org/400018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33952 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/extensions')
-rw-r--r--chrome/common/extensions/extension.cc26
-rw-r--r--chrome/common/extensions/extension.h8
2 files changed, 34 insertions, 0 deletions
diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc
index 94d6de2..04ae051c 100644
--- a/chrome/common/extensions/extension.cc
+++ b/chrome/common/extensions/extension.cc
@@ -128,6 +128,32 @@ const std::string Extension::VersionString() const {
}
// static
+bool Extension::IsGalleryURL(const GURL& url) {
+ return StartsWithASCII(url.spec(),
+ std::string(extension_urls::kGalleryBrowsePrefix), true);
+}
+
+// static
+bool Extension::IsDownloadFromGallery(const GURL& download_url,
+ const GURL& referrer_url) {
+ if (StartsWithASCII(download_url.spec(),
+ extension_urls::kMiniGalleryDownloadPrefix, false) &&
+ StartsWithASCII(referrer_url.spec(),
+ extension_urls::kMiniGalleryBrowsePrefix, false)) {
+ return true;
+ }
+
+ if (StartsWithASCII(download_url.spec(),
+ extension_urls::kGalleryDownloadPrefix, false) &&
+ StartsWithASCII(referrer_url.spec(),
+ extension_urls::kGalleryBrowsePrefix, false)) {
+ return true;
+ }
+
+ return false;
+}
+
+// static
bool Extension::IsExtension(const FilePath& file_name) {
return file_name.MatchesExtension(
FilePath::StringType(FILE_PATH_LITERAL(".")) +
diff --git a/chrome/common/extensions/extension.h b/chrome/common/extensions/extension.h
index 331de16..28bffc1 100644
--- a/chrome/common/extensions/extension.h
+++ b/chrome/common/extensions/extension.h
@@ -122,6 +122,14 @@ class Extension {
explicit Extension(const FilePath& path);
virtual ~Extension();
+ // Determine if a given |url| is a gallery browse URL.
+ static bool IsGalleryURL(const GURL& url);
+
+ // Determine if a given extension download should be treated as if it came
+ // from the theme gallery.
+ static bool IsDownloadFromGallery(const GURL& download_url,
+ const GURL& referrer_url);
+
// Checks to see if the extension has a valid ID.
static bool IdIsValid(const std::string& id);