OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "net/base/filename_util.h" | 5 #include "net/base/filename_util.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 // with the preferred extension for the MIME type if one is available. | 195 // with the preferred extension for the MIME type if one is available. |
196 if (IsShellIntegratedExtension(extension)) | 196 if (IsShellIntegratedExtension(extension)) |
197 extension.assign(default_extension); | 197 extension.assign(default_extension); |
198 #endif | 198 #endif |
199 | 199 |
200 *file_name = file_name->ReplaceExtension(extension); | 200 *file_name = file_name->ReplaceExtension(extension); |
201 } | 201 } |
202 | 202 |
203 bool FilePathToString16(const base::FilePath& path, base::string16* converted) { | 203 bool FilePathToString16(const base::FilePath& path, base::string16* converted) { |
204 #if defined(OS_WIN) | 204 #if defined(OS_WIN) |
205 return base::WideToUTF16( | 205 *converted = path.value(); |
206 path.value().c_str(), path.value().size(), converted); | 206 return true; |
207 #elif defined(OS_POSIX) | 207 #elif defined(OS_POSIX) |
208 std::string component8 = path.AsUTF8Unsafe(); | 208 std::string component8 = path.AsUTF8Unsafe(); |
209 return !component8.empty() && | 209 return !component8.empty() && |
210 base::UTF8ToUTF16(component8.c_str(), component8.size(), converted); | 210 base::UTF8ToUTF16(component8.c_str(), component8.size(), converted); |
211 #endif | 211 #endif |
212 } | 212 } |
213 | 213 |
214 base::string16 GetSuggestedFilenameImpl( | 214 base::string16 GetSuggestedFilenameImpl( |
215 const GURL& url, | 215 const GURL& url, |
216 const std::string& content_disposition, | 216 const std::string& content_disposition, |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 base::FilePath generated_name( | 318 base::FilePath generated_name( |
319 base::SysWideToNativeMB(base::UTF16ToWide(file_name))); | 319 base::SysWideToNativeMB(base::UTF16ToWide(file_name))); |
320 #endif | 320 #endif |
321 | 321 |
322 DCHECK(!generated_name.empty()); | 322 DCHECK(!generated_name.empty()); |
323 | 323 |
324 return generated_name; | 324 return generated_name; |
325 } | 325 } |
326 | 326 |
327 } // namespace net | 327 } // namespace net |
OLD | NEW |