Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(252)

Unified Diff: chrome/browser/tab_contents/tab_contents.cc

Issue 362013: [Mac] Delay TabContents::Close() when event-tracking. (Closed)
Patch Set: Oops, included file moved. Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/cocoa/tab_controller.mm ('k') | chrome/browser/tab_contents/tab_contents_view.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/tab_contents/tab_contents.cc
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index e72df68642ed11783ebd319c349bff635b744355..35e9b80b6c689576472310fee6ab286dd69ee23b 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -2179,6 +2179,21 @@ void TabContents::UpdateInspectorSettings(const std::string& raw_settings) {
}
void TabContents::Close(RenderViewHost* rvh) {
+ // The UI may be in an event-tracking loop, such as between the
+ // mouse-down and mouse-up in text selection or a button click.
+ // Defer the close until after tracking is complete, so that we
+ // don't free objects out from under the UI.
+ // TODO(shess): This could probably be integrated with the
+ // IsDoingDrag() test below. Punting for now because I need more
+ // research to understand how this impacts platforms other than Mac.
+ // TODO(shess): This could get more fine-grained. For instance,
+ // closing a tab in another window while selecting text in the
+ // current window's Omnibox should be just fine.
+ if (view()->IsEventTracking()) {
+ view()->CloseTabAfterEventTracking();
+ return;
+ }
+
// If we close the tab while we're in the middle of a drag, we'll crash.
// Instead, cancel the drag and close it as soon as the drag ends.
if (view()->IsDoingDrag()) {
« no previous file with comments | « chrome/browser/cocoa/tab_controller.mm ('k') | chrome/browser/tab_contents/tab_contents_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698