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

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

Issue 1165893004: [Downloads] Prevent dangerous files from being opened automatically. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
Index: chrome/browser/download/download_extensions.cc
diff --git a/chrome/browser/download/download_extensions.cc b/chrome/browser/download/download_extensions.cc
index 623bdf48d855f651fcc7ef343522d450bd9a5fba..6475045897f2e024e8e09345ddacce12fc4b52f4 100644
--- a/chrome/browser/download/download_extensions.cc
+++ b/chrome/browser/download/download_extensions.cc
@@ -227,6 +227,14 @@ DownloadDangerLevel GetFileDangerLevel(const base::FilePath& path) {
return NOT_DANGEROUS;
}
+bool IsAllowedToOpenAutomatically(const base::FilePath& path) {
+ // This is probably overly conservative, but the intention is that if the file
+ // type was dangerous enough to require prompting, then we shouldn't allow
+ // opening it automatically.
+ base::FilePath::StringType extension(path.FinalExtension());
+ return !extension.empty() && GetFileDangerLevel(path) == NOT_DANGEROUS;
Randy Smith (Not in Mondays) 2015/06/03 23:44:07 So we no longer allow ALLOW_ON_USER_GESTURE files
Randy Smith (Not in Mondays) 2015/06/03 23:44:07 The !extension.empty() test is redundant with the
asanka 2015/06/04 15:30:48 The check is different. GetFileDangerLevel() retur
+}
+
static const char* kExecutableWhiteList[] = {
// JavaScript is just as powerful as EXE.
"text/javascript",

Powered by Google App Engine
This is Rietveld 408576698