| 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()) {
|
|
|