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

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

Issue 9562049: Move the core drag&drop code for Windows to content\browser to match Mac/GTK. I've had to add tempo… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 9 months 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
OLDNEW
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 "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/pickle.h" 14 #include "base/pickle.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/tab_contents/web_drag_source_win.h"
20 #include "chrome/browser/tab_contents/web_drag_utils_win.h"
21 #include "chrome/browser/tab_contents/web_drop_target_win.h"
22 #include "chrome/browser/ui/views/tab_contents/native_tab_contents_view_win.h" 19 #include "chrome/browser/ui/views/tab_contents/native_tab_contents_view_win.h"
23 #include "chrome/common/url_constants.h" 20 #include "chrome/common/url_constants.h"
24 #include "content/browser/download/drag_download_file.h" 21 #include "content/browser/download/drag_download_file.h"
25 #include "content/browser/download/drag_download_util.h" 22 #include "content/browser/download/drag_download_util.h"
23 #include "content/browser/tab_contents/web_drag_dest_win.h"
24 #include "content/browser/tab_contents/web_drag_source_win.h"
25 #include "content/browser/tab_contents/web_drag_utils_win.h"
26 #include "content/public/browser/browser_thread.h" 26 #include "content/public/browser/browser_thread.h"
27 #include "content/public/browser/content_browser_client.h" 27 #include "content/public/browser/content_browser_client.h"
28 #include "content/public/browser/web_contents.h" 28 #include "content/public/browser/web_contents.h"
29 #include "net/base/net_util.h" 29 #include "net/base/net_util.h"
30 #include "ui/base/clipboard/clipboard_util_win.h" 30 #include "ui/base/clipboard/clipboard_util_win.h"
31 #include "ui/base/clipboard/custom_data_helper.h" 31 #include "ui/base/clipboard/custom_data_helper.h"
32 #include "ui/views/drag_utils.h" 32 #include "ui/views/drag_utils.h"
33 #include "webkit/glue/webdropdata.h" 33 #include "webkit/glue/webdropdata.h"
34 34
35 using content::BrowserThread; 35 using content::BrowserThread;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 const std::string& page_encoding = view_->GetWebContents()->GetEncoding(); 126 const std::string& page_encoding = view_->GetWebContents()->GetEncoding();
127 127
128 // If it is not drag-out, do the drag-and-drop in the current UI thread. 128 // If it is not drag-out, do the drag-and-drop in the current UI thread.
129 if (drop_data.download_metadata.empty()) { 129 if (drop_data.download_metadata.empty()) {
130 DoDragging(drop_data, ops, page_url, page_encoding, image, image_offset); 130 DoDragging(drop_data, ops, page_url, page_encoding, image, image_offset);
131 EndDragging(false); 131 EndDragging(false);
132 return; 132 return;
133 } 133 }
134 134
135 // We do not want to drag and drop the download to itself. 135 // We do not want to drag and drop the download to itself.
136 old_drop_target_suspended_state_ = view_->drop_target()->suspended(); 136 old_drop_target_suspended_state_ = view_->drag_dest()->suspended();
137 view_->drop_target()->set_suspended(true); 137 view_->drag_dest()->set_suspended(true);
138 138
139 // Start a background thread to do the drag-and-drop. 139 // Start a background thread to do the drag-and-drop.
140 DCHECK(!drag_drop_thread_.get()); 140 DCHECK(!drag_drop_thread_.get());
141 drag_drop_thread_.reset(new DragDropThread(this)); 141 drag_drop_thread_.reset(new DragDropThread(this));
142 base::Thread::Options options; 142 base::Thread::Options options;
143 options.message_loop_type = MessageLoop::TYPE_UI; 143 options.message_loop_type = MessageLoop::TYPE_UI;
144 if (drag_drop_thread_->StartWithOptions(options)) { 144 if (drag_drop_thread_->StartWithOptions(options)) {
145 drag_drop_thread_->message_loop()->PostTask( 145 drag_drop_thread_->message_loop()->PostTask(
146 FROM_HERE, 146 FROM_HERE,
147 base::Bind(&TabContentsDragWin::StartBackgroundDragging, this, 147 base::Bind(&TabContentsDragWin::StartBackgroundDragging, this,
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 } 327 }
328 328
329 void TabContentsDragWin::EndDragging(bool restore_suspended_state) { 329 void TabContentsDragWin::EndDragging(bool restore_suspended_state) {
330 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 330 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
331 331
332 if (drag_ended_) 332 if (drag_ended_)
333 return; 333 return;
334 drag_ended_ = true; 334 drag_ended_ = true;
335 335
336 if (restore_suspended_state) 336 if (restore_suspended_state)
337 view_->drop_target()->set_suspended(old_drop_target_suspended_state_); 337 view_->drag_dest()->set_suspended(old_drop_target_suspended_state_);
338 338
339 if (msg_hook) { 339 if (msg_hook) {
340 AttachThreadInput(drag_out_thread_id, GetCurrentThreadId(), FALSE); 340 AttachThreadInput(drag_out_thread_id, GetCurrentThreadId(), FALSE);
341 UnhookWindowsHookEx(msg_hook); 341 UnhookWindowsHookEx(msg_hook);
342 msg_hook = NULL; 342 msg_hook = NULL;
343 } 343 }
344 344
345 view_->EndDragging(); 345 view_->EndDragging();
346 } 346 }
347 347
(...skipping 24 matching lines...) Expand all
372 void TabContentsDragWin::OnDataObjectDisposed() { 372 void TabContentsDragWin::OnDataObjectDisposed() {
373 DCHECK(drag_drop_thread_id_ == base::PlatformThread::CurrentId()); 373 DCHECK(drag_drop_thread_id_ == base::PlatformThread::CurrentId());
374 374
375 // The drag-and-drop thread is only closed after OLE is done with 375 // The drag-and-drop thread is only closed after OLE is done with
376 // DataObjectImpl. 376 // DataObjectImpl.
377 BrowserThread::PostTask( 377 BrowserThread::PostTask(
378 BrowserThread::UI, 378 BrowserThread::UI,
379 FROM_HERE, 379 FROM_HERE,
380 base::Bind(&TabContentsDragWin::CloseThread, this)); 380 base::Bind(&TabContentsDragWin::CloseThread, this));
381 } 381 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/tab_contents/native_tab_contents_view_win.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698