Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(323)

Side by Side Diff: chrome/browser/ui/views/tab_contents/tab_contents_drag_win.cc

Issue 8380021: Make all drag sources not depend on download_util. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: header path Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/cocoa/tab_contents/web_drag_source.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "chrome/browser/ui/views/tab_contents/tab_contents_drag_win.h" 5 #include "chrome/browser/ui/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/bind.h" 11 #include "base/bind.h"
12 #include "base/file_path.h" 12 #include "base/file_path.h"
13 #include "base/message_loop.h" 13 #include "base/message_loop.h"
14 #include "base/task.h" 14 #include "base/task.h"
15 #include "base/threading/platform_thread.h" 15 #include "base/threading/platform_thread.h"
16 #include "base/threading/thread.h" 16 #include "base/threading/thread.h"
17 #include "base/utf_string_conversions.h" 17 #include "base/utf_string_conversions.h"
18 #include "chrome/browser/bookmarks/bookmark_node_data.h" 18 #include "chrome/browser/bookmarks/bookmark_node_data.h"
19 #include "chrome/browser/download/download_util.h"
20 #include "chrome/browser/tab_contents/web_drag_source_win.h" 19 #include "chrome/browser/tab_contents/web_drag_source_win.h"
21 #include "chrome/browser/tab_contents/web_drag_utils_win.h" 20 #include "chrome/browser/tab_contents/web_drag_utils_win.h"
22 #include "chrome/browser/tab_contents/web_drop_target_win.h" 21 #include "chrome/browser/tab_contents/web_drop_target_win.h"
23 #include "chrome/browser/ui/views/tab_contents/native_tab_contents_view_win.h" 22 #include "chrome/browser/ui/views/tab_contents/native_tab_contents_view_win.h"
24 #include "chrome/common/url_constants.h" 23 #include "chrome/common/url_constants.h"
25 #include "content/browser/browser_thread.h" 24 #include "content/browser/browser_thread.h"
26 #include "content/browser/download/drag_download_file.h" 25 #include "content/browser/download/drag_download_file.h"
27 #include "content/browser/download/drag_download_util.h" 26 #include "content/browser/download/drag_download_util.h"
28 #include "content/browser/tab_contents/tab_contents.h" 27 #include "content/browser/tab_contents/tab_contents.h"
28 #include "content/public/browser/content_browser_client.h"
29 #include "net/base/net_util.h" 29 #include "net/base/net_util.h"
30 #include "views/drag_utils.h" 30 #include "views/drag_utils.h"
31 #include "webkit/glue/webdropdata.h" 31 #include "webkit/glue/webdropdata.h"
32 32
33 using WebKit::WebDragOperationsMask; 33 using WebKit::WebDragOperationsMask;
34 using WebKit::WebDragOperationCopy; 34 using WebKit::WebDragOperationCopy;
35 using WebKit::WebDragOperationLink; 35 using WebKit::WebDragOperationLink;
36 using WebKit::WebDragOperationMove; 36 using WebKit::WebDragOperationMove;
37 37
38 namespace { 38 namespace {
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 // Parse the download metadata. 190 // Parse the download metadata.
191 string16 mime_type; 191 string16 mime_type;
192 FilePath file_name; 192 FilePath file_name;
193 GURL download_url; 193 GURL download_url;
194 if (!drag_download_util::ParseDownloadMetadata(drop_data.download_metadata, 194 if (!drag_download_util::ParseDownloadMetadata(drop_data.download_metadata,
195 &mime_type, 195 &mime_type,
196 &file_name, 196 &file_name,
197 &download_url)) 197 &download_url))
198 return; 198 return;
199 199
200 // Generate the download filename. 200 // Generate the file name based on both mime type and proposed file name.
201 FilePath generated_file_name; 201 std::string default_name =
202 download_util::GenerateFileNameFromSuggestedName( 202 content::GetContentClient()->browser()->GetDefaultDownloadName();
203 download_url, 203 FilePath generated_download_file_name =
204 UTF16ToUTF8(file_name.value()), 204 net::GenerateFileName(download_url,
205 UTF16ToUTF8(mime_type), 205 std::string(),
206 &generated_file_name); 206 std::string(),
207 UTF16ToUTF8(file_name.value()),
208 UTF16ToUTF8(mime_type),
209 default_name);
207 210
208 // Provide the data as file (CF_HDROP). A temporary download file with the 211 // Provide the data as file (CF_HDROP). A temporary download file with the
209 // Zone.Identifier ADS (Alternate Data Stream) attached will be created. 212 // Zone.Identifier ADS (Alternate Data Stream) attached will be created.
210 linked_ptr<net::FileStream> empty_file_stream; 213 linked_ptr<net::FileStream> empty_file_stream;
211 scoped_refptr<DragDownloadFile> download_file = 214 scoped_refptr<DragDownloadFile> download_file =
212 new DragDownloadFile(generated_file_name, 215 new DragDownloadFile(generated_download_file_name,
213 empty_file_stream, 216 empty_file_stream,
214 download_url, 217 download_url,
215 page_url, 218 page_url,
216 page_encoding, 219 page_encoding,
217 view_->GetTabContents()); 220 view_->GetTabContents());
218 ui::OSExchangeData::DownloadFileInfo file_download(FilePath(), 221 ui::OSExchangeData::DownloadFileInfo file_download(FilePath(),
219 download_file.get()); 222 download_file.get());
220 data->SetDownloadFileInfo(file_download); 223 data->SetDownloadFileInfo(file_download);
221 224
222 // Enable asynchronous operation. 225 // Enable asynchronous operation.
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 void TabContentsDragWin::OnDataObjectDisposed() { 365 void TabContentsDragWin::OnDataObjectDisposed() {
363 DCHECK(drag_drop_thread_id_ == base::PlatformThread::CurrentId()); 366 DCHECK(drag_drop_thread_id_ == base::PlatformThread::CurrentId());
364 367
365 // The drag-and-drop thread is only closed after OLE is done with 368 // The drag-and-drop thread is only closed after OLE is done with
366 // DataObjectImpl. 369 // DataObjectImpl.
367 BrowserThread::PostTask( 370 BrowserThread::PostTask(
368 BrowserThread::UI, 371 BrowserThread::UI,
369 FROM_HERE, 372 FROM_HERE,
370 base::Bind(&TabContentsDragWin::CloseThread, this)); 373 base::Bind(&TabContentsDragWin::CloseThread, this));
371 } 374 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/tab_contents/web_drag_source.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698