Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <set> | 5 #include <set> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "chrome/browser/download/download_extensions.h" | 8 #include "chrome/browser/download/download_extensions.h" |
| 9 | 9 |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 220 if (ascii_extension[0] == base::FilePath::kExtensionSeparator) | 220 if (ascii_extension[0] == base::FilePath::kExtensionSeparator) |
| 221 ascii_extension.erase(0, 1); | 221 ascii_extension.erase(0, 1); |
| 222 | 222 |
| 223 for (size_t i = 0; i < arraysize(g_executables); ++i) { | 223 for (size_t i = 0; i < arraysize(g_executables); ++i) { |
| 224 if (LowerCaseEqualsASCII(ascii_extension, g_executables[i].extension)) | 224 if (LowerCaseEqualsASCII(ascii_extension, g_executables[i].extension)) |
| 225 return g_executables[i].level; | 225 return g_executables[i].level; |
| 226 } | 226 } |
| 227 return NOT_DANGEROUS; | 227 return NOT_DANGEROUS; |
| 228 } | 228 } |
| 229 | 229 |
| 230 bool IsAllowedToOpenAutomatically(const base::FilePath& path) { | |
| 231 // This is probably overly conservative, but the intention is that if the file | |
| 232 // type was dangerous enough to require prompting, then we shouldn't allow | |
| 233 // opening it automatically. | |
| 234 base::FilePath::StringType extension(path.FinalExtension()); | |
| 235 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
| |
| 236 } | |
| 237 | |
| 230 static const char* kExecutableWhiteList[] = { | 238 static const char* kExecutableWhiteList[] = { |
| 231 // JavaScript is just as powerful as EXE. | 239 // JavaScript is just as powerful as EXE. |
| 232 "text/javascript", | 240 "text/javascript", |
| 233 "text/javascript;version=*", | 241 "text/javascript;version=*", |
| 234 "text/html", | 242 "text/html", |
| 235 // Registry files can cause critical changes to the MS OS behavior. | 243 // Registry files can cause critical changes to the MS OS behavior. |
| 236 // Addition of this mimetype also addresses bug 7337. | 244 // Addition of this mimetype also addresses bug 7337. |
| 237 "text/x-registry", | 245 "text/x-registry", |
| 238 "text/x-sh", | 246 "text/x-sh", |
| 239 // Some sites use binary/octet-stream to mean application/octet-stream. | 247 // Some sites use binary/octet-stream to mean application/octet-stream. |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 255 for (size_t i = 0; i < arraysize(kExecutableBlackList); ++i) { | 263 for (size_t i = 0; i < arraysize(kExecutableBlackList); ++i) { |
| 256 if (net::MatchesMimeType(kExecutableBlackList[i], mime_type)) | 264 if (net::MatchesMimeType(kExecutableBlackList[i], mime_type)) |
| 257 return false; | 265 return false; |
| 258 } | 266 } |
| 259 // We consider only other application types to be executable. | 267 // We consider only other application types to be executable. |
| 260 return net::MatchesMimeType("application/*", mime_type); | 268 return net::MatchesMimeType("application/*", mime_type); |
| 261 } | 269 } |
| 262 | 270 |
| 263 | 271 |
| 264 } // namespace download_util | 272 } // namespace download_util |
| OLD | NEW |