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

Side by Side Diff: chrome/browser/ui/views/browser_actions_container.cc

Issue 9535020: Fix DCHECK in BrowserActionsContainer::OnWidgetClosing (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix comments Created 8 years, 9 months 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/browser_actions_container.h" 5 #include "chrome/browser/ui/views/browser_actions_container.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 BrowserActionOverflowMenuController* controller) { 806 BrowserActionOverflowMenuController* controller) {
807 DCHECK(controller == overflow_menu_); 807 DCHECK(controller == overflow_menu_);
808 overflow_menu_ = NULL; 808 overflow_menu_ = NULL;
809 } 809 }
810 810
811 void BrowserActionsContainer::InspectPopup(ExtensionAction* action) { 811 void BrowserActionsContainer::InspectPopup(ExtensionAction* action) {
812 OnBrowserActionExecuted(GetBrowserActionView(action)->button(), true); 812 OnBrowserActionExecuted(GetBrowserActionView(action)->button(), true);
813 } 813 }
814 814
815 void BrowserActionsContainer::OnWidgetClosing(views::Widget* widget) { 815 void BrowserActionsContainer::OnWidgetClosing(views::Widget* widget) {
816 DCHECK_EQ(popup_->GetWidget(), widget); 816 // Always remove this as an observer of a closing popup.
817 popup_->GetWidget()->RemoveObserver(this); 817 widget->RemoveObserver(this);
818 // 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
819 // point to the new popup, so just return.
820 if (!popup_ || popup_->GetWidget() != widget)
821 return;
818 popup_ = NULL; 822 popup_ = NULL;
819 // |popup_button_| is NULL if the extension has been removed. 823 // |popup_button_| is NULL if the extension has been removed.
820 if (popup_button_) { 824 if (popup_button_) {
821 popup_button_->SetButtonNotPushed(); 825 popup_button_->SetButtonNotPushed();
822 popup_button_ = NULL; 826 popup_button_ = NULL;
823 } 827 }
824 } 828 }
825 829
826 void BrowserActionsContainer::MoveBrowserAction(const std::string& extension_id, 830 void BrowserActionsContainer::MoveBrowserAction(const std::string& extension_id,
827 size_t new_index) { 831 size_t new_index) {
828 ExtensionService* service = profile_->GetExtensionService(); 832 ExtensionService* service = profile_->GetExtensionService();
829 if (service) { 833 if (service) {
830 const Extension* extension = service->GetExtensionById(extension_id, false); 834 const Extension* extension = service->GetExtensionById(extension_id, false);
831 model_->MoveBrowserAction(extension, new_index); 835 model_->MoveBrowserAction(extension, new_index);
832 SchedulePaint(); 836 SchedulePaint();
833 } 837 }
834 } 838 }
835 839
836 void BrowserActionsContainer::HidePopup() { 840 void BrowserActionsContainer::HidePopup() {
841 // Remove this as an observer and clear |popup_| and |popup_button_| here,
842 // since we might change them before OnWidgetClosing() gets called.
837 if (popup_) { 843 if (popup_) {
844 popup_->GetWidget()->RemoveObserver(this);
838 popup_->GetWidget()->Close(); 845 popup_->GetWidget()->Close();
839 // NULL out popup_button_ in case it's being deleted. 846 popup_ = NULL;
847 }
848 if (popup_button_) {
849 popup_button_->SetButtonNotPushed();
840 popup_button_ = NULL; 850 popup_button_ = NULL;
841 } 851 }
842 } 852 }
843 853
844 void BrowserActionsContainer::TestExecuteBrowserAction(int index) { 854 void BrowserActionsContainer::TestExecuteBrowserAction(int index) {
845 BrowserActionButton* button = browser_action_views_[index]->button(); 855 BrowserActionButton* button = browser_action_views_[index]->button();
846 OnBrowserActionExecuted(button, false); 856 OnBrowserActionExecuted(button, false);
847 } 857 }
848 858
849 void BrowserActionsContainer::TestSetIconVisibilityCount(size_t icons) { 859 void BrowserActionsContainer::TestSetIconVisibilityCount(size_t icons) {
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
1120 } 1130 }
1121 } 1131 }
1122 1132
1123 bool BrowserActionsContainer::ShouldDisplayBrowserAction( 1133 bool BrowserActionsContainer::ShouldDisplayBrowserAction(
1124 const Extension* extension) { 1134 const Extension* extension) {
1125 // Only display incognito-enabled extensions while in incognito mode. 1135 // Only display incognito-enabled extensions while in incognito mode.
1126 return 1136 return
1127 (!profile_->IsOffTheRecord() || 1137 (!profile_->IsOffTheRecord() ||
1128 profile_->GetExtensionService()->IsIncognitoEnabled(extension->id())); 1138 profile_->GetExtensionService()->IsIncognitoEnabled(extension->id()));
1129 } 1139 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698