Fix 2 drag-out problems:
1) Does not work if dragging out to XP desktop. We need to return an error code when waiting for XP Shell to start a background thread. 2) Occasional crash due to regression caused by r43726. Fix it by holding a local reference to drag_source_. BUG=none TEST=none Review URL: http://codereview.chromium.org/1619023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44833 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
@ -633,24 +633,25 @@ HRESULT DataObjectImpl::GetData(FORMATETC* format_etc, STGMEDIUM* medium) {
|
||||
}
|
||||
}
|
||||
|
||||
if (wait_for_data) {
|
||||
// Notify the observer we start waiting for the data. This gives
|
||||
// an observer a chance to end the drag and drop.
|
||||
if (observer_)
|
||||
observer_->OnWaitForData();
|
||||
if (!wait_for_data)
|
||||
return DV_E_FORMATETC;
|
||||
|
||||
// Now we can start the download.
|
||||
if ((*iter)->downloader.get()) {
|
||||
if (!(*iter)->downloader->Start(this)) {
|
||||
is_aborting_ = true;
|
||||
return DV_E_FORMATETC;
|
||||
}
|
||||
// Notify the observer we start waiting for the data. This gives
|
||||
// an observer a chance to end the drag and drop.
|
||||
if (observer_)
|
||||
observer_->OnWaitForData();
|
||||
|
||||
// Now we can start the download.
|
||||
if ((*iter)->downloader.get()) {
|
||||
if (!(*iter)->downloader->Start(this)) {
|
||||
is_aborting_ = true;
|
||||
return DV_E_FORMATETC;
|
||||
}
|
||||
|
||||
// The stored data should have been updated with the final version.
|
||||
// So we just need to call this function again to retrieve it.
|
||||
return GetData(format_etc, medium);
|
||||
}
|
||||
|
||||
// The stored data should have been updated with the final version.
|
||||
// So we just need to call this function again to retrieve it.
|
||||
return GetData(format_etc, medium);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
@ -284,17 +284,22 @@ void TabContentsDragWin::DoDragging(const WebDropData& drop_data,
|
||||
data.SetString(drop_data.plain_text);
|
||||
}
|
||||
|
||||
// Keep a local reference to drag_source_ in case that EndDragging is called
|
||||
// before DoDragDrop returns.
|
||||
scoped_refptr<WebDragSource> drag_source(drag_source_);
|
||||
|
||||
// We need to enable recursive tasks on the message loop so we can get
|
||||
// updates while in the system DoDragDrop loop.
|
||||
bool old_state = MessageLoop::current()->NestableTasksAllowed();
|
||||
DWORD effect;
|
||||
MessageLoop::current()->SetNestableTasksAllowed(true);
|
||||
DWORD effect;
|
||||
DoDragDrop(OSExchangeDataProviderWin::GetIDataObject(data), drag_source_,
|
||||
web_drag_utils_win::WebDragOpMaskToWinDragOpMask(ops), &effect);
|
||||
MessageLoop::current()->SetNestableTasksAllowed(old_state);
|
||||
|
||||
// This works because WebDragSource::OnDragSourceDrop uses PostTask to
|
||||
// dispatch the actual event.
|
||||
drag_source_->set_effect(effect);
|
||||
MessageLoop::current()->SetNestableTasksAllowed(old_state);
|
||||
drag_source->set_effect(effect);
|
||||
}
|
||||
|
||||
void TabContentsDragWin::EndDragging(bool restore_suspended_state) {
|
||||
|
Reference in New Issue
Block a user