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 "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 |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 } | 305 } |
306 | 306 |
307 // Set drag image. | 307 // Set drag image. |
308 if (!image.isNull()) { | 308 if (!image.isNull()) { |
309 drag_utils::SetDragImageOnDataObject( | 309 drag_utils::SetDragImageOnDataObject( |
310 image, gfx::Size(image.width(), image.height()), image_offset, &data); | 310 image, gfx::Size(image.width(), image.height()), image_offset, &data); |
311 } | 311 } |
312 | 312 |
313 // We need to enable recursive tasks on the message loop so we can get | 313 // We need to enable recursive tasks on the message loop so we can get |
314 // updates while in the system DoDragDrop loop. | 314 // updates while in the system DoDragDrop loop. |
315 bool old_state = MessageLoop::current()->NestableTasksAllowed(); | |
316 MessageLoop::current()->SetNestableTasksAllowed(true); | |
317 DWORD effect; | 315 DWORD effect; |
318 DoDragDrop(ui::OSExchangeDataProviderWin::GetIDataObject(data), drag_source_, | 316 { |
319 web_drag_utils_win::WebDragOpMaskToWinDragOpMask(ops), &effect); | 317 MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); |
320 MessageLoop::current()->SetNestableTasksAllowed(old_state); | 318 DoDragDrop(ui::OSExchangeDataProviderWin::GetIDataObject(data), |
| 319 drag_source_, |
| 320 web_drag_utils_win::WebDragOpMaskToWinDragOpMask(ops), |
| 321 &effect); |
| 322 } |
321 | 323 |
322 // This works because WebDragSource::OnDragSourceDrop uses PostTask to | 324 // This works because WebDragSource::OnDragSourceDrop uses PostTask to |
323 // dispatch the actual event. | 325 // dispatch the actual event. |
324 drag_source_->set_effect(effect); | 326 drag_source_->set_effect(effect); |
325 } | 327 } |
326 | 328 |
327 void TabContentsDragWin::EndDragging(bool restore_suspended_state) { | 329 void TabContentsDragWin::EndDragging(bool restore_suspended_state) { |
328 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 330 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
329 | 331 |
330 if (drag_ended_) | 332 if (drag_ended_) |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 void TabContentsDragWin::OnDataObjectDisposed() { | 372 void TabContentsDragWin::OnDataObjectDisposed() { |
371 DCHECK(drag_drop_thread_id_ == base::PlatformThread::CurrentId()); | 373 DCHECK(drag_drop_thread_id_ == base::PlatformThread::CurrentId()); |
372 | 374 |
373 // 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 |
374 // DataObjectImpl. | 376 // DataObjectImpl. |
375 BrowserThread::PostTask( | 377 BrowserThread::PostTask( |
376 BrowserThread::UI, | 378 BrowserThread::UI, |
377 FROM_HERE, | 379 FROM_HERE, |
378 base::Bind(&TabContentsDragWin::CloseThread, this)); | 380 base::Bind(&TabContentsDragWin::CloseThread, this)); |
379 } | 381 } |
OLD | NEW |