summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorshess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-06 23:07:25 +0000
committershess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-06 23:07:25 +0000
commit06ec7d485f2582a97824b379aef69b45f2a1beaf (patch)
tree07b9450b3d6b92b6eb2450a4e1eb54fa98b9b839 /chrome
parenta24b7aff2b62be4ebadedd9cf0898f73ac004e2d (diff)
downloadchromium_src-06ec7d485f2582a97824b379aef69b45f2a1beaf.zip
chromium_src-06ec7d485f2582a97824b379aef69b45f2a1beaf.tar.gz
chromium_src-06ec7d485f2582a97824b379aef69b45f2a1beaf.tar.bz2
[Mac] Defer close from renderer while tab is a drag source.
When dragging a link out of web content, pin the tab so that it doesn't close out from under the drag. BUG=26134 TEST=See bug for test.html. View test.html. Dragging link out should cause page to not close, and app should no longer crash. Review URL: http://codereview.chromium.org/372023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31318 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/tab_contents/tab_contents_view_mac.mm15
1 files changed, 12 insertions, 3 deletions
diff --git a/chrome/browser/tab_contents/tab_contents_view_mac.mm b/chrome/browser/tab_contents/tab_contents_view_mac.mm
index f464c1e..bb92da4 100644
--- a/chrome/browser/tab_contents/tab_contents_view_mac.mm
+++ b/chrome/browser/tab_contents/tab_contents_view_mac.mm
@@ -129,13 +129,22 @@ void TabContentsViewMac::GetContainerBounds(gfx::Rect* out) const {
void TabContentsViewMac::StartDragging(const WebDropData& drop_data,
WebDragOperationsMask allowed_operations) {
- // The drag invokes a nested event loop, but we need to continue processing
- // events.
+ // By allowing nested tasks, the code below also allows Close(),
+ // which would deallocate |this|. The same problem can occur while
+ // processing -sendEvent:, so Close() is deferred in that case.
+ // Drags from web content do not come via -sendEvent:, this sets the
+ // same flag -sendEvent: would.
+ chrome_application_mac::ScopedSendingEvent sendingEventScoper(
+ static_cast<CrApplication*>([CrApplication sharedApplication]));
+
+ // The drag invokes a nested event loop, arrange to continue
+ // processing events.
+ bool old_state = MessageLoop::current()->NestableTasksAllowed();
MessageLoop::current()->SetNestableTasksAllowed(true);
NSDragOperation mask = static_cast<NSDragOperation>(allowed_operations);
[cocoa_view_ startDragWithDropData:drop_data
dragOperationMask:mask];
- MessageLoop::current()->SetNestableTasksAllowed(false);
+ MessageLoop::current()->SetNestableTasksAllowed(old_state);
}
void TabContentsViewMac::RenderViewCreated(RenderViewHost* host) {