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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 #if defined(OS_ANDROID) | 202 #if defined(OS_ANDROID) |
203 { "apk", ALLOW_ON_USER_GESTURE }, | 203 { "apk", ALLOW_ON_USER_GESTURE }, |
204 { "dex", ALLOW_ON_USER_GESTURE }, // Really an executable format. | 204 { "dex", ALLOW_ON_USER_GESTURE }, // Really an executable format. |
205 #endif | 205 #endif |
206 }; | 206 }; |
207 | 207 |
208 DownloadDangerLevel GetFileDangerLevel(const base::FilePath& path) { | 208 DownloadDangerLevel GetFileDangerLevel(const base::FilePath& path) { |
209 base::FilePath::StringType extension(path.FinalExtension()); | 209 base::FilePath::StringType extension(path.FinalExtension()); |
210 if (extension.empty()) | 210 if (extension.empty()) |
211 return NOT_DANGEROUS; | 211 return NOT_DANGEROUS; |
212 if (!IsStringASCII(extension)) | 212 if (!base::IsStringASCII(extension)) |
213 return NOT_DANGEROUS; | 213 return NOT_DANGEROUS; |
214 #if defined(OS_WIN) | 214 #if defined(OS_WIN) |
215 std::string ascii_extension = base::UTF16ToASCII(extension); | 215 std::string ascii_extension = base::UTF16ToASCII(extension); |
216 #elif defined(OS_POSIX) | 216 #elif defined(OS_POSIX) |
217 std::string ascii_extension = extension; | 217 std::string ascii_extension = extension; |
218 #endif | 218 #endif |
219 | 219 |
220 // Strip out leading dot if it's still there | 220 // Strip out leading dot if it's still there |
221 if (ascii_extension[0] == base::FilePath::kExtensionSeparator) | 221 if (ascii_extension[0] == base::FilePath::kExtensionSeparator) |
222 ascii_extension.erase(0, 1); | 222 ascii_extension.erase(0, 1); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 for (size_t i = 0; i < arraysize(kExecutableBlackList); ++i) { | 256 for (size_t i = 0; i < arraysize(kExecutableBlackList); ++i) { |
257 if (net::MatchesMimeType(kExecutableBlackList[i], mime_type)) | 257 if (net::MatchesMimeType(kExecutableBlackList[i], mime_type)) |
258 return false; | 258 return false; |
259 } | 259 } |
260 // We consider only other application types to be executable. | 260 // We consider only other application types to be executable. |
261 return net::MatchesMimeType("application/*", mime_type); | 261 return net::MatchesMimeType("application/*", mime_type); |
262 } | 262 } |
263 | 263 |
264 | 264 |
265 } // namespace download_util | 265 } // namespace download_util |
OLD | NEW |