| Index: chrome/browser/ui/views/toolbar/browser_action_view.cc
|
| diff --git a/chrome/browser/ui/views/toolbar/browser_action_view.cc b/chrome/browser/ui/views/toolbar/browser_action_view.cc
|
| index 02a63533a0ff8358099ccf48fdd7c4a369b13d51..e66650171931e96d9e030beefdcb04e0719a9d4a 100644
|
| --- a/chrome/browser/ui/views/toolbar/browser_action_view.cc
|
| +++ b/chrome/browser/ui/views/toolbar/browser_action_view.cc
|
| @@ -130,13 +130,8 @@ void BrowserActionView::UpdateState() {
|
| if (tab_id < 0)
|
| return;
|
|
|
| - if (!IsEnabled(tab_id)) {
|
| + if (!IsEnabled(tab_id))
|
| SetState(views::CustomButton::STATE_DISABLED);
|
| - } else {
|
| - SetState(menu_visible_ ?
|
| - views::CustomButton::STATE_PRESSED :
|
| - views::CustomButton::STATE_NORMAL);
|
| - }
|
|
|
| gfx::ImageSkia icon = *view_controller_->GetIcon(tab_id).ToImageSkia();
|
|
|
| @@ -255,16 +250,6 @@ scoped_ptr<LabelButtonBorder> BrowserActionView::CreateDefaultBorder() const {
|
| return border.Pass();
|
| }
|
|
|
| -void BrowserActionView::SetButtonPushed() {
|
| - SetState(views::CustomButton::STATE_PRESSED);
|
| - menu_visible_ = true;
|
| -}
|
| -
|
| -void BrowserActionView::SetButtonNotPushed() {
|
| - SetState(views::CustomButton::STATE_NORMAL);
|
| - menu_visible_ = false;
|
| -}
|
| -
|
| bool BrowserActionView::IsEnabled(int tab_id) const {
|
| return view_controller_->extension_action()->GetIsVisible(tab_id);
|
| }
|
| @@ -334,7 +319,7 @@ void BrowserActionView::HideActivePopup() {
|
| void BrowserActionView::OnPopupShown(bool grant_tab_permissions) {
|
| delegate_->SetPopupOwner(this);
|
| if (grant_tab_permissions)
|
| - SetButtonPushed();
|
| + SetMenuVisible(true);
|
| }
|
|
|
| void BrowserActionView::CleanupPopup() {
|
| @@ -342,14 +327,27 @@ void BrowserActionView::CleanupPopup() {
|
| // performing the rest of the cleanup in OnWidgetDestroyed()) because
|
| // OnWidgetDestroyed() can be called asynchronously from Close(), and we need
|
| // to keep the delegate's popup owner up-to-date.
|
| - SetButtonNotPushed();
|
| + SetMenuVisible(false);
|
| delegate_->SetPopupOwner(NULL);
|
| }
|
|
|
| void BrowserActionView::OnWillShowContextMenus() {
|
| - SetButtonPushed();
|
| + SetMenuVisible(true);
|
| }
|
|
|
| void BrowserActionView::OnContextMenuDone() {
|
| - SetButtonNotPushed();
|
| + SetMenuVisible(false);
|
| +}
|
| +
|
| +void BrowserActionView::SetMenuVisible(bool menu_visible) {
|
| + // We set the state of the menu button we're using as a reference view, which
|
| + // is either this or the overflow reference view.
|
| + // This cast is safe because GetReferenceViewForPopup returns either |this|
|
| + // or delegate_->GetOverflowReferenceView(), which returns a MenuButton.
|
| + views::MenuButton* reference_view =
|
| + static_cast<views::MenuButton*>(GetReferenceViewForPopup());
|
| + if (menu_visible)
|
| + reference_view->AttachMenu();
|
| + else
|
| + reference_view->DetachMenu();
|
| }
|
|
|