Index: chrome/browser/ui/views/tabs/tab_drag_controller.cc |
diff --git a/chrome/browser/ui/views/tabs/tab_drag_controller.cc b/chrome/browser/ui/views/tabs/tab_drag_controller.cc |
index c3980924258555be4adeb146fc11318f6f8da8a6..d0e2820b4b60a072219d30dc6f89f34b07a1b73d 100644 |
--- a/chrome/browser/ui/views/tabs/tab_drag_controller.cc |
+++ b/chrome/browser/ui/views/tabs/tab_drag_controller.cc |
@@ -1137,7 +1137,7 @@ void TabDragController::Attach(TabStrip* attached_tabstrip, |
} |
// Return the WebContents to normalcy. |
- source_dragged_contents()->SetCapturingContents(false); |
+ source_dragged_contents()->DecrementCapturerCount(); |
} |
// Inserting counts as a move. We don't want the tabs to jitter when the |
@@ -1226,7 +1226,7 @@ void TabDragController::Detach(ReleaseCapture release_capture) { |
// Prevent the WebContents HWND from being hidden by any of the model |
// operations performed during the drag. |
if (!detach_into_browser_) |
- source_dragged_contents()->SetCapturingContents(true); |
+ source_dragged_contents()->IncrementCapturerCount(); |
std::vector<gfx::Rect> drag_bounds = CalculateBoundsForDraggedTabs(0); |
TabStripModel* attached_model = GetModel(attached_tabstrip_); |
@@ -1660,6 +1660,13 @@ void TabDragController::RevertDrag() { |
if (detach_into_browser_ && source_tabstrip_) |
source_tabstrip_->GetWidget()->Activate(); |
+ |
+ // Return the WebContents to normalcy. If the tab was attached to a |
+ // TabStrip before the revert, the decrement has already occurred. |
+ // If the tab was destroyed, don't attempt to dereference the |
+ // WebContents pointer. |
+ if (!detach_into_browser_ && !attached_tabstrip_ && source_dragged_contents()) |
+ source_dragged_contents()->DecrementCapturerCount(); |
} |
void TabDragController::ResetSelection(TabStripModel* model) { |
@@ -1805,6 +1812,10 @@ void TabDragController::CompleteDrag() { |
contentses, window_bounds, dock_info_, widget->IsMaximized()); |
ResetSelection(new_browser->tab_strip_model()); |
new_browser->window()->Show(); |
+ |
+ // Return the WebContents to normalcy. |
+ if (!detach_into_browser_) |
+ source_dragged_contents()->DecrementCapturerCount(); |
} |
CleanUpHiddenFrame(); |