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 "content/browser/download/drag_download_util.h" | 5 #include "content/browser/download/drag_download_util.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 return false; | 42 return false; |
43 | 43 |
44 if (mime_type) | 44 if (mime_type) |
45 *mime_type = metadata.substr(0, mime_type_end_pos); | 45 *mime_type = metadata.substr(0, mime_type_end_pos); |
46 if (file_name) { | 46 if (file_name) { |
47 base::string16 file_name_str = metadata.substr( | 47 base::string16 file_name_str = metadata.substr( |
48 mime_type_end_pos + 1, file_name_end_pos - mime_type_end_pos - 1); | 48 mime_type_end_pos + 1, file_name_end_pos - mime_type_end_pos - 1); |
49 #if defined(OS_WIN) | 49 #if defined(OS_WIN) |
50 *file_name = base::FilePath(file_name_str); | 50 *file_name = base::FilePath(file_name_str); |
51 #else | 51 #else |
52 *file_name = base::FilePath(UTF16ToUTF8(file_name_str)); | 52 *file_name = base::FilePath(base::UTF16ToUTF8(file_name_str)); |
53 #endif | 53 #endif |
54 } | 54 } |
55 if (url) | 55 if (url) |
56 *url = parsed_url; | 56 *url = parsed_url; |
57 | 57 |
58 return true; | 58 return true; |
59 } | 59 } |
60 | 60 |
61 FileStream* CreateFileStreamForDrop(base::FilePath* file_path, | 61 FileStream* CreateFileStreamForDrop(base::FilePath* file_path, |
62 net::NetLog* net_log) { | 62 net::NetLog* net_log) { |
63 DCHECK(file_path && !file_path->empty()); | 63 DCHECK(file_path && !file_path->empty()); |
64 | 64 |
65 scoped_ptr<FileStream> file_stream(new FileStream(net_log)); | 65 scoped_ptr<FileStream> file_stream(new FileStream(net_log)); |
66 const int kMaxSeq = 99; | 66 const int kMaxSeq = 99; |
67 for (int seq = 0; seq <= kMaxSeq; seq++) { | 67 for (int seq = 0; seq <= kMaxSeq; seq++) { |
68 base::FilePath new_file_path; | 68 base::FilePath new_file_path; |
69 if (seq == 0) { | 69 if (seq == 0) { |
70 new_file_path = *file_path; | 70 new_file_path = *file_path; |
71 } else { | 71 } else { |
72 #if defined(OS_WIN) | 72 #if defined(OS_WIN) |
73 base::string16 suffix = ASCIIToUTF16("-") + base::IntToString16(seq); | 73 base::string16 suffix = |
| 74 base::ASCIIToUTF16("-") + base::IntToString16(seq); |
74 #else | 75 #else |
75 std::string suffix = std::string("-") + base::IntToString(seq); | 76 std::string suffix = std::string("-") + base::IntToString(seq); |
76 #endif | 77 #endif |
77 new_file_path = file_path->InsertBeforeExtension(suffix); | 78 new_file_path = file_path->InsertBeforeExtension(suffix); |
78 } | 79 } |
79 | 80 |
80 // http://crbug.com/110709 | 81 // http://crbug.com/110709 |
81 base::ThreadRestrictions::ScopedAllowIO allow_io; | 82 base::ThreadRestrictions::ScopedAllowIO allow_io; |
82 | 83 |
83 // Explicitly (and redundantly check) for file -- despite the fact that our | 84 // Explicitly (and redundantly check) for file -- despite the fact that our |
(...skipping 28 matching lines...) Expand all Loading... |
112 } | 113 } |
113 | 114 |
114 PromiseFileFinalizer::~PromiseFileFinalizer() {} | 115 PromiseFileFinalizer::~PromiseFileFinalizer() {} |
115 | 116 |
116 void PromiseFileFinalizer::Cleanup() { | 117 void PromiseFileFinalizer::Cleanup() { |
117 if (drag_file_downloader_.get()) | 118 if (drag_file_downloader_.get()) |
118 drag_file_downloader_ = NULL; | 119 drag_file_downloader_ = NULL; |
119 } | 120 } |
120 | 121 |
121 } // namespace content | 122 } // namespace content |
OLD | NEW |