| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/views/tab_contents/tab_contents_drag_win.h" | 5 #include "chrome/browser/views/tab_contents/tab_contents_drag_win.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 | 8 |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 if (!drop_data.file_contents.empty()) | 277 if (!drop_data.file_contents.empty()) |
| 278 PrepareDragForFileContents(drop_data, &data); | 278 PrepareDragForFileContents(drop_data, &data); |
| 279 if (!drop_data.text_html.empty()) | 279 if (!drop_data.text_html.empty()) |
| 280 data.SetHtml(drop_data.text_html, drop_data.html_base_url); | 280 data.SetHtml(drop_data.text_html, drop_data.html_base_url); |
| 281 if (drop_data.url.is_valid()) | 281 if (drop_data.url.is_valid()) |
| 282 PrepareDragForUrl(drop_data, &data); | 282 PrepareDragForUrl(drop_data, &data); |
| 283 if (!drop_data.plain_text.empty()) | 283 if (!drop_data.plain_text.empty()) |
| 284 data.SetString(drop_data.plain_text); | 284 data.SetString(drop_data.plain_text); |
| 285 } | 285 } |
| 286 | 286 |
| 287 // Keep a local reference to drag_source_ in case that EndDragging is called |
| 288 // before DoDragDrop returns. |
| 289 scoped_refptr<WebDragSource> drag_source(drag_source_); |
| 290 |
| 287 // We need to enable recursive tasks on the message loop so we can get | 291 // We need to enable recursive tasks on the message loop so we can get |
| 288 // updates while in the system DoDragDrop loop. | 292 // updates while in the system DoDragDrop loop. |
| 289 bool old_state = MessageLoop::current()->NestableTasksAllowed(); | 293 bool old_state = MessageLoop::current()->NestableTasksAllowed(); |
| 294 MessageLoop::current()->SetNestableTasksAllowed(true); |
| 290 DWORD effect; | 295 DWORD effect; |
| 291 MessageLoop::current()->SetNestableTasksAllowed(true); | |
| 292 DoDragDrop(OSExchangeDataProviderWin::GetIDataObject(data), drag_source_, | 296 DoDragDrop(OSExchangeDataProviderWin::GetIDataObject(data), drag_source_, |
| 293 web_drag_utils_win::WebDragOpToWinDragOp(ops), &effect); | 297 web_drag_utils_win::WebDragOpToWinDragOp(ops), &effect); |
| 298 MessageLoop::current()->SetNestableTasksAllowed(old_state); |
| 299 |
| 294 // This works because WebDragSource::OnDragSourceDrop uses PostTask to | 300 // This works because WebDragSource::OnDragSourceDrop uses PostTask to |
| 295 // dispatch the actual event. | 301 // dispatch the actual event. |
| 296 drag_source_->set_effect(effect); | 302 drag_source->set_effect(effect); |
| 297 MessageLoop::current()->SetNestableTasksAllowed(old_state); | |
| 298 } | 303 } |
| 299 | 304 |
| 300 void TabContentsDragWin::EndDragging(bool restore_suspended_state) { | 305 void TabContentsDragWin::EndDragging(bool restore_suspended_state) { |
| 301 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); | 306 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); |
| 302 | 307 |
| 303 if (drag_ended_) | 308 if (drag_ended_) |
| 304 return; | 309 return; |
| 305 drag_ended_ = true; | 310 drag_ended_ = true; |
| 306 | 311 |
| 307 if (restore_suspended_state) | 312 if (restore_suspended_state) |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 | 348 |
| 344 void TabContentsDragWin::OnDataObjectDisposed() { | 349 void TabContentsDragWin::OnDataObjectDisposed() { |
| 345 DCHECK(drag_drop_thread_id_ == PlatformThread::CurrentId()); | 350 DCHECK(drag_drop_thread_id_ == PlatformThread::CurrentId()); |
| 346 | 351 |
| 347 // The drag-and-drop thread is only closed after OLE is done with | 352 // The drag-and-drop thread is only closed after OLE is done with |
| 348 // DataObjectImpl. | 353 // DataObjectImpl. |
| 349 ChromeThread::PostTask( | 354 ChromeThread::PostTask( |
| 350 ChromeThread::UI, FROM_HERE, | 355 ChromeThread::UI, FROM_HERE, |
| 351 NewRunnableMethod(this, &TabContentsDragWin::CloseThread)); | 356 NewRunnableMethod(this, &TabContentsDragWin::CloseThread)); |
| 352 } | 357 } |
| OLD | NEW |