Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4524)

Unified Diff: chrome/browser/download/download_extension_api.cc

Issue 10213002: Make downloads.download() respect host permissions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/downloads/manifest.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/download/download_extension_api.cc
diff --git a/chrome/browser/download/download_extension_api.cc b/chrome/browser/download/download_extension_api.cc
index 48006b83ce1ae96bdbcd98f17722a4bffec249a1..58f60ba81da3ef4af9d8e1dfb8f53eea7633945a 100644
--- a/chrome/browser/download/download_extension_api.cc
+++ b/chrome/browser/download/download_extension_api.cc
@@ -381,6 +381,18 @@ bool DownloadsDownloadFunction::ParseArgs() {
return false;
}
+ // The host permissions should not be why e.g. data, filesystem URLs don't
+ // work.
+ if ((iodata_->url.SchemeIs("http") ||
Mihai Parparita -not on Chrome 2012/05/01 20:08:31 Why do you have these scheme checks? HasHostPermis
benjhayden 2012/05/01 20:19:12 HasHostPermission() *disallows* schemes other than
Mihai Parparita -not on Chrome 2012/05/01 20:53:12 Then I'd rather have those be explicitly listed (i
benjhayden 2012/05/02 14:40:18 Done.
+ iodata_->url.SchemeIs("https") ||
+ iodata_->url.SchemeIs("ftp") ||
+ iodata_->url.SchemeIs("file") ||
+ iodata_->url.SchemeIs("chrome-extension")) &&
+ !GetExtension()->HasHostPermission(iodata_->url)) {
+ error_ = download_extension_errors::kInvalidURLError;
+ return false;
+ }
+
if (options->HasKey(kFilenameKey)) {
EXTENSION_FUNCTION_VALIDATE(options->GetString(
kFilenameKey, &iodata_->filename));
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/downloads/manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698