Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 | |
| 819 // point to the new popup, so just return. | |
| 820 if (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() { |
| 837 if (popup_) { | 841 if (popup_) |
| 838 popup_->GetWidget()->Close(); | 842 popup_->GetWidget()->Close(); |
| 843 if (popup_button_) { | |
| 844 // Set the popup button to not pused here, since we might change popup_ | |
|
msw
2012/02/29 19:21:36
spelling nit: pushed
| |
| 845 // before OnWidgetClosing() gets called. | |
| 846 popup_button_->SetButtonNotPushed(); | |
| 839 // NULL out popup_button_ in case it's being deleted. | 847 // NULL out popup_button_ in case it's being deleted. |
| 840 popup_button_ = NULL; | 848 popup_button_ = NULL; |
| 841 } | 849 } |
| 842 } | 850 } |
| 843 | 851 |
| 844 void BrowserActionsContainer::TestExecuteBrowserAction(int index) { | 852 void BrowserActionsContainer::TestExecuteBrowserAction(int index) { |
| 845 BrowserActionButton* button = browser_action_views_[index]->button(); | 853 BrowserActionButton* button = browser_action_views_[index]->button(); |
| 846 OnBrowserActionExecuted(button, false); | 854 OnBrowserActionExecuted(button, false); |
| 847 } | 855 } |
| 848 | 856 |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1120 } | 1128 } |
| 1121 } | 1129 } |
| 1122 | 1130 |
| 1123 bool BrowserActionsContainer::ShouldDisplayBrowserAction( | 1131 bool BrowserActionsContainer::ShouldDisplayBrowserAction( |
| 1124 const Extension* extension) { | 1132 const Extension* extension) { |
| 1125 // Only display incognito-enabled extensions while in incognito mode. | 1133 // Only display incognito-enabled extensions while in incognito mode. |
| 1126 return | 1134 return |
| 1127 (!profile_->IsOffTheRecord() || | 1135 (!profile_->IsOffTheRecord() || |
| 1128 profile_->GetExtensionService()->IsIncognitoEnabled(extension->id())); | 1136 profile_->GetExtensionService()->IsIncognitoEnabled(extension->id())); |
| 1129 } | 1137 } |
| OLD | NEW |