diff options
-rw-r--r-- | app/menus/menu_model.cc | 5 | ||||
-rw-r--r-- | app/menus/menu_model.h | 4 | ||||
-rw-r--r-- | chrome/browser/back_forward_menu_model.cc | 7 | ||||
-rw-r--r-- | chrome/browser/back_forward_menu_model.h | 6 | ||||
-rw-r--r-- | chrome/browser/gtk/menu_gtk.cc | 12 |
5 files changed, 24 insertions, 10 deletions
diff --git a/app/menus/menu_model.cc b/app/menus/menu_model.cc index cbce228..c8b7835 100644 --- a/app/menus/menu_model.cc +++ b/app/menus/menu_model.cc @@ -29,4 +29,9 @@ bool MenuModel::GetModelAndIndexForCommandId(int command_id, return false; } +// Default implementation ignores the disposition. +void MenuModel::ActivatedAtWithDisposition(int index, int disposition) { + ActivatedAt(index); +} + } // namespace diff --git a/app/menus/menu_model.h b/app/menus/menu_model.h index 1cb356a..78b92a7 100644 --- a/app/menus/menu_model.h +++ b/app/menus/menu_model.h @@ -107,6 +107,10 @@ class MenuModel { // Called when the item at the specified index has been activated. virtual void ActivatedAt(int index) = 0; + // Called when the item has been activated with a given disposition (for the + // case where the activation involves a navigation). + virtual void ActivatedAtWithDisposition(int index, int disposition); + // Called when the menu is about to be shown. virtual void MenuWillShow() {} diff --git a/chrome/browser/back_forward_menu_model.cc b/chrome/browser/back_forward_menu_model.cc index fb18da8..98307af 100644 --- a/chrome/browser/back_forward_menu_model.cc +++ b/chrome/browser/back_forward_menu_model.cc @@ -137,8 +137,7 @@ void BackForwardMenuModel::ActivatedAt(int index) { } void BackForwardMenuModel::ActivatedAtWithDisposition( - int index, - WindowOpenDisposition disposition) { + int index, int disposition) { Profile* profile = browser_->profile(); DCHECK(!IsSeparator(index)); @@ -162,8 +161,8 @@ void BackForwardMenuModel::ActivatedAtWithDisposition( } int controller_index = MenuIndexToNavEntryIndex(index); - if (!browser_->NavigateToIndexWithDisposition(controller_index, - disposition)) { + if (!browser_->NavigateToIndexWithDisposition( + controller_index, static_cast<WindowOpenDisposition>(disposition))) { NOTREACHED(); } } diff --git a/chrome/browser/back_forward_menu_model.h b/chrome/browser/back_forward_menu_model.h index 4f838fd..b97698d 100644 --- a/chrome/browser/back_forward_menu_model.h +++ b/chrome/browser/back_forward_menu_model.h @@ -59,11 +59,7 @@ class BackForwardMenuModel : public menus::MenuModel { virtual MenuModel* GetSubmenuModelAt(int index) const; virtual void HighlightChangedTo(int index); virtual void ActivatedAt(int index); - - // Navigates to the corresponding history item, opening it in a new tab - // if necessary. - void ActivatedAtWithDisposition(int index, - WindowOpenDisposition disposition); + virtual void ActivatedAtWithDisposition(int index, int disposition); virtual void MenuWillShow(); // Is the item at |index| a separator? diff --git a/chrome/browser/gtk/menu_gtk.cc b/chrome/browser/gtk/menu_gtk.cc index 86a1ba1..5823f25 100644 --- a/chrome/browser/gtk/menu_gtk.cc +++ b/chrome/browser/gtk/menu_gtk.cc @@ -20,6 +20,7 @@ #include "chrome/browser/gtk/gtk_util.h" #include "gfx/gtk_util.h" #include "third_party/skia/include/core/SkBitmap.h" +#include "webkit/glue/window_open_disposition.h" bool MenuGtk::block_activation_ = false; @@ -693,7 +694,16 @@ void MenuGtk::ExecuteCommand(menus::MenuModel* model, int id) { if (delegate_) delegate_->CommandWillBeExecuted(); - model->ActivatedAt(id); + GdkEvent* event = gtk_get_current_event(); + if (event && event->type == GDK_BUTTON_RELEASE) { + model->ActivatedAtWithDisposition( + id, event_utils::DispositionFromEventFlags(event->button.state)); + } else { + model->ActivatedAt(id); + } + + if (event) + gdk_event_free(event); } void MenuGtk::OnMenuShow(GtkWidget* widget) { |