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

Side by Side Diff: chrome/browser/download/download_extensions.cc

Issue 176843022: Move UTF16ToASCII, remove WideToASCII. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 #include "base/strings/utf_string_conversions.h"
11 #include "net/base/mime_util.h" 12 #include "net/base/mime_util.h"
12 #include "net/base/net_util.h" 13 #include "net/base/net_util.h"
13 14
14 namespace download_util { 15 namespace download_util {
15 16
16 // For file extensions taken from mozilla: 17 // For file extensions taken from mozilla:
17 18
18 /* ***** BEGIN LICENSE BLOCK ***** 19 /* ***** BEGIN LICENSE BLOCK *****
19 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 20 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20 * 21 *
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 #endif 205 #endif
205 }; 206 };
206 207
207 DownloadDangerLevel GetFileDangerLevel(const base::FilePath& path) { 208 DownloadDangerLevel GetFileDangerLevel(const base::FilePath& path) {
208 base::FilePath::StringType extension(path.FinalExtension()); 209 base::FilePath::StringType extension(path.FinalExtension());
209 if (extension.empty()) 210 if (extension.empty())
210 return NOT_DANGEROUS; 211 return NOT_DANGEROUS;
211 if (!IsStringASCII(extension)) 212 if (!IsStringASCII(extension))
212 return NOT_DANGEROUS; 213 return NOT_DANGEROUS;
213 #if defined(OS_WIN) 214 #if defined(OS_WIN)
214 std::string ascii_extension = WideToASCII(extension); 215 std::string ascii_extension = base::UTF16ToASCII(extension);
215 #elif defined(OS_POSIX) 216 #elif defined(OS_POSIX)
216 std::string ascii_extension = extension; 217 std::string ascii_extension = extension;
217 #endif 218 #endif
218 219
219 // Strip out leading dot if it's still there 220 // Strip out leading dot if it's still there
220 if (ascii_extension[0] == base::FilePath::kExtensionSeparator) 221 if (ascii_extension[0] == base::FilePath::kExtensionSeparator)
221 ascii_extension.erase(0, 1); 222 ascii_extension.erase(0, 1);
222 223
223 for (size_t i = 0; i < arraysize(g_executables); ++i) { 224 for (size_t i = 0; i < arraysize(g_executables); ++i) {
224 if (LowerCaseEqualsASCII(ascii_extension, g_executables[i].extension)) 225 if (LowerCaseEqualsASCII(ascii_extension, g_executables[i].extension))
(...skipping 30 matching lines...) Expand all
255 for (size_t i = 0; i < arraysize(kExecutableBlackList); ++i) { 256 for (size_t i = 0; i < arraysize(kExecutableBlackList); ++i) {
256 if (net::MatchesMimeType(kExecutableBlackList[i], mime_type)) 257 if (net::MatchesMimeType(kExecutableBlackList[i], mime_type))
257 return false; 258 return false;
258 } 259 }
259 // We consider only other application types to be executable. 260 // We consider only other application types to be executable.
260 return net::MatchesMimeType("application/*", mime_type); 261 return net::MatchesMimeType("application/*", mime_type);
261 } 262 }
262 263
263 264
264 } // namespace download_util 265 } // namespace download_util
OLDNEW
« no previous file with comments | « chrome/browser/devtools/adb/android_usb_device.cc ('k') | chrome/browser/enumerate_modules_model_unittest_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698