Index: chrome/browser/ui/views/browser_actions_container.cc |
diff --git a/chrome/browser/ui/views/browser_actions_container.cc b/chrome/browser/ui/views/browser_actions_container.cc |
index ef3dd6e7008693358b448560840b4d8e19296beb..b014d1f5ebd14e86aaf75f4811276d4d14dd00e5 100644 |
--- a/chrome/browser/ui/views/browser_actions_container.cc |
+++ b/chrome/browser/ui/views/browser_actions_container.cc |
@@ -813,8 +813,12 @@ void BrowserActionsContainer::InspectPopup(ExtensionAction* action) { |
} |
void BrowserActionsContainer::OnWidgetClosing(views::Widget* widget) { |
- DCHECK_EQ(popup_->GetWidget(), widget); |
- popup_->GetWidget()->RemoveObserver(this); |
+ // Always remove this as an observer of a closing popup. |
+ widget->RemoveObserver(this); |
+ // If a new popup has been opened before this gets called, |popup_| will |
sky
2012/03/02 20:53:50
Can't this go back to a DCHECK now?
stevenjb
2012/03/02 21:29:13
Since closing a window is independent from calls t
|
+ // point to the new popup, so just return. |
+ if (!popup_ || popup_->GetWidget() != widget) |
+ return; |
popup_ = NULL; |
// |popup_button_| is NULL if the extension has been removed. |
if (popup_button_) { |
@@ -834,9 +838,15 @@ void BrowserActionsContainer::MoveBrowserAction(const std::string& extension_id, |
} |
void BrowserActionsContainer::HidePopup() { |
+ // Remove this as an observer and clear |popup_| and |popup_button_| here, |
+ // since we might change them before OnWidgetClosing() gets called. |
if (popup_) { |
+ popup_->GetWidget()->RemoveObserver(this); |
popup_->GetWidget()->Close(); |
- // NULL out popup_button_ in case it's being deleted. |
+ popup_ = NULL; |
+ } |
+ if (popup_button_) { |
+ popup_button_->SetButtonNotPushed(); |
popup_button_ = NULL; |
} |
} |