| 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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 // because the window could be disposed in the nested message loop. | 353 // because the window could be disposed in the nested message loop. |
| 354 HWND native_window = web_contents_->GetView()->GetNativeView(); | 354 HWND native_window = web_contents_->GetView()->GetNativeView(); |
| 355 | 355 |
| 356 // We need to enable recursive tasks on the message loop so we can get | 356 // We need to enable recursive tasks on the message loop so we can get |
| 357 // updates while in the system DoDragDrop loop. | 357 // updates while in the system DoDragDrop loop. |
| 358 DWORD effect = DROPEFFECT_NONE; | 358 DWORD effect = DROPEFFECT_NONE; |
| 359 if (run_do_drag_drop) { | 359 if (run_do_drag_drop) { |
| 360 // Keep a reference count such that |drag_source_| will not get deleted | 360 // Keep a reference count such that |drag_source_| will not get deleted |
| 361 // if the contents view window is gone in the nested message loop invoked | 361 // if the contents view window is gone in the nested message loop invoked |
| 362 // from DoDragDrop. | 362 // from DoDragDrop. |
| 363 scoped_refptr<WebDragSource> retain_this(drag_source_); | 363 scoped_refptr<WebDragSource> retain_source(drag_source_); |
| 364 retain_source->set_data(&data); |
| 365 data.SetInDragLoop(true); |
| 364 | 366 |
| 365 MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); | 367 MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); |
| 366 DoDragDrop(ui::OSExchangeDataProviderWin::GetIDataObject(data), | 368 DoDragDrop(ui::OSExchangeDataProviderWin::GetIDataObject(data), |
| 367 drag_source_, | 369 drag_source_, |
| 368 WebDragOpMaskToWinDragOpMask(ops), | 370 WebDragOpMaskToWinDragOpMask(ops), |
| 369 &effect); | 371 &effect); |
| 372 retain_source->set_data(NULL); |
| 370 } | 373 } |
| 371 | 374 |
| 372 // Bail out immediately if the contents view window is gone. | 375 // Bail out immediately if the contents view window is gone. |
| 373 if (!IsWindow(native_window)) | 376 if (!IsWindow(native_window)) |
| 374 return false; | 377 return false; |
| 375 | 378 |
| 376 // Normally, the drop and dragend events get dispatched in the system | 379 // Normally, the drop and dragend events get dispatched in the system |
| 377 // DoDragDrop message loop so it'd be too late to set the effect to send back | 380 // DoDragDrop message loop so it'd be too late to set the effect to send back |
| 378 // to the renderer here. However, we use PostTask to delay the execution of | 381 // to the renderer here. However, we use PostTask to delay the execution of |
| 379 // WebDragSource::OnDragSourceDrop, which means that the delayed dragend | 382 // WebDragSource::OnDragSourceDrop, which means that the delayed dragend |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 FROM_HERE, | 434 FROM_HERE, |
| 432 base::Bind(&WebContentsDragWin::CloseThread, this)); | 435 base::Bind(&WebContentsDragWin::CloseThread, this)); |
| 433 } | 436 } |
| 434 | 437 |
| 435 // static | 438 // static |
| 436 void WebContentsDragWin::DisableDragDropForTesting() { | 439 void WebContentsDragWin::DisableDragDropForTesting() { |
| 437 run_do_drag_drop = false; | 440 run_do_drag_drop = false; |
| 438 } | 441 } |
| 439 | 442 |
| 440 } // namespace content | 443 } // namespace content |
| OLD | NEW |