diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-06 21:04:55 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-06 21:04:55 +0000 |
commit | a8e91124532061d21f0114605530c605582144e8 (patch) | |
tree | 4ee30fb79cdb064517c5ad0a1c11a75328a7db04 /chrome | |
parent | 4e59e814cc1264300b597c3d62a8ccb4da264889 (diff) | |
download | chromium_src-a8e91124532061d21f0114605530c605582144e8.zip chromium_src-a8e91124532061d21f0114605530c605582144e8.tar.gz chromium_src-a8e91124532061d21f0114605530c605582144e8.tar.bz2 |
GTK: Change menu delegate callback from CommandWasExecuted to CommandWillBeExecuted.
Both the menu itself and the delegate were being destroyed in ExecuteCommand, double whammy!
BUG=40477
TEST=disable browser action extension via context menu
Review URL: http://codereview.chromium.org/1593012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43757 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/gtk/browser_actions_toolbar_gtk.cc | 2 | ||||
-rw-r--r-- | chrome/browser/gtk/menu_gtk.cc | 6 | ||||
-rw-r--r-- | chrome/browser/gtk/menu_gtk.h | 8 |
3 files changed, 9 insertions, 7 deletions
diff --git a/chrome/browser/gtk/browser_actions_toolbar_gtk.cc b/chrome/browser/gtk/browser_actions_toolbar_gtk.cc index 1d25c2a..9087793 100644 --- a/chrome/browser/gtk/browser_actions_toolbar_gtk.cc +++ b/chrome/browser/gtk/browser_actions_toolbar_gtk.cc @@ -200,7 +200,7 @@ class BrowserActionButton : public NotificationObserver, gtk_util::GrabAllInput(toolbar_->overflow_menu_->widget()); } - virtual void CommandWasExecuted() { + virtual void CommandWillBeExecuted() { // If the context menu was showing for the overflow menu, and a command // is executed, then stop showing the overflow menu. if (toolbar_->overflow_menu_.get()) diff --git a/chrome/browser/gtk/menu_gtk.cc b/chrome/browser/gtk/menu_gtk.cc index 31c2a55..7670b6c 100644 --- a/chrome/browser/gtk/menu_gtk.cc +++ b/chrome/browser/gtk/menu_gtk.cc @@ -509,13 +509,13 @@ bool MenuGtk::IsCommandEnabled(menus::MenuModel* model, int id) { // http://crbug.com/31365 void MenuGtk::ExecuteCommand(menus::MenuModel* model, int id) { + if (delegate_) + delegate_->CommandWillBeExecuted(); + if (model) model->ActivatedAt(id); else delegate_->ExecuteCommandById(id); - - if (delegate_) - delegate_->CommandWasExecuted(); } // http://crbug.com/31365 diff --git a/chrome/browser/gtk/menu_gtk.h b/chrome/browser/gtk/menu_gtk.h index 4dfbdcf..5f33b6b 100644 --- a/chrome/browser/gtk/menu_gtk.h +++ b/chrome/browser/gtk/menu_gtk.h @@ -40,10 +40,12 @@ class MenuGtk { // Executes the command. virtual void ExecuteCommandById(int command_id) {} - // Called after a command is executed. This exists for the case where a + // Called before a command is executed. This exists for the case where a // model is handling the actual execution of commands, but the delegate - // still needs to know that some command got executed. - virtual void CommandWasExecuted() {} + // still needs to know that some command got executed. This is called before + // and not after the command is executed because its execution may delete + // the menu and/or the delegate. + virtual void CommandWillBeExecuted() {} // Called when the menu stops showing. This will be called before // ExecuteCommand if the user clicks an item, but will also be called when |