OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Download utility implementation | 5 // Download utility implementation |
6 | 6 |
7 #include "chrome/browser/download/download_util.h" | 7 #include "chrome/browser/download/download_util.h" |
8 | 8 |
9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
10 #include <shobjidl.h> | 10 #include <shobjidl.h> |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 // The GetPreferredExtensionForMimeType call will end up going to disk. Do | 281 // The GetPreferredExtensionForMimeType call will end up going to disk. Do |
282 // this on another thread to avoid slowing the IO thread. | 282 // this on another thread to avoid slowing the IO thread. |
283 // http://crbug.com/61827 | 283 // http://crbug.com/61827 |
284 base::ThreadRestrictions::ScopedAllowIO allow_io; | 284 base::ThreadRestrictions::ScopedAllowIO allow_io; |
285 net::GetPreferredExtensionForMimeType(mime_type, &extension); | 285 net::GetPreferredExtensionForMimeType(mime_type, &extension); |
286 } | 286 } |
287 | 287 |
288 generated_extension->swap(extension); | 288 generated_extension->swap(extension); |
289 } | 289 } |
290 | 290 |
291 void GenerateFileNameFromRequest(const GURL& url, | 291 void GenerateFileNameFromRequest(const DownloadItem& download_item, |
292 const std::string& content_disposition, | |
293 const std::string& referrer_charset, | |
294 const std::string& mime_type, | |
295 FilePath* generated_name) { | 292 FilePath* generated_name) { |
296 GenerateFileNameInternal(url, | 293 GenerateFileNameInternal(download_item.GetURL(), |
297 content_disposition, | 294 download_item.content_disposition(), |
298 referrer_charset, | 295 download_item.referrer_charset(), |
299 std::string(), | 296 download_item.suggested_filename(), |
300 mime_type, | 297 download_item.mime_type(), |
301 generated_name); | 298 generated_name); |
302 } | 299 } |
303 | 300 |
304 void GenerateFileNameFromSuggestedName(const GURL& url, | 301 void GenerateFileNameFromSuggestedName(const GURL& url, |
305 const std::string& suggested_name, | 302 const std::string& suggested_name, |
306 const std::string& mime_type, | 303 const std::string& mime_type, |
307 FilePath* generated_name) { | 304 FilePath* generated_name) { |
308 GenerateFileNameInternal(url, std::string(), std::string(), | 305 GenerateFileNameInternal(url, std::string(), std::string(), |
309 suggested_name, mime_type, generated_name); | 306 suggested_name, mime_type, generated_name); |
310 } | 307 } |
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
912 FilePath GetCrDownloadPath(const FilePath& suggested_path) { | 909 FilePath GetCrDownloadPath(const FilePath& suggested_path) { |
913 FilePath::StringType file_name; | 910 FilePath::StringType file_name; |
914 base::SStringPrintf( | 911 base::SStringPrintf( |
915 &file_name, | 912 &file_name, |
916 PRFilePathLiteral FILE_PATH_LITERAL(".crdownload"), | 913 PRFilePathLiteral FILE_PATH_LITERAL(".crdownload"), |
917 suggested_path.value().c_str()); | 914 suggested_path.value().c_str()); |
918 return FilePath(file_name); | 915 return FilePath(file_name); |
919 } | 916 } |
920 | 917 |
921 } // namespace download_util | 918 } // namespace download_util |
OLD | NEW |