| 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 10 matching lines...) Expand all Loading... |
| 21 #include "content/browser/web_contents/web_drag_source_win.h" | 21 #include "content/browser/web_contents/web_drag_source_win.h" |
| 22 #include "content/browser/web_contents/web_drag_utils_win.h" | 22 #include "content/browser/web_contents/web_drag_utils_win.h" |
| 23 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
| 24 #include "content/public/browser/content_browser_client.h" | 24 #include "content/public/browser/content_browser_client.h" |
| 25 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
| 26 #include "content/public/browser/web_drag_dest_delegate.h" | 26 #include "content/public/browser/web_drag_dest_delegate.h" |
| 27 #include "net/base/net_util.h" | 27 #include "net/base/net_util.h" |
| 28 #include "ui/base/clipboard/clipboard_util_win.h" | 28 #include "ui/base/clipboard/clipboard_util_win.h" |
| 29 #include "ui/base/clipboard/custom_data_helper.h" | 29 #include "ui/base/clipboard/custom_data_helper.h" |
| 30 #include "ui/base/dragdrop/drag_utils.h" | 30 #include "ui/base/dragdrop/drag_utils.h" |
| 31 #include "ui/base/layout.h" |
| 31 #include "ui/gfx/image/image_skia.h" | 32 #include "ui/gfx/image/image_skia.h" |
| 33 #include "ui/gfx/screen.h" |
| 32 #include "ui/gfx/size.h" | 34 #include "ui/gfx/size.h" |
| 33 #include "webkit/glue/webdropdata.h" | 35 #include "webkit/glue/webdropdata.h" |
| 34 | 36 |
| 35 using content::BrowserThread; | 37 using content::BrowserThread; |
| 36 using WebKit::WebDragOperationsMask; | 38 using WebKit::WebDragOperationsMask; |
| 37 using WebKit::WebDragOperationCopy; | 39 using WebKit::WebDragOperationCopy; |
| 38 using WebKit::WebDragOperationLink; | 40 using WebKit::WebDragOperationLink; |
| 39 using WebKit::WebDragOperationMove; | 41 using WebKit::WebDragOperationMove; |
| 40 | 42 |
| 41 namespace { | 43 namespace { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 // We do not want to drag and drop the download to itself. | 143 // We do not want to drag and drop the download to itself. |
| 142 old_drop_target_suspended_state_ = drag_dest_->suspended(); | 144 old_drop_target_suspended_state_ = drag_dest_->suspended(); |
| 143 drag_dest_->set_suspended(true); | 145 drag_dest_->set_suspended(true); |
| 144 | 146 |
| 145 // Start a background thread to do the drag-and-drop. | 147 // Start a background thread to do the drag-and-drop. |
| 146 DCHECK(!drag_drop_thread_.get()); | 148 DCHECK(!drag_drop_thread_.get()); |
| 147 drag_drop_thread_.reset(new DragDropThread(this)); | 149 drag_drop_thread_.reset(new DragDropThread(this)); |
| 148 base::Thread::Options options; | 150 base::Thread::Options options; |
| 149 options.message_loop_type = MessageLoop::TYPE_UI; | 151 options.message_loop_type = MessageLoop::TYPE_UI; |
| 150 if (drag_drop_thread_->StartWithOptions(options)) { | 152 if (drag_drop_thread_->StartWithOptions(options)) { |
| 153 gfx::Display display = |
| 154 gfx::Screen::GetDisplayNearestWindow(web_contents_->GetNativeView()); |
| 155 ui::ScaleFactor scale_factor = ui::GetScaleFactorFromScale( |
| 156 display.device_scale_factor()); |
| 151 drag_drop_thread_->message_loop()->PostTask( | 157 drag_drop_thread_->message_loop()->PostTask( |
| 152 FROM_HERE, | 158 FROM_HERE, |
| 153 base::Bind(&WebContentsDragWin::StartBackgroundDragging, this, | 159 base::Bind(&WebContentsDragWin::StartBackgroundDragging, this, |
| 154 drop_data, ops, page_url, page_encoding, image, | 160 drop_data, ops, page_url, page_encoding, |
| 161 image.GetRepresentation(scale_factor).sk_bitmap(), |
| 155 image_offset)); | 162 image_offset)); |
| 156 } | 163 } |
| 157 | 164 |
| 158 // Install a hook procedure to monitor the messages so that we can forward | 165 // Install a hook procedure to monitor the messages so that we can forward |
| 159 // the appropriate ones to the background thread. | 166 // the appropriate ones to the background thread. |
| 160 drag_out_thread_id = drag_drop_thread_->thread_id(); | 167 drag_out_thread_id = drag_drop_thread_->thread_id(); |
| 161 mouse_up_received = false; | 168 mouse_up_received = false; |
| 162 DCHECK(!msg_hook); | 169 DCHECK(!msg_hook); |
| 163 msg_hook = SetWindowsHookEx(WH_MSGFILTER, | 170 msg_hook = SetWindowsHookEx(WH_MSGFILTER, |
| 164 MsgFilterProc, | 171 MsgFilterProc, |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 void WebContentsDragWin::OnDataObjectDisposed() { | 373 void WebContentsDragWin::OnDataObjectDisposed() { |
| 367 DCHECK(drag_drop_thread_id_ == base::PlatformThread::CurrentId()); | 374 DCHECK(drag_drop_thread_id_ == base::PlatformThread::CurrentId()); |
| 368 | 375 |
| 369 // The drag-and-drop thread is only closed after OLE is done with | 376 // The drag-and-drop thread is only closed after OLE is done with |
| 370 // DataObjectImpl. | 377 // DataObjectImpl. |
| 371 BrowserThread::PostTask( | 378 BrowserThread::PostTask( |
| 372 BrowserThread::UI, | 379 BrowserThread::UI, |
| 373 FROM_HERE, | 380 FROM_HERE, |
| 374 base::Bind(&WebContentsDragWin::CloseThread, this)); | 381 base::Bind(&WebContentsDragWin::CloseThread, this)); |
| 375 } | 382 } |
| OLD | NEW |