Chromium Code Reviews| 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..61db7a25605880da6913a7d9c04507c8280e229a 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 |
| + // 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, |
|
msw
2012/03/02 20:39:35
nit: add vertical bars around identifiers in comme
stevenjb
2012/03/02 20:44:18
Done.
|
| + // since we might change popup_ 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; |
| } |
| } |