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/web_contents/web_contents_drag_win.h" | 5 #include "content/browser/web_contents/web_contents_drag_win.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 base::Bind(&DisableBackgroundDraggingSupport)); | 220 base::Bind(&DisableBackgroundDraggingSupport)); |
221 } | 221 } |
222 } | 222 } |
223 | 223 |
224 void WebContentsDragWin::PrepareDragForDownload( | 224 void WebContentsDragWin::PrepareDragForDownload( |
225 const DropData& drop_data, | 225 const DropData& drop_data, |
226 ui::OSExchangeData* data, | 226 ui::OSExchangeData* data, |
227 const GURL& page_url, | 227 const GURL& page_url, |
228 const std::string& page_encoding) { | 228 const std::string& page_encoding) { |
229 // Parse the download metadata. | 229 // Parse the download metadata. |
230 string16 mime_type; | 230 base::string16 mime_type; |
231 base::FilePath file_name; | 231 base::FilePath file_name; |
232 GURL download_url; | 232 GURL download_url; |
233 if (!ParseDownloadMetadata(drop_data.download_metadata, | 233 if (!ParseDownloadMetadata(drop_data.download_metadata, |
234 &mime_type, | 234 &mime_type, |
235 &file_name, | 235 &file_name, |
236 &download_url)) | 236 &download_url)) |
237 return; | 237 return; |
238 | 238 |
239 // Generate the file name based on both mime type and proposed file name. | 239 // Generate the file name based on both mime type and proposed file name. |
240 std::string default_name = | 240 std::string default_name = |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 } | 277 } |
278 | 278 |
279 void WebContentsDragWin::PrepareDragForFileContents( | 279 void WebContentsDragWin::PrepareDragForFileContents( |
280 const DropData& drop_data, ui::OSExchangeData* data) { | 280 const DropData& drop_data, ui::OSExchangeData* data) { |
281 static const int kMaxFilenameLength = 255; // FAT and NTFS | 281 static const int kMaxFilenameLength = 255; // FAT and NTFS |
282 base::FilePath file_name(drop_data.file_description_filename); | 282 base::FilePath file_name(drop_data.file_description_filename); |
283 | 283 |
284 // Images without ALT text will only have a file extension so we need to | 284 // Images without ALT text will only have a file extension so we need to |
285 // synthesize one from the provided extension and URL. | 285 // synthesize one from the provided extension and URL. |
286 if (file_name.BaseName().RemoveExtension().empty()) { | 286 if (file_name.BaseName().RemoveExtension().empty()) { |
287 const string16 extension = file_name.Extension(); | 287 const base::string16 extension = file_name.Extension(); |
288 // Retrieve the name from the URL. | 288 // Retrieve the name from the URL. |
289 file_name = base::FilePath( | 289 file_name = base::FilePath( |
290 net::GetSuggestedFilename(drop_data.url, "", "", "", "", "")); | 290 net::GetSuggestedFilename(drop_data.url, "", "", "", "", "")); |
291 if (file_name.value().size() + extension.size() > kMaxFilenameLength) { | 291 if (file_name.value().size() + extension.size() > kMaxFilenameLength) { |
292 file_name = base::FilePath(file_name.value().substr( | 292 file_name = base::FilePath(file_name.value().substr( |
293 0, kMaxFilenameLength - extension.size())); | 293 0, kMaxFilenameLength - extension.size())); |
294 } | 294 } |
295 file_name = file_name.ReplaceExtension(extension); | 295 file_name = file_name.ReplaceExtension(extension); |
296 } | 296 } |
297 data->SetFileContents(file_name, drop_data.file_contents); | 297 data->SetFileContents(file_name, drop_data.file_contents); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 FROM_HERE, | 434 FROM_HERE, |
435 base::Bind(&WebContentsDragWin::CloseThread, this)); | 435 base::Bind(&WebContentsDragWin::CloseThread, this)); |
436 } | 436 } |
437 | 437 |
438 // static | 438 // static |
439 void WebContentsDragWin::DisableDragDropForTesting() { | 439 void WebContentsDragWin::DisableDragDropForTesting() { |
440 run_do_drag_drop = false; | 440 run_do_drag_drop = false; |
441 } | 441 } |
442 | 442 |
443 } // namespace content | 443 } // namespace content |
OLD | NEW |