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 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
14 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
15 #include "base/pickle.h" | 15 #include "base/pickle.h" |
16 #include "base/threading/platform_thread.h" | 16 #include "base/threading/platform_thread.h" |
17 #include "base/threading/thread.h" | 17 #include "base/threading/thread.h" |
18 #include "base/utf_string_conversions.h" | 18 #include "base/utf_string_conversions.h" |
19 #include "content/browser/download/drag_download_file.h" | 19 #include "content/browser/download/drag_download_file.h" |
20 #include "content/browser/download/drag_download_util.h" | 20 #include "content/browser/download/drag_download_util.h" |
21 #include "content/browser/web_contents/web_drag_dest_win.h" | 21 #include "content/browser/web_contents/web_drag_dest_win.h" |
22 #include "content/browser/web_contents/web_drag_source_win.h" | 22 #include "content/browser/web_contents/web_drag_source_win.h" |
23 #include "content/browser/web_contents/web_drag_utils_win.h" | 23 #include "content/browser/web_contents/web_drag_utils_win.h" |
24 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
25 #include "content/public/browser/content_browser_client.h" | 25 #include "content/public/browser/content_browser_client.h" |
26 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
| 27 #include "content/public/browser/web_contents_view.h" |
27 #include "content/public/browser/web_drag_dest_delegate.h" | 28 #include "content/public/browser/web_drag_dest_delegate.h" |
28 #include "net/base/net_util.h" | 29 #include "net/base/net_util.h" |
29 #include "third_party/skia/include/core/SkBitmap.h" | 30 #include "third_party/skia/include/core/SkBitmap.h" |
30 #include "ui/base/clipboard/clipboard_util_win.h" | 31 #include "ui/base/clipboard/clipboard_util_win.h" |
31 #include "ui/base/clipboard/custom_data_helper.h" | 32 #include "ui/base/clipboard/custom_data_helper.h" |
32 #include "ui/base/dragdrop/drag_utils.h" | 33 #include "ui/base/dragdrop/drag_utils.h" |
33 #include "ui/base/layout.h" | 34 #include "ui/base/layout.h" |
34 #include "ui/base/win/scoped_ole_initializer.h" | 35 #include "ui/base/win/scoped_ole_initializer.h" |
35 #include "ui/gfx/image/image_skia.h" | 36 #include "ui/gfx/image/image_skia.h" |
36 #include "ui/gfx/screen.h" | 37 #include "ui/gfx/screen.h" |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 | 342 |
342 // Set drag image. | 343 // Set drag image. |
343 if (!image.isNull()) { | 344 if (!image.isNull()) { |
344 drag_utils::SetDragImageOnDataObject(image, | 345 drag_utils::SetDragImageOnDataObject(image, |
345 gfx::Size(image.width(), image.height()), image_offset, &data); | 346 gfx::Size(image.width(), image.height()), image_offset, &data); |
346 } | 347 } |
347 | 348 |
348 // Use a local variable to keep track of the contents view window handle. | 349 // Use a local variable to keep track of the contents view window handle. |
349 // It might not be safe to access the instance after DoDragDrop returns | 350 // It might not be safe to access the instance after DoDragDrop returns |
350 // because the window could be disposed in the nested message loop. | 351 // because the window could be disposed in the nested message loop. |
351 HWND native_window = web_contents_->GetNativeView(); | 352 HWND native_window = web_contents_->GetView()->GetNativeView(); |
352 | 353 |
353 // We need to enable recursive tasks on the message loop so we can get | 354 // We need to enable recursive tasks on the message loop so we can get |
354 // updates while in the system DoDragDrop loop. | 355 // updates while in the system DoDragDrop loop. |
355 DWORD effect; | 356 DWORD effect; |
356 { | 357 { |
357 // Keep a reference count such that |drag_source_| will not get deleted | 358 // Keep a reference count such that |drag_source_| will not get deleted |
358 // if the contents view window is gone in the nested message loop invoked | 359 // if the contents view window is gone in the nested message loop invoked |
359 // from DoDragDrop. | 360 // from DoDragDrop. |
360 scoped_refptr<WebDragSource> retain_this(drag_source_); | 361 scoped_refptr<WebDragSource> retain_this(drag_source_); |
361 | 362 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 | 424 |
424 // The drag-and-drop thread is only closed after OLE is done with | 425 // The drag-and-drop thread is only closed after OLE is done with |
425 // DataObjectImpl. | 426 // DataObjectImpl. |
426 BrowserThread::PostTask( | 427 BrowserThread::PostTask( |
427 BrowserThread::UI, | 428 BrowserThread::UI, |
428 FROM_HERE, | 429 FROM_HERE, |
429 base::Bind(&WebContentsDragWin::CloseThread, this)); | 430 base::Bind(&WebContentsDragWin::CloseThread, this)); |
430 } | 431 } |
431 | 432 |
432 } // namespace content | 433 } // namespace content |
OLD | NEW |