diff options
author | abarth@chromium.org <abarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-15 20:56:46 +0000 |
---|---|---|
committer | abarth@chromium.org <abarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-15 20:56:46 +0000 |
commit | 7b73d994dc6edf83fecc7ceec07746a160fbdb07 (patch) | |
tree | 256c112148a850cfabcfa006c2f8b8df82d49e4f /chrome | |
parent | 83b0855da21a4d3ac6b3c6b6bef872d79fb11727 (diff) | |
download | chromium_src-7b73d994dc6edf83fecc7ceec07746a160fbdb07.zip chromium_src-7b73d994dc6edf83fecc7ceec07746a160fbdb07.tar.gz chromium_src-7b73d994dc6edf83fecc7ceec07746a160fbdb07.tar.bz2 |
Cleanup IsExecutableMimeType.
R=cpu
Review URL: http://codereview.chromium.org/14417
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7004 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/download/download_manager.cc | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/chrome/browser/download/download_manager.cc b/chrome/browser/download/download_manager.cc index d746355..5328807 100644 --- a/chrome/browser/download/download_manager.cc +++ b/chrome/browser/download/download_manager.cc @@ -1177,29 +1177,33 @@ bool DownloadManager::ShouldOpenFileExtension(const std::wstring& extension) { return false; } -// static -bool DownloadManager::IsExecutableMimeType(const std::string& mime_type) { +static const char* kExecutableWhiteList[] = { // JavaScript is just as powerful as EXE. - if (net::MatchesMimeType("text/javascript", mime_type)) - return true; - if (net::MatchesMimeType("text/javascript;version=*", mime_type)) - return true; + "text/javascript", + "text/javascript;version=*", // Some sites use binary/octet-stream to mean application/octet-stream. // See http://code.google.com/p/chromium/issues/detail?id=1573 - if (net::MatchesMimeType("binary/octet-stream", mime_type)) - return true; - - // We don't consider other non-application types to be executable. - if (!net::MatchesMimeType("application/*", mime_type)) - return false; + "binary/octet-stream" +}; +static const char* kExecutableBlackList[] = { // These application types are not executable. - if (net::MatchesMimeType("application/*+xml", mime_type)) - return false; - if (net::MatchesMimeType("application/xml", mime_type)) - return false; + "application/*+xml", + "application/xml" +}; - return true; +// static +bool DownloadManager::IsExecutableMimeType(const std::string& mime_type) { + for (int i=0; i < arraysize(kExecutableWhiteList); ++i) { + if (net::MatchesMimeType(kExecutableWhiteList[i], mime_type)) + return true; + } + for (int i=0; i < arraysize(kExecutableBlackList); ++i) { + if (net::MatchesMimeType(kExecutableBlackList[i], mime_type)) + return false; + } + // We consider only other application types to be executable. + return net::MatchesMimeType("application/*", mime_type); } bool DownloadManager::IsExecutable(const std::wstring& extension) { |