Index: ui/views/controls/menu/menu_controller.cc |
diff --git a/ui/views/controls/menu/menu_controller.cc b/ui/views/controls/menu/menu_controller.cc |
index 12c5aae5351eb5759e048fc629f9b5e8cc3380c8..12ce299884df8b53cf8d9ff4b9cc799385584be1 100644 |
--- a/ui/views/controls/menu/menu_controller.cc |
+++ b/ui/views/controls/menu/menu_controller.cc |
@@ -356,8 +356,12 @@ MenuItemView* MenuController::Run(Widget* parent, |
return NULL; |
} |
- if (button) |
+ scoped_ptr<MenuButton::PressedLock>& pressed_lock = |
+ nested_menu ? nested_pressed_lock_ : pressed_lock_; |
+ if (button) { |
menu_button_ = button; |
+ pressed_lock.reset(new MenuButton::PressedLock(menu_button_)); |
+ } |
// Make sure Chrome doesn't attempt to shut down while the menu is showing. |
if (ViewsDelegate::views_delegate) |
@@ -434,12 +438,10 @@ MenuItemView* MenuController::Run(Widget* parent, |
} |
} |
- // If we stopped running because one of the menus was destroyed chances are |
- // the button was also destroyed. |
- if (exit_type_ != EXIT_DESTROYED && menu_button_) { |
- menu_button_->SetState(CustomButton::STATE_NORMAL); |
- menu_button_->SchedulePaint(); |
- } |
+ // Reset our pressed lock. The lock handles the case if the button was |
+ // destroyed. |
+ pressed_lock.reset(); |
+ |
return result; |
} |
@@ -1223,11 +1225,13 @@ bool MenuController::ShowSiblingMenu(SubmenuView* source, |
// There is a sibling menu, update the button state, hide the current menu |
// and show the new one. |
- menu_button_->SetState(CustomButton::STATE_NORMAL); |
- menu_button_->SchedulePaint(); |
menu_button_ = button; |
- menu_button_->SetState(CustomButton::STATE_PRESSED); |
- menu_button_->SchedulePaint(); |
+ // We know that we need to reset the nested lock if it exists because we only |
+ // support nesting menus that block runs (so we can't both have a nested menu |
+ // *and* be updating the original). |
+ scoped_ptr<MenuButton::PressedLock>& pressed_lock = |
+ nested_pressed_lock_.get() ? nested_pressed_lock_ : pressed_lock_; |
+ pressed_lock.reset(new MenuButton::PressedLock(menu_button_)); |
// Need to reset capture when we show the menu again, otherwise we aren't |
// going to get any events. |