| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/views/tab_contents/tab_contents_drag_win.h" | 5 #include "chrome/browser/views/tab_contents/tab_contents_drag_win.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
| 12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 13 #include "base/task.h" | 13 #include "base/task.h" |
| 14 #include "base/thread.h" | 14 #include "base/thread.h" |
| 15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
| 16 #include "base/win_util.h" | 16 #include "base/win_util.h" |
| 17 #include "chrome/browser/bookmarks/bookmark_drag_data.h" | 17 #include "chrome/browser/bookmarks/bookmark_drag_data.h" |
| 18 #include "chrome/browser/chrome_thread.h" | 18 #include "chrome/browser/chrome_thread.h" |
| 19 #include "chrome/browser/download/download_util.h" |
| 19 #include "chrome/browser/download/drag_download_file.h" | 20 #include "chrome/browser/download/drag_download_file.h" |
| 20 #include "chrome/browser/download/drag_download_util.h" | 21 #include "chrome/browser/download/drag_download_util.h" |
| 21 #include "chrome/browser/profile.h" | 22 #include "chrome/browser/profile.h" |
| 22 #include "chrome/browser/tab_contents/tab_contents.h" | 23 #include "chrome/browser/tab_contents/tab_contents.h" |
| 23 #include "chrome/browser/tab_contents/web_drag_source_win.h" | 24 #include "chrome/browser/tab_contents/web_drag_source_win.h" |
| 24 #include "chrome/browser/tab_contents/web_drag_utils_win.h" | 25 #include "chrome/browser/tab_contents/web_drag_utils_win.h" |
| 25 #include "chrome/browser/tab_contents/web_drop_target_win.h" | 26 #include "chrome/browser/tab_contents/web_drop_target_win.h" |
| 26 #include "chrome/browser/views/tab_contents/tab_contents_view_win.h" | 27 #include "chrome/browser/views/tab_contents/tab_contents_view_win.h" |
| 27 #include "chrome/common/url_constants.h" | 28 #include "chrome/common/url_constants.h" |
| 28 #include "net/base/net_util.h" | 29 #include "net/base/net_util.h" |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 if (!drag_download_util::ParseDownloadMetadata(drop_data.download_metadata, | 193 if (!drag_download_util::ParseDownloadMetadata(drop_data.download_metadata, |
| 193 &mime_type, | 194 &mime_type, |
| 194 &file_name, | 195 &file_name, |
| 195 &download_url)) | 196 &download_url)) |
| 196 return; | 197 return; |
| 197 | 198 |
| 198 // Generate the download filename. | 199 // Generate the download filename. |
| 199 std::string content_disposition = | 200 std::string content_disposition = |
| 200 "attachment; filename=" + UTF16ToUTF8(file_name.value()); | 201 "attachment; filename=" + UTF16ToUTF8(file_name.value()); |
| 201 FilePath generated_file_name; | 202 FilePath generated_file_name; |
| 202 DownloadManager::GenerateFileName(download_url, | 203 download_util::GenerateFileName(download_url, |
| 203 content_disposition, | 204 content_disposition, |
| 204 std::string(), | 205 std::string(), |
| 205 UTF16ToUTF8(mime_type), | 206 UTF16ToUTF8(mime_type), |
| 206 &generated_file_name); | 207 &generated_file_name); |
| 207 | 208 |
| 208 // Provide the data as file (CF_HDROP). A temporary download file with the | 209 // Provide the data as file (CF_HDROP). A temporary download file with the |
| 209 // Zone.Identifier ADS (Alternate Data Stream) attached will be created. | 210 // Zone.Identifier ADS (Alternate Data Stream) attached will be created. |
| 210 linked_ptr<net::FileStream> empty_file_stream; | 211 linked_ptr<net::FileStream> empty_file_stream; |
| 211 scoped_refptr<DragDownloadFile> download_file = | 212 scoped_refptr<DragDownloadFile> download_file = |
| 212 new DragDownloadFile(generated_file_name, | 213 new DragDownloadFile(generated_file_name, |
| 213 empty_file_stream, | 214 empty_file_stream, |
| 214 download_url, | 215 download_url, |
| 215 page_url, | 216 page_url, |
| 216 page_encoding, | 217 page_encoding, |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 | 357 |
| 357 void TabContentsDragWin::OnDataObjectDisposed() { | 358 void TabContentsDragWin::OnDataObjectDisposed() { |
| 358 DCHECK(drag_drop_thread_id_ == PlatformThread::CurrentId()); | 359 DCHECK(drag_drop_thread_id_ == PlatformThread::CurrentId()); |
| 359 | 360 |
| 360 // The drag-and-drop thread is only closed after OLE is done with | 361 // The drag-and-drop thread is only closed after OLE is done with |
| 361 // DataObjectImpl. | 362 // DataObjectImpl. |
| 362 ChromeThread::PostTask( | 363 ChromeThread::PostTask( |
| 363 ChromeThread::UI, FROM_HERE, | 364 ChromeThread::UI, FROM_HERE, |
| 364 NewRunnableMethod(this, &TabContentsDragWin::CloseThread)); | 365 NewRunnableMethod(this, &TabContentsDragWin::CloseThread)); |
| 365 } | 366 } |
| OLD | NEW |