summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvarunjain@chromium.org <varunjain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-18 16:54:28 +0000
committervarunjain@chromium.org <varunjain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-18 16:54:28 +0000
commit940fb1c9ca08476b1d52fdb6e92b42e699f2d1e4 (patch)
tree49f2f8fbb112b16feadd07bef76f86bd5423f16b
parentcf43b6c19e56557cae9f0c36d3896b4576830475 (diff)
downloadchromium_src-940fb1c9ca08476b1d52fdb6e92b42e699f2d1e4.zip
chromium_src-940fb1c9ca08476b1d52fdb6e92b42e699f2d1e4.tar.gz
chromium_src-940fb1c9ca08476b1d52fdb6e92b42e699f2d1e4.tar.bz2
Add ContextMenuSourceType to views::ContextMenuController::ShowContextMenuForView.
This will help bring context menu positioning logic to one place and unify the positioning logic for all views. BUG=239110 Review URL: https://chromiumcodereview.appspot.com/16979002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207019 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/desktop_background/desktop_background_view.cc8
-rw-r--r--ash/desktop_background/desktop_background_view.h3
-rw-r--r--ash/launcher/launcher.cc4
-rw-r--r--ash/launcher/launcher.h3
-rw-r--r--ash/launcher/launcher_button.cc4
-rw-r--r--ash/launcher/launcher_button.h2
-rw-r--r--ash/launcher/launcher_unittest.cc2
-rw-r--r--ash/launcher/launcher_view.cc24
-rw-r--r--ash/launcher/launcher_view.h8
-rw-r--r--ash/root_window_controller.cc7
-rw-r--r--ash/root_window_controller.h4
-rw-r--r--ash/shell.cc5
-rw-r--r--ash/shell.h4
-rw-r--r--ash/shell/window_type_launcher.cc10
-rw-r--r--ash/shell/window_type_launcher.h3
-rw-r--r--ash/system/web_notification/web_notification_tray.cc5
-rw-r--r--ash/system/web_notification/web_notification_tray.h2
-rw-r--r--chrome/browser/chromeos/login/language_switch_menu.cc3
-rw-r--r--chrome/browser/ui/views/action_box_context_menu.cc4
-rw-r--r--chrome/browser/ui/views/action_box_context_menu.h3
-rw-r--r--chrome/browser/ui/views/action_box_menu.cc5
-rw-r--r--chrome/browser/ui/views/action_box_menu.h2
-rw-r--r--chrome/browser/ui/views/autofill/autofill_dialog_views.cc2
-rw-r--r--chrome/browser/ui/views/bookmarks/bookmark_bar_instructions_view.cc3
-rw-r--r--chrome/browser/ui/views/bookmarks/bookmark_bar_instructions_view.h3
-rw-r--r--chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc10
-rw-r--r--chrome/browser/ui/views/bookmarks/bookmark_bar_view.h5
-rw-r--r--chrome/browser/ui/views/bookmarks/bookmark_context_menu.cc5
-rw-r--r--chrome/browser/ui/views/bookmarks/bookmark_context_menu.h3
-rw-r--r--chrome/browser/ui/views/bookmarks/bookmark_editor_view.cc7
-rw-r--r--chrome/browser/ui/views/bookmarks/bookmark_editor_view.h3
-rw-r--r--chrome/browser/ui/views/bookmarks/bookmark_menu_controller_views.cc7
-rw-r--r--chrome/browser/ui/views/bookmarks/bookmark_menu_controller_views.h2
-rw-r--r--chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.cc4
-rw-r--r--chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.h2
-rw-r--r--chrome/browser/ui/views/browser_action_view.cc12
-rw-r--r--chrome/browser/ui/views/browser_action_view.h3
-rw-r--r--chrome/browser/ui/views/content_setting_bubble_contents.cc3
-rw-r--r--chrome/browser/ui/views/download/download_item_view.cc13
-rw-r--r--chrome/browser/ui/views/download/download_item_view.h6
-rw-r--r--chrome/browser/ui/views/download/download_shelf_context_menu_view.cc4
-rw-r--r--chrome/browser/ui/views/download/download_shelf_context_menu_view.h5
-rw-r--r--chrome/browser/ui/views/extensions/browser_action_overflow_menu_controller.cc5
-rw-r--r--chrome/browser/ui/views/extensions/browser_action_overflow_menu_controller.h2
-rw-r--r--chrome/browser/ui/views/frame/browser_frame.cc4
-rw-r--r--chrome/browser/ui/views/frame/browser_frame.h3
-rw-r--r--chrome/browser/ui/views/infobars/infobar_view.cc2
-rw-r--r--chrome/browser/ui/views/location_bar/page_action_image_view.cc10
-rw-r--r--chrome/browser/ui/views/location_bar/page_action_image_view.h3
-rw-r--r--chrome/browser/ui/views/menu_item_view_test.cc1
-rw-r--r--chrome/browser/ui/views/menu_model_adapter_test.cc1
-rw-r--r--chrome/browser/ui/views/notifications/balloon_view_views.cc1
-rw-r--r--chrome/browser/ui/views/omnibox/omnibox_view_win.cc2
-rw-r--r--chrome/browser/ui/views/reload_button.cc4
-rw-r--r--chrome/browser/ui/views/reload_button.h2
-rw-r--r--chrome/browser/ui/views/status_icons/status_icon_win.cc2
-rw-r--r--chrome/browser/ui/views/tab_contents/render_view_context_menu_views.cc19
-rw-r--r--chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc13
-rw-r--r--chrome/browser/ui/views/tabs/browser_tab_strip_controller.h3
-rw-r--r--chrome/browser/ui/views/tabs/fake_base_tab_strip_controller.cc6
-rw-r--r--chrome/browser/ui/views/tabs/fake_base_tab_strip_controller.h3
-rw-r--r--chrome/browser/ui/views/tabs/tab.cc5
-rw-r--r--chrome/browser/ui/views/tabs/tab.h3
-rw-r--r--chrome/browser/ui/views/tabs/tab_controller.h4
-rw-r--r--chrome/browser/ui/views/tabs/tab_strip.cc8
-rw-r--r--chrome/browser/ui/views/tabs/tab_strip.h3
-rw-r--r--chrome/browser/ui/views/tabs/tab_strip_controller.h5
-rw-r--r--chrome/browser/ui/views/tabs/tab_unittest.cc3
-rw-r--r--chrome/browser/ui/views/task_manager_view.cc8
-rw-r--r--chrome/browser/ui/views/website_settings/permission_selector_view.cc1
-rw-r--r--chrome/browser/ui/views/wrench_menu.cc7
-rw-r--r--chrome/browser/ui/views/wrench_menu.h2
-rw-r--r--ui/app_list/views/app_list_item_view.cc6
-rw-r--r--ui/app_list/views/app_list_item_view.h3
-rw-r--r--ui/app_list/views/app_list_menu_views.cc3
-rw-r--r--ui/app_list/views/search_result_view.cc6
-rw-r--r--ui/app_list/views/search_result_view.h3
-rw-r--r--ui/base/ui_base_types.cc20
-rw-r--r--ui/base/ui_base_types.h15
-rw-r--r--ui/message_center/views/message_view.cc7
-rw-r--r--ui/ui.gyp1
-rw-r--r--ui/views/context_menu_controller.h4
-rw-r--r--ui/views/controls/button/button_dropdown.cc14
-rw-r--r--ui/views/controls/button/button_dropdown.h5
-rw-r--r--ui/views/controls/button/custom_button.cc5
-rw-r--r--ui/views/controls/button/custom_button.h2
-rw-r--r--ui/views/controls/combobox/native_combobox_views.cc9
-rw-r--r--ui/views/controls/combobox/native_combobox_views.h2
-rw-r--r--ui/views/controls/menu/menu_controller.cc19
-rw-r--r--ui/views/controls/menu/menu_controller.h3
-rw-r--r--ui/views/controls/menu/menu_delegate.cc2
-rw-r--r--ui/views/controls/menu/menu_delegate.h2
-rw-r--r--ui/views/controls/menu/menu_runner.cc23
-rw-r--r--ui/views/controls/menu/menu_runner.h1
-rw-r--r--ui/views/controls/native_control.cc10
-rw-r--r--ui/views/controls/native_control_win.cc10
-rw-r--r--ui/views/controls/scrollbar/base_scroll_bar.cc6
-rw-r--r--ui/views/controls/scrollbar/base_scroll_bar.h3
-rw-r--r--ui/views/controls/textfield/native_textfield_views.cc9
-rw-r--r--ui/views/controls/textfield/native_textfield_views.h3
-rw-r--r--ui/views/controls/textfield/native_textfield_win.cc4
-rw-r--r--ui/views/controls/tree/tree_view.cc7
-rw-r--r--ui/views/controls/tree/tree_view.h2
-rw-r--r--ui/views/examples/menu_example.cc3
-rw-r--r--ui/views/examples/tree_view_example.cc5
-rw-r--r--ui/views/examples/tree_view_example.h3
-rw-r--r--ui/views/view.cc11
-rw-r--r--ui/views/view.h4
-rw-r--r--ui/views/widget/root_view.cc3
109 files changed, 388 insertions, 202 deletions
diff --git a/ash/desktop_background/desktop_background_view.cc b/ash/desktop_background/desktop_background_view.cc
index 141ad47..e27a183 100644
--- a/ash/desktop_background/desktop_background_view.cc
+++ b/ash/desktop_background/desktop_background_view.cc
@@ -170,9 +170,11 @@ bool DesktopBackgroundView::OnMousePressed(const ui::MouseEvent& event) {
return true;
}
-void DesktopBackgroundView::ShowContextMenuForView(views::View* source,
- const gfx::Point& point) {
- Shell::GetInstance()->ShowContextMenu(point);
+void DesktopBackgroundView::ShowContextMenuForView(
+ views::View* source,
+ const gfx::Point& point,
+ ui::MenuSourceType source_type) {
+ Shell::GetInstance()->ShowContextMenu(point, source_type);
}
views::Widget* CreateDesktopBackground(aura::RootWindow* root_window,
diff --git a/ash/desktop_background/desktop_background_view.h b/ash/desktop_background/desktop_background_view.h
index 8528e77..dbd3320 100644
--- a/ash/desktop_background/desktop_background_view.h
+++ b/ash/desktop_background/desktop_background_view.h
@@ -25,7 +25,8 @@ class DesktopBackgroundView : public views::View,
// Overridden from views::ContextMenuController:
virtual void ShowContextMenuForView(views::View* source,
- const gfx::Point& point) OVERRIDE;
+ const gfx::Point& point,
+ ui::MenuSourceType source_type) OVERRIDE;
DISALLOW_COPY_AND_ASSIGN(DesktopBackgroundView);
};
diff --git a/ash/launcher/launcher.cc b/ash/launcher/launcher.cc
index 335029a..8991c35 100644
--- a/ash/launcher/launcher.cc
+++ b/ash/launcher/launcher.cc
@@ -130,10 +130,6 @@ bool Launcher::IsShowingMenu() const {
return launcher_view_->IsShowingMenu();
}
-void Launcher::ShowContextMenu(const gfx::Point& location) {
- launcher_view_->ShowContextMenu(location, false);
-}
-
bool Launcher::IsShowingOverflowBubble() const {
return launcher_view_->IsShowingOverflowBubble();
}
diff --git a/ash/launcher/launcher.h b/ash/launcher/launcher.h
index 7d7f3cd..caeb63f 100644
--- a/ash/launcher/launcher.h
+++ b/ash/launcher/launcher.h
@@ -80,9 +80,6 @@ class ASH_EXPORT Launcher {
// Returns true if the Launcher is showing a context menu.
bool IsShowingMenu() const;
- // Show the context menu for the Launcher.
- void ShowContextMenu(const gfx::Point& location);
-
bool IsShowingOverflowBubble() const;
void SetVisible(bool visible) const;
diff --git a/ash/launcher/launcher_button.cc b/ash/launcher/launcher_button.cc
index 8c15a22..f275b0a 100644
--- a/ash/launcher/launcher_button.cc
+++ b/ash/launcher/launcher_button.cc
@@ -327,14 +327,14 @@ gfx::Rect LauncherButton::GetIconBounds() const {
}
void LauncherButton::ShowContextMenu(const gfx::Point& p,
- bool is_mouse_gesture) {
+ ui::MenuSourceType source_type) {
if (!context_menu_controller())
return;
bool destroyed = false;
destroyed_flag_ = &destroyed;
- CustomButton::ShowContextMenu(p, is_mouse_gesture);
+ CustomButton::ShowContextMenu(p, source_type);
if (!destroyed) {
destroyed_flag_ = NULL;
diff --git a/ash/launcher/launcher_button.h b/ash/launcher/launcher_button.h
index 41169e8..707aac0 100644
--- a/ash/launcher/launcher_button.h
+++ b/ash/launcher/launcher_button.h
@@ -59,7 +59,7 @@ class ASH_EXPORT LauncherButton : public views::CustomButton {
// Overrides to views::CustomButton:
virtual void ShowContextMenu(const gfx::Point& p,
- bool is_mouse_gesture) OVERRIDE;
+ ui::MenuSourceType source_type) OVERRIDE;
protected:
LauncherButton(views::ButtonListener* listener,
diff --git a/ash/launcher/launcher_unittest.cc b/ash/launcher/launcher_unittest.cc
index 59d6a67..b1798e3 100644
--- a/ash/launcher/launcher_unittest.cc
+++ b/ash/launcher/launcher_unittest.cc
@@ -75,7 +75,7 @@ TEST_F(LauncherTest, checkHoverAfterMenu) {
ASSERT_EQ(++button_count, test.GetButtonCount());
LauncherButton* button = test.GetButton(index);
button->AddState(LauncherButton::STATE_HOVERED);
- button->ShowContextMenu(gfx::Point(), true);
+ button->ShowContextMenu(gfx::Point(), ui::MENU_SOURCE_MOUSE);
EXPECT_FALSE(button->state() & LauncherButton::STATE_HOVERED);
// Remove it.
diff --git a/ash/launcher/launcher_view.cc b/ash/launcher/launcher_view.cc
index 0d1f898..70292f2 100644
--- a/ash/launcher/launcher_view.cc
+++ b/ash/launcher/launcher_view.cc
@@ -1498,14 +1498,14 @@ void LauncherView::ButtonPressed(views::Button* sender,
}
if (model_->items()[view_index].type != TYPE_APP_LIST)
- ShowListMenuForView(model_->items()[view_index], sender, event.flags());
+ ShowListMenuForView(model_->items()[view_index], sender, event);
}
bool LauncherView::ShowListMenuForView(const LauncherItem& item,
views::View* source,
- int event_flags) {
+ const ui::Event& event) {
scoped_ptr<ash::LauncherMenuModel> menu_model;
- menu_model.reset(delegate_->CreateApplicationMenu(item, event_flags));
+ menu_model.reset(delegate_->CreateApplicationMenu(item, event.flags()));
// Make sure we have a menu and it has at least two items in addition to the
// application title and the 3 spacing separators.
@@ -1516,12 +1516,14 @@ bool LauncherView::ShowListMenuForView(const LauncherItem& item,
new LauncherMenuModelAdapter(menu_model.get())),
source,
gfx::Point(),
- false);
+ false,
+ ui::GetMenuSourceTypeForEvent(event));
return true;
}
void LauncherView::ShowContextMenuForView(views::View* source,
- const gfx::Point& point) {
+ const gfx::Point& point,
+ ui:: MenuSourceType source_type) {
int view_index = view_model_->GetIndexOfView(source);
if (view_index != -1 &&
model_->items()[view_index].type == TYPE_APP_LIST) {
@@ -1531,7 +1533,7 @@ void LauncherView::ShowContextMenuForView(views::View* source,
tooltip_->Close();
if (view_index == -1) {
- Shell::GetInstance()->ShowContextMenu(point);
+ Shell::GetInstance()->ShowContextMenu(point, source_type);
return;
}
scoped_ptr<ui::MenuModel> menu_model(delegate_->CreateContextMenu(
@@ -1547,14 +1549,16 @@ void LauncherView::ShowContextMenuForView(views::View* source,
new views::MenuModelAdapter(menu_model.get())),
source,
point,
- true);
+ true,
+ source_type);
}
void LauncherView::ShowMenu(
scoped_ptr<views::MenuModelAdapter> menu_model_adapter,
views::View* source,
const gfx::Point& click_point,
- bool context_menu) {
+ bool context_menu,
+ ui::MenuSourceType source_type) {
closing_event_time_ = base::TimeDelta();
launcher_menu_runner_.reset(
new views::MenuRunner(menu_model_adapter->CreateMenu()));
@@ -1612,7 +1616,9 @@ void LauncherView::ShowMenu(
NULL,
anchor_point,
menu_alignment,
- views::MenuRunner::CONTEXT_MENU) == views::MenuRunner::MENU_DELETED) {
+ source_type,
+ context_menu ? views::MenuRunner::CONTEXT_MENU : 0) ==
+ views::MenuRunner::MENU_DELETED) {
if (!got_deleted) {
got_deleted_ = NULL;
shelf->ForceUndimming(false);
diff --git a/ash/launcher/launcher_view.h b/ash/launcher/launcher_view.h
index 0bee1c9..aa59f1e 100644
--- a/ash/launcher/launcher_view.h
+++ b/ash/launcher/launcher_view.h
@@ -243,11 +243,12 @@ class ASH_EXPORT LauncherView : public views::View,
// The |event_flags| are the flags of the event which triggered this menu.
bool ShowListMenuForView(const LauncherItem& item,
views::View* source,
- int event_flags);
+ const ui::Event& event);
// Overridden from views::ContextMenuController:
virtual void ShowContextMenuForView(views::View* source,
- const gfx::Point& point) OVERRIDE;
+ const gfx::Point& point,
+ ui::MenuSourceType source_type) OVERRIDE;
// Show either a context or normal click menu of given |menu_model_adapter|.
// If |context_menu| is set, the displayed menu is a context menu and not
@@ -256,7 +257,8 @@ class ASH_EXPORT LauncherView : public views::View,
void ShowMenu(scoped_ptr<views::MenuModelAdapter> menu_model_adapter,
views::View* source,
const gfx::Point& click_point,
- bool context_menu);
+ bool context_menu,
+ ui::MenuSourceType source_type);
// Overridden from views::BoundsAnimatorObserver:
virtual void OnBoundsAnimatorProgressed(
diff --git a/ash/root_window_controller.cc b/ash/root_window_controller.cc
index 8e1d400..af6e946 100644
--- a/ash/root_window_controller.cc
+++ b/ash/root_window_controller.cc
@@ -426,8 +426,8 @@ SystemTray* RootWindowController::GetSystemTray() {
return shelf_->status_area_widget()->system_tray();
}
-void RootWindowController::ShowContextMenu(
- const gfx::Point& location_in_screen) {
+void RootWindowController::ShowContextMenu(const gfx::Point& location_in_screen,
+ ui::MenuSourceType source_type) {
DCHECK(Shell::GetInstance()->delegate());
scoped_ptr<ui::MenuModel> menu_model(
Shell::GetInstance()->delegate()->CreateContextMenu(root_window()));
@@ -444,7 +444,8 @@ void RootWindowController::ShowContextMenu(
views::MenuRunner menu_runner(menu_model.get());
if (menu_runner.RunMenuAt(background->widget(),
NULL, gfx::Rect(location_in_screen, gfx::Size()),
- views::MenuItemView::TOPLEFT, views::MenuRunner::CONTEXT_MENU) ==
+ views::MenuItemView::TOPLEFT, source_type,
+ views::MenuRunner::CONTEXT_MENU) ==
views::MenuRunner::MENU_DELETED) {
return;
}
diff --git a/ash/root_window_controller.h b/ash/root_window_controller.h
index 79c5f5e..2c02b20 100644
--- a/ash/root_window_controller.h
+++ b/ash/root_window_controller.h
@@ -10,6 +10,7 @@
#include "ash/system/user/login_status.h"
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
+#include "ui/base/ui_base_types.h"
class SkBitmap;
@@ -108,7 +109,8 @@ class ASH_EXPORT RootWindowController {
// Shows context menu at the |location_in_screen|. This uses
// |ShellDelegate::CreateContextMenu| to define the content of the menu.
- void ShowContextMenu(const gfx::Point& location_in_screen);
+ void ShowContextMenu(const gfx::Point& location_in_screen,
+ ui::MenuSourceType source_type);
// Returns the layout-manager for the appropriate modal-container. If the
// window is inside the lockscreen modal container, then the layout manager
diff --git a/ash/shell.cc b/ash/shell.cc
index 1cc177f..1bda4db 100644
--- a/ash/shell.cc
+++ b/ash/shell.cc
@@ -621,7 +621,8 @@ void Shell::Init() {
}
}
-void Shell::ShowContextMenu(const gfx::Point& location_in_screen) {
+void Shell::ShowContextMenu(const gfx::Point& location_in_screen,
+ ui::MenuSourceType source_type) {
// No context menus if there is no session with an active user.
if (!session_state_delegate_->NumberOfLoggedInUsers())
return;
@@ -639,7 +640,7 @@ void Shell::ShowContextMenu(const gfx::Point& location_in_screen) {
CHECK(rwc) << "root=" << root
<< ", location:" << location_in_screen.ToString();
if (rwc)
- rwc->ShowContextMenu(location_in_screen);
+ rwc->ShowContextMenu(location_in_screen, source_type);
}
void Shell::ToggleAppList(aura::Window* window) {
diff --git a/ash/shell.h b/ash/shell.h
index a420293..f8649dc 100644
--- a/ash/shell.h
+++ b/ash/shell.h
@@ -19,6 +19,7 @@
#include "base/observer_list.h"
#include "ui/aura/client/activation_change_observer.h"
#include "ui/base/events/event_target.h"
+#include "ui/base/ui_base_types.h"
#include "ui/gfx/insets.h"
#include "ui/gfx/screen.h"
#include "ui/gfx/size.h"
@@ -211,7 +212,8 @@ class ASH_EXPORT Shell
// Shows the context menu for the background and launcher at
// |location_in_screen| (in screen coordinates).
- void ShowContextMenu(const gfx::Point& location_in_screen);
+ void ShowContextMenu(const gfx::Point& location_in_screen,
+ ui::MenuSourceType source_type);
// Toggles the app list. |window| specifies in which display the app
// list should be shown. If this is NULL, the active root window
diff --git a/ash/shell/window_type_launcher.cc b/ash/shell/window_type_launcher.cc
index f87250d..4bfe453 100644
--- a/ash/shell/window_type_launcher.cc
+++ b/ash/shell/window_type_launcher.cc
@@ -388,8 +388,10 @@ void WindowTypeLauncher::ExecuteCommand(int id, int event_flags) {
#endif // !defined(OS_MACOSX)
#if !defined(OS_MACOSX)
-void WindowTypeLauncher::ShowContextMenuForView(views::View* source,
- const gfx::Point& point) {
+void WindowTypeLauncher::ShowContextMenuForView(
+ views::View* source,
+ const gfx::Point& point,
+ ui::MenuSourceType source_type) {
MenuItemView* root = new MenuItemView(this);
root->AppendMenuItem(COMMAND_NEW_WINDOW,
ASCIIToUTF16("New Window"),
@@ -399,8 +401,10 @@ void WindowTypeLauncher::ShowContextMenuForView(views::View* source,
MenuItemView::NORMAL);
// MenuRunner takes ownership of root.
menu_runner_.reset(new MenuRunner(root));
- if (menu_runner_->RunMenuAt(GetWidget(), NULL, gfx::Rect(point, gfx::Size()),
+ if (menu_runner_->RunMenuAt(GetWidget(), NULL,
+ gfx::Rect(point, gfx::Size()),
MenuItemView::TOPLEFT,
+ source_type,
MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU) ==
MenuRunner::MENU_DELETED)
return;
diff --git a/ash/shell/window_type_launcher.h b/ash/shell/window_type_launcher.h
index de2159e..29d703d 100644
--- a/ash/shell/window_type_launcher.h
+++ b/ash/shell/window_type_launcher.h
@@ -61,7 +61,8 @@ class WindowTypeLauncher : public views::WidgetDelegateView,
// Override from views::ContextMenuController:
virtual void ShowContextMenuForView(views::View* source,
- const gfx::Point& point) OVERRIDE;
+ const gfx::Point& point,
+ ui::MenuSourceType source_type) OVERRIDE;
#endif // !defined(OS_MACOSX)
views::LabelButton* create_button_;
diff --git a/ash/system/web_notification/web_notification_tray.cc b/ash/system/web_notification/web_notification_tray.cc
index c428bea..9579442 100644
--- a/ash/system/web_notification/web_notification_tray.cc
+++ b/ash/system/web_notification/web_notification_tray.cc
@@ -302,7 +302,7 @@ bool WebNotificationTray::ShouldShowMessageCenter() {
status_area_widget()->system_tray()->HasNotificationBubble());
}
-void WebNotificationTray::ShowQuietModeMenu() {
+void WebNotificationTray::ShowQuietModeMenu(const ui::Event& event) {
base::AutoReset<bool> reset(&should_block_shelf_auto_hide_, true);
scoped_ptr<ui::MenuModel> menu_model(
message_center_tray_->CreateQuietModeMenu());
@@ -314,6 +314,7 @@ void WebNotificationTray::ShowQuietModeMenu() {
NULL,
gfx::Rect(point, bounds().size()),
views::MenuItemView::BUBBLE_ABOVE,
+ ui::GetMenuSourceTypeForEvent(event),
views::MenuRunner::HAS_MNEMONICS) == views::MenuRunner::MENU_DELETED)
return;
@@ -410,7 +411,7 @@ void WebNotificationTray::HideBubbleWithView(
bool WebNotificationTray::PerformAction(const ui::Event& event) {
if (ShouldShowQuietModeMenu(event)) {
- ShowQuietModeMenu();
+ ShowQuietModeMenu(event);
return true;
}
diff --git a/ash/system/web_notification/web_notification_tray.h b/ash/system/web_notification/web_notification_tray.h
index 8b3aff8..df7a663 100644
--- a/ash/system/web_notification/web_notification_tray.h
+++ b/ash/system/web_notification/web_notification_tray.h
@@ -126,7 +126,7 @@ class ASH_EXPORT WebNotificationTray
bool ShouldShowQuietModeMenu(const ui::Event& event);
// Shows the quiet mode menu.
- void ShowQuietModeMenu();
+ void ShowQuietModeMenu(const ui::Event& event);
internal::WebNotificationBubbleWrapper* message_center_bubble() const {
return message_center_bubble_.get();
diff --git a/chrome/browser/chromeos/login/language_switch_menu.cc b/chrome/browser/chromeos/login/language_switch_menu.cc
index d4b73c2..d4dab0f 100644
--- a/chrome/browser/chromeos/login/language_switch_menu.cc
+++ b/chrome/browser/chromeos/login/language_switch_menu.cc
@@ -184,7 +184,8 @@ void LanguageSwitchMenu::OnMenuButtonClicked(views::View* source,
if (menu_runner_->RunMenuAt(button->GetWidget(), button,
gfx::Rect(new_pt, gfx::Size()), views::MenuItemView::TOPLEFT,
- views::MenuRunner::HAS_MNEMONICS) == views::MenuRunner::MENU_DELETED)
+ ui::MENU_SOURCE_NONE, views::MenuRunner::HAS_MNEMONICS) ==
+ views::MenuRunner::MENU_DELETED)
return;
}
diff --git a/chrome/browser/ui/views/action_box_context_menu.cc b/chrome/browser/ui/views/action_box_context_menu.cc
index 2747fa7..2beac0b 100644
--- a/chrome/browser/ui/views/action_box_context_menu.cc
+++ b/chrome/browser/ui/views/action_box_context_menu.cc
@@ -23,7 +23,8 @@ ActionBoxContextMenu::~ActionBoxContextMenu() {
views::MenuRunner::RunResult ActionBoxContextMenu::RunMenuAt(
const gfx::Point& p,
- views::Widget* parent_widget) {
+ views::Widget* parent_widget,
+ ui::MenuSourceType source_type) {
adapter_.reset(new views::MenuModelAdapter(controller_.menu_model()));
menu_runner_.reset(new MenuRunner(adapter_->CreateMenu()));
return menu_runner_->RunMenuAt(
@@ -31,6 +32,7 @@ views::MenuRunner::RunResult ActionBoxContextMenu::RunMenuAt(
NULL, // No menu button.
gfx::Rect(p, gfx::Size()),
views::MenuItemView::TOPLEFT,
+ source_type,
(MenuRunner::CONTEXT_MENU | MenuRunner::IS_NESTED |
MenuRunner::HAS_MNEMONICS));
}
diff --git a/chrome/browser/ui/views/action_box_context_menu.h b/chrome/browser/ui/views/action_box_context_menu.h
index f4a3f8c..605f40b 100644
--- a/chrome/browser/ui/views/action_box_context_menu.h
+++ b/chrome/browser/ui/views/action_box_context_menu.h
@@ -38,7 +38,8 @@ class ActionBoxContextMenu {
// See comments in menu_runner.h on how the return value should be used.
views::MenuRunner::RunResult RunMenuAt(
const gfx::Point& p,
- views::Widget* parent_widget) WARN_UNUSED_RESULT;
+ views::Widget* parent_widget,
+ ui::MenuSourceType source_type) WARN_UNUSED_RESULT;
private:
ActionBoxContextMenuController controller_;
diff --git a/chrome/browser/ui/views/action_box_menu.cc b/chrome/browser/ui/views/action_box_menu.cc
index 8ef3d82..d6a7ecd 100644
--- a/chrome/browser/ui/views/action_box_menu.cc
+++ b/chrome/browser/ui/views/action_box_menu.cc
@@ -71,6 +71,7 @@ void ActionBoxMenu::RunMenu(views::MenuButton* menu_button,
menu_button,
gfx::Rect(menu_offset, menu_button->size()),
views::MenuItemView::TOPRIGHT,
+ ui::MENU_SOURCE_NONE,
views::MenuRunner::HAS_MNEMONICS));
}
@@ -92,7 +93,7 @@ void ActionBoxMenu::ExecuteCommand(int id) {
bool ActionBoxMenu::ShowContextMenu(views::MenuItemView* source,
int id,
const gfx::Point& p,
- bool is_mouse_gesture) {
+ ui::MenuSourceType source_type) {
DCHECK(menu_parent_);
int index = model_->GetIndexOfCommandId(id);
@@ -101,7 +102,7 @@ bool ActionBoxMenu::ShowContextMenu(views::MenuItemView* source,
context_menu_.reset(
new ActionBoxContextMenu(browser_, model_->GetExtensionAt(index)));
- if (context_menu_->RunMenuAt(p, menu_parent_) ==
+ if (context_menu_->RunMenuAt(p, menu_parent_, source_type) ==
views::MenuRunner::MENU_DELETED)
return true;
context_menu_.reset();
diff --git a/chrome/browser/ui/views/action_box_menu.h b/chrome/browser/ui/views/action_box_menu.h
index 2cd442d..3248013 100644
--- a/chrome/browser/ui/views/action_box_menu.h
+++ b/chrome/browser/ui/views/action_box_menu.h
@@ -38,7 +38,7 @@ class ActionBoxMenu : public views::MenuDelegate {
virtual bool ShowContextMenu(views::MenuItemView* source,
int id,
const gfx::Point& p,
- bool is_mouse_gesture) OVERRIDE;
+ ui::MenuSourceType source_type) OVERRIDE;
// Populates |root_| with all the child menu items from the |model_|.
void PopulateMenu();
diff --git a/chrome/browser/ui/views/autofill/autofill_dialog_views.cc b/chrome/browser/ui/views/autofill/autofill_dialog_views.cc
index 92d084b..32dff53 100644
--- a/chrome/browser/ui/views/autofill/autofill_dialog_views.cc
+++ b/chrome/browser/ui/views/autofill/autofill_dialog_views.cc
@@ -547,6 +547,7 @@ void AutofillDialogViews::AccountChooser::OnMouseReleased(
NULL,
GetBoundsInScreen(),
views::MenuItemView::TOPRIGHT,
+ ui::MENU_SOURCE_MOUSE,
0));
}
@@ -1300,6 +1301,7 @@ void AutofillDialogViews::ButtonPressed(views::Button* sender,
NULL,
bounds,
views::MenuItemView::TOPRIGHT,
+ ui::GetMenuSourceTypeForEvent(event),
0));
group->container->SetActive(false);
group->suggested_button->SetState(state);
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_instructions_view.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_instructions_view.cc
index 26a1053..4c49679 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_bar_instructions_view.cc
+++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_instructions_view.cc
@@ -109,7 +109,8 @@ void BookmarkBarInstructionsView::LinkClicked(views::Link* source,
void BookmarkBarInstructionsView::ShowContextMenuForView(
views::View* source,
- const gfx::Point& point) {
+ const gfx::Point& point,
+ ui::MenuSourceType source_type) {
// Do nothing here, we don't want to show the Bookmarks context menu when
// the user right clicks on the "Import bookmarks now" link.
}
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_instructions_view.h b/chrome/browser/ui/views/bookmarks/bookmark_bar_instructions_view.h
index 7fa0466..f9a8804 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_bar_instructions_view.h
+++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_instructions_view.h
@@ -45,7 +45,8 @@ class BookmarkBarInstructionsView : public views::View,
private:
virtual void ShowContextMenuForView(views::View* source,
- const gfx::Point& point) OVERRIDE;
+ const gfx::Point& point,
+ ui::MenuSourceType source_type) OVERRIDE;
void UpdateColors();
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc
index 9190910..fce68ef 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc
+++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc
@@ -908,11 +908,6 @@ int BookmarkBarView::OnPerformDrop(const DropTargetEvent& event) {
return chrome::DropBookmarks(browser_->profile(), data, parent_node, index);
}
-void BookmarkBarView::ShowContextMenu(const gfx::Point& p,
- bool is_mouse_gesture) {
- ShowContextMenuForView(this, p);
-}
-
void BookmarkBarView::OnThemeChanged() {
UpdateColors();
}
@@ -1214,7 +1209,8 @@ void BookmarkBarView::ButtonPressed(views::Button* sender,
}
void BookmarkBarView::ShowContextMenuForView(views::View* source,
- const gfx::Point& point) {
+ const gfx::Point& point,
+ ui::MenuSourceType source_type) {
if (!model_->loaded()) {
// Don't do anything if the model isn't loaded.
return;
@@ -1250,7 +1246,7 @@ void BookmarkBarView::ShowContextMenuForView(views::View* source,
GetWidget(), browser_, profile,
browser_->tab_strip_model()->GetActiveWebContents(),
parent, nodes, close_on_remove));
- context_menu_->RunMenuAt(point);
+ context_menu_->RunMenuAt(point, source_type);
}
void BookmarkBarView::Init() {
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.h b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.h
index dfb6087..5768fc0 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.h
+++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.h
@@ -180,8 +180,6 @@ class BookmarkBarView : public DetachableToolbarView,
virtual int OnDragUpdated(const ui::DropTargetEvent& event) OVERRIDE;
virtual void OnDragExited() OVERRIDE;
virtual int OnPerformDrop(const ui::DropTargetEvent& event) OVERRIDE;
- virtual void ShowContextMenu(const gfx::Point& p,
- bool is_mouse_gesture) OVERRIDE;
virtual void OnThemeChanged() OVERRIDE;
virtual const char* GetClassName() const OVERRIDE;
@@ -246,7 +244,8 @@ class BookmarkBarView : public DetachableToolbarView,
// views::ContextMenuController:
virtual void ShowContextMenuForView(views::View* source,
- const gfx::Point& point) OVERRIDE;
+ const gfx::Point& point,
+ ui::MenuSourceType source_type) OVERRIDE;
private:
class ButtonSeparatorView;
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_context_menu.cc b/chrome/browser/ui/views/bookmarks/bookmark_context_menu.cc
index b2b93e8..ca4a844 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_context_menu.cc
+++ b/chrome/browser/ui/views/bookmarks/bookmark_context_menu.cc
@@ -59,7 +59,8 @@ BookmarkContextMenu::BookmarkContextMenu(
BookmarkContextMenu::~BookmarkContextMenu() {
}
-void BookmarkContextMenu::RunMenuAt(const gfx::Point& point) {
+void BookmarkContextMenu::RunMenuAt(const gfx::Point& point,
+ ui::MenuSourceType source_type) {
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_BOOKMARK_CONTEXT_MENU_SHOWN,
content::Source<BookmarkContextMenu>(this),
@@ -67,7 +68,7 @@ void BookmarkContextMenu::RunMenuAt(const gfx::Point& point) {
// width/height don't matter here.
if (menu_runner_->RunMenuAt(
parent_widget_, NULL, gfx::Rect(point.x(), point.y(), 0, 0),
- views::MenuItemView::TOPLEFT,
+ views::MenuItemView::TOPLEFT, source_type,
(views::MenuRunner::HAS_MNEMONICS | views::MenuRunner::IS_NESTED |
views::MenuRunner::CONTEXT_MENU)) ==
views::MenuRunner::MENU_DELETED)
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_context_menu.h b/chrome/browser/ui/views/bookmarks/bookmark_context_menu.h
index 5f6a97b..eba85f6 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_context_menu.h
+++ b/chrome/browser/ui/views/bookmarks/bookmark_context_menu.h
@@ -45,7 +45,8 @@ class BookmarkContextMenu : public BookmarkContextMenuControllerDelegate,
virtual ~BookmarkContextMenu();
// Shows the context menu at the specified point.
- void RunMenuAt(const gfx::Point& point);
+ void RunMenuAt(const gfx::Point& point,
+ ui::MenuSourceType source_type);
views::MenuItemView* menu() const { return menu_; }
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_editor_view.cc b/chrome/browser/ui/views/bookmarks/bookmark_editor_view.cc
index 281436a..56be739 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_editor_view.cc
+++ b/chrome/browser/ui/views/bookmarks/bookmark_editor_view.cc
@@ -234,8 +234,10 @@ void BookmarkEditorView::Close() {
GetWidget()->Close();
}
-void BookmarkEditorView::ShowContextMenuForView(views::View* source,
- const gfx::Point& point) {
+void BookmarkEditorView::ShowContextMenuForView(
+ views::View* source,
+ const gfx::Point& point,
+ ui::MenuSourceType source_type) {
DCHECK_EQ(tree_view_, source);
if (!tree_view_->GetSelectedNode())
return;
@@ -247,6 +249,7 @@ void BookmarkEditorView::ShowContextMenuForView(views::View* source,
if (context_menu_runner_->RunMenuAt(source->GetWidget()->GetTopLevelWidget(),
NULL, gfx::Rect(point, gfx::Size()), views::MenuItemView::TOPRIGHT,
+ source_type,
views::MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU) ==
views::MenuRunner::MENU_DELETED)
return;
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_editor_view.h b/chrome/browser/ui/views/bookmarks/bookmark_editor_view.h
index 57a9fbb..b11f00d 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_editor_view.h
+++ b/chrome/browser/ui/views/bookmarks/bookmark_editor_view.h
@@ -121,7 +121,8 @@ class BookmarkEditorView : public BookmarkEditor,
// views::ContextMenuController:
virtual void ShowContextMenuForView(views::View* source,
- const gfx::Point& point) OVERRIDE;
+ const gfx::Point& point,
+ ui::MenuSourceType source_type) OVERRIDE;
private:
friend class BookmarkEditorViewTest;
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_menu_controller_views.cc b/chrome/browser/ui/views/bookmarks/bookmark_menu_controller_views.cc
index 829551a..5c2a41c 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_menu_controller_views.cc
+++ b/chrome/browser/ui/views/bookmarks/bookmark_menu_controller_views.cc
@@ -65,7 +65,8 @@ void BookmarkMenuController::RunMenuAt(BookmarkBarView* bookmark_bar,
// We only delete ourself after the menu completes, so we can safely ignore
// the return value.
ignore_result(menu_runner_->RunMenuAt(menu_delegate_->parent(), menu_button,
- bounds, anchor, for_drop ? views::MenuRunner::FOR_DROP : 0));
+ bounds, anchor, ui::MENU_SOURCE_NONE,
+ for_drop ? views::MenuRunner::FOR_DROP : 0));
if (!for_drop)
delete this;
}
@@ -140,8 +141,8 @@ int BookmarkMenuController::OnPerformDrop(MenuItemView* menu,
bool BookmarkMenuController::ShowContextMenu(MenuItemView* source,
int id,
const gfx::Point& p,
- bool is_mouse_gesture) {
- return menu_delegate_->ShowContextMenu(source, id, p, is_mouse_gesture);
+ ui::MenuSourceType source_type) {
+ return menu_delegate_->ShowContextMenu(source, id, p, source_type);
}
void BookmarkMenuController::DropMenuClosed(MenuItemView* menu) {
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_menu_controller_views.h b/chrome/browser/ui/views/bookmarks/bookmark_menu_controller_views.h
index 1cfdacb..269738b 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_menu_controller_views.h
+++ b/chrome/browser/ui/views/bookmarks/bookmark_menu_controller_views.h
@@ -99,7 +99,7 @@ class BookmarkMenuController : public BaseBookmarkModelObserver,
virtual bool ShowContextMenu(views::MenuItemView* source,
int id,
const gfx::Point& p,
- bool is_mouse_gesture) OVERRIDE;
+ ui::MenuSourceType source_type) OVERRIDE;
virtual void DropMenuClosed(views::MenuItemView* menu) OVERRIDE;
virtual bool CanDrag(views::MenuItemView* menu) OVERRIDE;
virtual void WriteDragData(views::MenuItemView* sender,
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.cc b/chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.cc
index 2845048..afd0b9f 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.cc
+++ b/chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.cc
@@ -273,7 +273,7 @@ int BookmarkMenuDelegate::OnPerformDrop(
bool BookmarkMenuDelegate::ShowContextMenu(MenuItemView* source,
int id,
const gfx::Point& p,
- bool is_mouse_gesture) {
+ ui::MenuSourceType source_type) {
DCHECK(menu_id_to_node_map_.find(id) != menu_id_to_node_map_.end());
std::vector<const BookmarkNode*> nodes;
nodes.push_back(menu_id_to_node_map_[id]);
@@ -291,7 +291,7 @@ bool BookmarkMenuDelegate::ShowContextMenu(MenuItemView* source,
nodes,
close_on_delete));
context_menu_->set_observer(this);
- context_menu_->RunMenuAt(p);
+ context_menu_->RunMenuAt(p, source_type);
context_menu_.reset(NULL);
return true;
}
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.h b/chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.h
index 573e6dd..6e36d04 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.h
+++ b/chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.h
@@ -113,7 +113,7 @@ class BookmarkMenuDelegate : public BaseBookmarkModelObserver,
bool ShowContextMenu(views::MenuItemView* source,
int id,
const gfx::Point& p,
- bool is_mouse_gesture);
+ ui::MenuSourceType source_type);
bool CanDrag(views::MenuItemView* menu);
void WriteDragData(views::MenuItemView* sender, ui::OSExchangeData* data);
int GetDragOperations(views::MenuItemView* sender);
diff --git a/chrome/browser/ui/views/browser_action_view.cc b/chrome/browser/ui/views/browser_action_view.cc
index 73db0f0..3f43bb9 100644
--- a/chrome/browser/ui/views/browser_action_view.cc
+++ b/chrome/browser/ui/views/browser_action_view.cc
@@ -175,8 +175,10 @@ void BrowserActionButton::ButtonPressed(views::Button* sender,
delegate_->OnBrowserActionExecuted(this);
}
-void BrowserActionButton::ShowContextMenuForView(View* source,
- const gfx::Point& point) {
+void BrowserActionButton::ShowContextMenuForView(
+ View* source,
+ const gfx::Point& point,
+ ui::MenuSourceType source_type) {
if (!extension()->ShowConfigureContextMenus())
return;
@@ -191,8 +193,8 @@ void BrowserActionButton::ShowContextMenuForView(View* source,
gfx::Point screen_loc;
views::View::ConvertPointToScreen(this, &screen_loc);
if (menu_runner_->RunMenuAt(GetWidget(), NULL, gfx::Rect(screen_loc, size()),
- views::MenuItemView::TOPLEFT, views::MenuRunner::HAS_MNEMONICS |
- views::MenuRunner::CONTEXT_MENU) ==
+ views::MenuItemView::TOPLEFT, source_type,
+ views::MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU) ==
views::MenuRunner::MENU_DELETED) {
return;
}
@@ -316,7 +318,7 @@ bool BrowserActionButton::OnMousePressed(const ui::MouseEvent& event) {
// See comments in MenuButton::Activate() as to why this is needed.
SetMouseHandler(NULL);
- ShowContextMenu(gfx::Point(), true);
+ ShowContextMenu(gfx::Point(), ui::MENU_SOURCE_MOUSE);
}
return false;
}
diff --git a/chrome/browser/ui/views/browser_action_view.h b/chrome/browser/ui/views/browser_action_view.h
index 23c86f3..1b4e8e2 100644
--- a/chrome/browser/ui/views/browser_action_view.h
+++ b/chrome/browser/ui/views/browser_action_view.h
@@ -138,7 +138,8 @@ class BrowserActionButton : public views::MenuButton,
// Overridden from views::ContextMenuController.
virtual void ShowContextMenuForView(View* source,
- const gfx::Point& point) OVERRIDE;
+ const gfx::Point& point,
+ ui::MenuSourceType source_type) OVERRIDE;
// Overridden from content::NotificationObserver:
virtual void Observe(int type,
diff --git a/chrome/browser/ui/views/content_setting_bubble_contents.cc b/chrome/browser/ui/views/content_setting_bubble_contents.cc
index c39d9ba..f6f30bb 100644
--- a/chrome/browser/ui/views/content_setting_bubble_contents.cc
+++ b/chrome/browser/ui/views/content_setting_bubble_contents.cc
@@ -55,7 +55,7 @@ const int kMinMultiLineContentsWidth = 250;
// The minimum width of the media menu buttons.
const int kMinMediaMenuButtonWidth = 100;
-}
+} // namespace
using content::PluginService;
using content::WebContents;
@@ -464,6 +464,7 @@ void ContentSettingBubbleContents::OnMenuButtonClicked(
i->first,
gfx::Rect(screen_location, i->first->size()),
views::MenuItemView::TOPLEFT,
+ ui::MENU_SOURCE_NONE,
views::MenuRunner::HAS_MNEMONICS));
}
diff --git a/chrome/browser/ui/views/download/download_item_view.cc b/chrome/browser/ui/views/download/download_item_view.cc
index 032d83c..4977edf 100644
--- a/chrome/browser/ui/views/download/download_item_view.cc
+++ b/chrome/browser/ui/views/download/download_item_view.cc
@@ -517,11 +517,12 @@ void DownloadItemView::OnGestureEvent(ui::GestureEvent* event) {
}
void DownloadItemView::ShowContextMenuForView(View* source,
- const gfx::Point& point) {
+ const gfx::Point& point,
+ ui::MenuSourceType source_type) {
// |point| is in screen coordinates. So convert it to local coordinates first.
gfx::Point local_point = point;
ConvertPointFromScreen(this, &local_point);
- ShowContextMenuImpl(local_point, true);
+ ShowContextMenuImpl(local_point, source_type);
}
void DownloadItemView::ButtonPressed(
@@ -889,7 +890,7 @@ void DownloadItemView::UpdateColorsFromTheme() {
}
void DownloadItemView::ShowContextMenuImpl(const gfx::Point& p,
- bool is_mouse_gesture) {
+ ui::MenuSourceType source_type) {
gfx::Point point = p;
gfx::Size size;
@@ -906,7 +907,7 @@ void DownloadItemView::ShowContextMenuImpl(const gfx::Point& p,
// If |is_mouse_gesture| is false, |p| is ignored. The menu is shown aligned
// to drop down arrow button.
- if (!is_mouse_gesture) {
+ if (!source_type == ui::MENU_SOURCE_MOUSE) {
drop_down_pressed_ = true;
SetState(NORMAL, PUSHED);
point.SetPoint(drop_down_x_left_, box_y_);
@@ -926,7 +927,7 @@ void DownloadItemView::ShowContextMenuImpl(const gfx::Point& p,
new DownloadShelfContextMenuView(download(), shelf_->GetNavigator()));
}
context_menu_->Run(GetWidget()->GetTopLevelWidget(),
- gfx::Rect(point, size));
+ gfx::Rect(point, size), source_type);
// We could be deleted now.
}
@@ -948,7 +949,7 @@ void DownloadItemView::HandlePressEvent(const ui::LocatedEvent& event,
// so that the positioning of the context menu will be similar to a
// keyboard invocation. I.e. we want the menu to always be positioned
// next to the drop down button instead of the next to the pointer.
- ShowContextMenuImpl(event.location(), false);
+ ShowContextMenuImpl(event.location(), ui::MENU_SOURCE_KEYBOARD);
// Once called, it is possible that *this was deleted (e.g.: due to
// invoking the 'Discard' action.)
} else if (!IsShowingWarningDialog()) {
diff --git a/chrome/browser/ui/views/download/download_item_view.h b/chrome/browser/ui/views/download/download_item_view.h
index 1c64923..ac672a5 100644
--- a/chrome/browser/ui/views/download/download_item_view.h
+++ b/chrome/browser/ui/views/download/download_item_view.h
@@ -98,7 +98,8 @@ class DownloadItemView : public views::ButtonListener,
// Overridden from views::ContextMenuController.
virtual void ShowContextMenuForView(View* source,
- const gfx::Point& point) OVERRIDE;
+ const gfx::Point& point,
+ ui::MenuSourceType source_type) OVERRIDE;
// ButtonListener implementation.
virtual void ButtonPressed(views::Button* sender,
@@ -159,7 +160,8 @@ class DownloadItemView : public views::ButtonListener,
// Shows the context menu at the specified location. |point| is in the view's
// coordinate system.
- void ShowContextMenuImpl(const gfx::Point& point, bool is_mouse_gesture);
+ void ShowContextMenuImpl(const gfx::Point& point,
+ ui::MenuSourceType source_type);
// Common code for handling pointer events (i.e. mouse or gesture).
void HandlePressEvent(const ui::LocatedEvent& event, bool active_event);
diff --git a/chrome/browser/ui/views/download/download_shelf_context_menu_view.cc b/chrome/browser/ui/views/download/download_shelf_context_menu_view.cc
index b5bed6e..75ab4df 100644
--- a/chrome/browser/ui/views/download/download_shelf_context_menu_view.cc
+++ b/chrome/browser/ui/views/download/download_shelf_context_menu_view.cc
@@ -22,7 +22,8 @@ DownloadShelfContextMenuView::DownloadShelfContextMenuView(
DownloadShelfContextMenuView::~DownloadShelfContextMenuView() {}
void DownloadShelfContextMenuView::Run(views::Widget* parent_widget,
- const gfx::Rect& rect) {
+ const gfx::Rect& rect,
+ ui::MenuSourceType source_type) {
ui::MenuModel* menu_model = GetMenuModel();
// Run() should not be getting called if the DownloadItem was destroyed.
DCHECK(menu_model);
@@ -45,5 +46,6 @@ void DownloadShelfContextMenuView::Run(views::Widget* parent_widget,
NULL,
rect,
position,
+ source_type,
views::MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU));
}
diff --git a/chrome/browser/ui/views/download/download_shelf_context_menu_view.h b/chrome/browser/ui/views/download/download_shelf_context_menu_view.h
index 916dc0a..aa411cd 100644
--- a/chrome/browser/ui/views/download/download_shelf_context_menu_view.h
+++ b/chrome/browser/ui/views/download/download_shelf_context_menu_view.h
@@ -9,6 +9,7 @@
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/download/download_shelf_context_menu.h"
+#include "ui/base/ui_base_types.h"
namespace content {
class DownloadItem;
@@ -32,7 +33,9 @@ class DownloadShelfContextMenuView : public DownloadShelfContextMenu {
// |rect| is the bounding area for positioning the menu in screen coordinates.
// The menu will be positioned above or below but not overlapping |rect|.
- void Run(views::Widget* parent_widget, const gfx::Rect& rect);
+ void Run(views::Widget* parent_widget,
+ const gfx::Rect& rect,
+ ui::MenuSourceType source_type);
private:
scoped_ptr<views::MenuRunner> menu_runner_;
diff --git a/chrome/browser/ui/views/extensions/browser_action_overflow_menu_controller.cc b/chrome/browser/ui/views/extensions/browser_action_overflow_menu_controller.cc
index f87c709..2551441 100644
--- a/chrome/browser/ui/views/extensions/browser_action_overflow_menu_controller.cc
+++ b/chrome/browser/ui/views/extensions/browser_action_overflow_menu_controller.cc
@@ -76,7 +76,7 @@ bool BrowserActionOverflowMenuController::RunMenu(views::Widget* window,
views::MenuItemView::AnchorPosition anchor = views::MenuItemView::TOPRIGHT;
// As we maintain our own lifetime we can safely ignore the result.
ignore_result(menu_runner_->RunMenuAt(window, menu_button_, bounds, anchor,
- for_drop_ ? views::MenuRunner::FOR_DROP : 0));
+ ui::MENU_SOURCE_NONE, for_drop_ ? views::MenuRunner::FOR_DROP : 0));
if (!for_drop_) {
// Give the context menu (if any) a chance to execute the user-selected
// command.
@@ -103,7 +103,7 @@ bool BrowserActionOverflowMenuController::ShowContextMenu(
views::MenuItemView* source,
int id,
const gfx::Point& p,
- bool is_mouse_gesture) {
+ ui::MenuSourceType source_type) {
const extensions::Extension* extension =
(*views_)[start_index_ + id - 1]->button()->extension();
if (!extension->ShowConfigureContextMenus())
@@ -117,6 +117,7 @@ bool BrowserActionOverflowMenuController::ShowContextMenu(
// This blocks until the user choses something or dismisses the menu.
ignore_result(context_menu_runner.RunMenuAt(menu_button_->GetWidget(),
NULL, gfx::Rect(p, gfx::Size()), views::MenuItemView::TOPLEFT,
+ source_type,
views::MenuRunner::HAS_MNEMONICS | views::MenuRunner::IS_NESTED |
views::MenuRunner::CONTEXT_MENU));
diff --git a/chrome/browser/ui/views/extensions/browser_action_overflow_menu_controller.h b/chrome/browser/ui/views/extensions/browser_action_overflow_menu_controller.h
index 33d8368..15964e4 100644
--- a/chrome/browser/ui/views/extensions/browser_action_overflow_menu_controller.h
+++ b/chrome/browser/ui/views/extensions/browser_action_overflow_menu_controller.h
@@ -54,7 +54,7 @@ class BrowserActionOverflowMenuController : public views::MenuDelegate {
virtual bool ShowContextMenu(views::MenuItemView* source,
int id,
const gfx::Point& p,
- bool is_mouse_gesture) OVERRIDE;
+ ui::MenuSourceType source_type) OVERRIDE;
virtual void DropMenuClosed(views::MenuItemView* menu) OVERRIDE;
// These drag functions offer support for dragging icons into the overflow
// menu.
diff --git a/chrome/browser/ui/views/frame/browser_frame.cc b/chrome/browser/ui/views/frame/browser_frame.cc
index 0ba3a25..23b2005 100644
--- a/chrome/browser/ui/views/frame/browser_frame.cc
+++ b/chrome/browser/ui/views/frame/browser_frame.cc
@@ -172,7 +172,8 @@ void BrowserFrame::OnNativeWidgetActivationChanged(bool active) {
}
void BrowserFrame::ShowContextMenuForView(views::View* source,
- const gfx::Point& p) {
+ const gfx::Point& p,
+ ui::MenuSourceType source_type) {
if (chrome::IsRunningInForcedAppMode())
return;
@@ -187,6 +188,7 @@ void BrowserFrame::ShowContextMenuForView(views::View* source,
menu_runner_.reset(new views::MenuRunner(GetSystemMenuModel()));
if (menu_runner_->RunMenuAt(source->GetWidget(), NULL,
gfx::Rect(p, gfx::Size(0,0)), views::MenuItemView::TOPLEFT,
+ source_type,
views::MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU) ==
views::MenuRunner::MENU_DELETED)
return;
diff --git a/chrome/browser/ui/views/frame/browser_frame.h b/chrome/browser/ui/views/frame/browser_frame.h
index b27dc2d..023e143 100644
--- a/chrome/browser/ui/views/frame/browser_frame.h
+++ b/chrome/browser/ui/views/frame/browser_frame.h
@@ -88,7 +88,8 @@ class BrowserFrame
// Overridden from views::ContextMenuController:
virtual void ShowContextMenuForView(views::View* source,
- const gfx::Point& p) OVERRIDE;
+ const gfx::Point& p,
+ ui::MenuSourceType source_type) OVERRIDE;
// Returns true if we should leave any offset at the frame caption. Typically
// when the frame is maximized/full screen we want to leave no offset at the
diff --git a/chrome/browser/ui/views/infobars/infobar_view.cc b/chrome/browser/ui/views/infobars/infobar_view.cc
index b241e46..1208c6a 100644
--- a/chrome/browser/ui/views/infobars/infobar_view.cc
+++ b/chrome/browser/ui/views/infobars/infobar_view.cc
@@ -310,7 +310,7 @@ void InfoBarView::RunMenuAt(ui::MenuModel* menu_model,
// Ignore the result since we don't need to handle a deleted menu specially.
ignore_result(menu_runner_->RunMenuAt(
GetWidget(), button, gfx::Rect(screen_point, button->size()), anchor,
- views::MenuRunner::HAS_MNEMONICS));
+ ui::MENU_SOURCE_NONE, views::MenuRunner::HAS_MNEMONICS));
}
void InfoBarView::PlatformSpecificShow(bool animate) {
diff --git a/chrome/browser/ui/views/location_bar/page_action_image_view.cc b/chrome/browser/ui/views/location_bar/page_action_image_view.cc
index cad5c54..ddb69b9 100644
--- a/chrome/browser/ui/views/location_bar/page_action_image_view.cc
+++ b/chrome/browser/ui/views/location_bar/page_action_image_view.cc
@@ -175,8 +175,10 @@ bool PageActionImageView::OnKeyPressed(const ui::KeyEvent& event) {
return false;
}
-void PageActionImageView::ShowContextMenuForView(View* source,
- const gfx::Point& point) {
+void PageActionImageView::ShowContextMenuForView(
+ View* source,
+ const gfx::Point& point,
+ ui::MenuSourceType source_type) {
const Extension* extension = owner_->profile()->GetExtensionService()->
GetExtensionById(page_action()->extension_id(), false);
if (!extension->ShowConfigureContextMenus())
@@ -188,8 +190,8 @@ void PageActionImageView::ShowContextMenuForView(View* source,
gfx::Point screen_loc;
views::View::ConvertPointToScreen(this, &screen_loc);
if (menu_runner_->RunMenuAt(GetWidget(), NULL, gfx::Rect(screen_loc, size()),
- views::MenuItemView::TOPLEFT, views::MenuRunner::HAS_MNEMONICS |
- views::MenuRunner::CONTEXT_MENU) ==
+ views::MenuItemView::TOPLEFT, source_type,
+ views::MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU) ==
views::MenuRunner::MENU_DELETED)
return;
}
diff --git a/chrome/browser/ui/views/location_bar/page_action_image_view.h b/chrome/browser/ui/views/location_bar/page_action_image_view.h
index 5234576..b35265b 100644
--- a/chrome/browser/ui/views/location_bar/page_action_image_view.h
+++ b/chrome/browser/ui/views/location_bar/page_action_image_view.h
@@ -63,7 +63,8 @@ class PageActionImageView : public views::ImageView,
// Overridden from views::ContextMenuController.
virtual void ShowContextMenuForView(View* source,
- const gfx::Point& point) OVERRIDE;
+ const gfx::Point& point,
+ ui::MenuSourceType source_type) OVERRIDE;
// Overriden from ExtensionActionIconFactory::Observer.
virtual void OnIconUpdated() OVERRIDE;
diff --git a/chrome/browser/ui/views/menu_item_view_test.cc b/chrome/browser/ui/views/menu_item_view_test.cc
index f9deb0f..2b182d9 100644
--- a/chrome/browser/ui/views/menu_item_view_test.cc
+++ b/chrome/browser/ui/views/menu_item_view_test.cc
@@ -81,6 +81,7 @@ class MenuItemViewTestBase : public ViewEventTestBase,
button_,
bounds,
views::MenuItemView::TOPLEFT,
+ ui::MENU_SOURCE_NONE,
views::MenuRunner::HAS_MNEMONICS));
}
diff --git a/chrome/browser/ui/views/menu_model_adapter_test.cc b/chrome/browser/ui/views/menu_model_adapter_test.cc
index dc1a72c..22c48ee 100644
--- a/chrome/browser/ui/views/menu_model_adapter_test.cc
+++ b/chrome/browser/ui/views/menu_model_adapter_test.cc
@@ -240,6 +240,7 @@ class MenuModelAdapterTest : public ViewEventTestBase,
button_,
bounds,
views::MenuItemView::TOPLEFT,
+ ui::MENU_SOURCE_NONE,
views::MenuRunner::HAS_MNEMONICS));
}
diff --git a/chrome/browser/ui/views/notifications/balloon_view_views.cc b/chrome/browser/ui/views/notifications/balloon_view_views.cc
index dc608c0..d6dc956 100644
--- a/chrome/browser/ui/views/notifications/balloon_view_views.cc
+++ b/chrome/browser/ui/views/notifications/balloon_view_views.cc
@@ -149,6 +149,7 @@ void BalloonViewImpl::OnMenuButtonClicked(views::View* source,
options_menu_button_,
gfx::Rect(screen_location, options_menu_button_->size()),
views::MenuItemView::TOPRIGHT,
+ ui::MENU_SOURCE_NONE,
views::MenuRunner::HAS_MNEMONICS) == views::MenuRunner::MENU_DELETED)
return;
}
diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_win.cc b/chrome/browser/ui/views/omnibox/omnibox_view_win.cc
index 890f6d2..3548e7f 100644
--- a/chrome/browser/ui/views/omnibox/omnibox_view_win.cc
+++ b/chrome/browser/ui/views/omnibox/omnibox_view_win.cc
@@ -1421,7 +1421,7 @@ void OmniboxViewWin::OnContextMenu(HWND window, const CPoint& point) {
ignore_result(context_menu_runner_->RunMenuAt(native_view_host_->GetWidget(),
NULL, gfx::Rect(location, gfx::Size()), views::MenuItemView::TOPLEFT,
- views::MenuRunner::HAS_MNEMONICS));
+ ui::MENU_SOURCE_MOUSE, views::MenuRunner::HAS_MNEMONICS));
}
void OmniboxViewWin::OnCopy() {
diff --git a/chrome/browser/ui/views/reload_button.cc b/chrome/browser/ui/views/reload_button.cc
index b900f73..470498f 100644
--- a/chrome/browser/ui/views/reload_button.cc
+++ b/chrome/browser/ui/views/reload_button.cc
@@ -170,8 +170,8 @@ bool ReloadButton::ShouldShowMenu() {
return menu_enabled_ && (visible_mode_ == MODE_RELOAD);
}
-void ReloadButton::ShowDropDownMenu() {
- ButtonDropDown::ShowDropDownMenu(); // Blocks.
+void ReloadButton::ShowDropDownMenu(ui::MenuSourceType source_type) {
+ ButtonDropDown::ShowDropDownMenu(source_type); // Blocks.
ChangeMode(intended_mode_, true);
}
diff --git a/chrome/browser/ui/views/reload_button.h b/chrome/browser/ui/views/reload_button.h
index 9c463ed..31ebdc9 100644
--- a/chrome/browser/ui/views/reload_button.h
+++ b/chrome/browser/ui/views/reload_button.h
@@ -59,7 +59,7 @@ class ReloadButton : public views::ButtonDropDown,
// Overridden from views::ButtonDropDown:
virtual bool ShouldShowMenu() OVERRIDE;
- virtual void ShowDropDownMenu() OVERRIDE;
+ virtual void ShowDropDownMenu(ui::MenuSourceType source_type) OVERRIDE;
// Overridden from ui::SimpleMenuModel::Delegate:
virtual bool IsCommandIdChecked(int command_id) const OVERRIDE;
diff --git a/chrome/browser/ui/views/status_icons/status_icon_win.cc b/chrome/browser/ui/views/status_icons/status_icon_win.cc
index 9e6c7b2..ee23a68 100644
--- a/chrome/browser/ui/views/status_icons/status_icon_win.cc
+++ b/chrome/browser/ui/views/status_icons/status_icon_win.cc
@@ -60,7 +60,7 @@ void StatusIconWin::HandleClickEvent(const gfx::Point& cursor_pos,
ignore_result(menu_runner_->RunMenuAt(NULL, NULL,
gfx::Rect(cursor_pos, gfx::Size()), views::MenuItemView::TOPLEFT,
- views::MenuRunner::HAS_MNEMONICS));
+ ui::MENU_SOURCE_MOUSE, views::MenuRunner::HAS_MNEMONICS));
}
void StatusIconWin::ResetIcon() {
diff --git a/chrome/browser/ui/views/tab_contents/render_view_context_menu_views.cc b/chrome/browser/ui/views/tab_contents/render_view_context_menu_views.cc
index 4c58468..70d6c7b 100644
--- a/chrome/browser/ui/views/tab_contents/render_view_context_menu_views.cc
+++ b/chrome/browser/ui/views/tab_contents/render_view_context_menu_views.cc
@@ -48,8 +48,25 @@ void RenderViewContextMenuViews::RunMenuAt(
(type == content::CONTEXT_MENU_SOURCE_TOUCH ||
type == content::CONTEXT_MENU_SOURCE_TOUCH_EDIT_MENU) ?
views::MenuItemView::BOTTOMCENTER : views::MenuItemView::TOPLEFT;
+
+ // TODO(varunjain): remove this by consolidating ui::MenuSourceType and
+ // content::ContextMenuSourceType.
+ ui::MenuSourceType source_type = ui::MENU_SOURCE_NONE;
+ switch (type) {
+ case content::CONTEXT_MENU_SOURCE_MOUSE:
+ source_type = ui::MENU_SOURCE_MOUSE;
+ break;
+ case content::CONTEXT_MENU_SOURCE_KEYBOARD:
+ source_type = ui::MENU_SOURCE_KEYBOARD;
+ break;
+ case content::CONTEXT_MENU_SOURCE_TOUCH:
+ source_type = ui::MENU_SOURCE_TOUCH;
+ break;
+ default:
+ break;
+ }
if (menu_runner_->RunMenuAt(parent, NULL, gfx::Rect(point, gfx::Size()),
- anchor_position, views::MenuRunner::HAS_MNEMONICS |
+ anchor_position, source_type, views::MenuRunner::HAS_MNEMONICS |
views::MenuRunner::CONTEXT_MENU) ==
views::MenuRunner::MENU_DELETED)
return;
diff --git a/chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc b/chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc
index 9825055..c98da98 100644
--- a/chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc
+++ b/chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc
@@ -95,10 +95,11 @@ class BrowserTabStripController::TabContextMenuContents
controller_ = NULL;
}
- void RunMenuAt(const gfx::Point& point) {
+ void RunMenuAt(const gfx::Point& point, ui::MenuSourceType source_type) {
if (menu_runner_->RunMenuAt(
tab_->GetWidget(), NULL, gfx::Rect(point, gfx::Size()),
- views::MenuItemView::TOPLEFT, views::MenuRunner::HAS_MNEMONICS |
+ views::MenuItemView::TOPLEFT, source_type,
+ views::MenuRunner::HAS_MNEMONICS |
views::MenuRunner::CONTEXT_MENU) ==
views::MenuRunner::MENU_DELETED)
return;
@@ -279,10 +280,12 @@ void BrowserTabStripController::CloseTab(int model_index,
TabStripModel::CLOSE_CREATE_HISTORICAL_TAB);
}
-void BrowserTabStripController::ShowContextMenuForTab(Tab* tab,
- const gfx::Point& p) {
+void BrowserTabStripController::ShowContextMenuForTab(
+ Tab* tab,
+ const gfx::Point& p,
+ ui::MenuSourceType source_type) {
context_menu_contents_.reset(new TabContextMenuContents(tab, this));
- context_menu_contents_->RunMenuAt(p);
+ context_menu_contents_->RunMenuAt(p, source_type);
}
void BrowserTabStripController::UpdateLoadingAnimations() {
diff --git a/chrome/browser/ui/views/tabs/browser_tab_strip_controller.h b/chrome/browser/ui/views/tabs/browser_tab_strip_controller.h
index 301e035..62e5f8f 100644
--- a/chrome/browser/ui/views/tabs/browser_tab_strip_controller.h
+++ b/chrome/browser/ui/views/tabs/browser_tab_strip_controller.h
@@ -59,7 +59,8 @@ class BrowserTabStripController : public TabStripController,
virtual void AddSelectionFromAnchorTo(int model_index) OVERRIDE;
virtual void CloseTab(int model_index, CloseTabSource source) OVERRIDE;
virtual void ShowContextMenuForTab(Tab* tab,
- const gfx::Point& p) OVERRIDE;
+ const gfx::Point& p,
+ ui::MenuSourceType source_type) OVERRIDE;
virtual void UpdateLoadingAnimations() OVERRIDE;
virtual int HasAvailableDragActions() const OVERRIDE;
virtual void OnDropIndexUpdate(int index, bool drop_before) OVERRIDE;
diff --git a/chrome/browser/ui/views/tabs/fake_base_tab_strip_controller.cc b/chrome/browser/ui/views/tabs/fake_base_tab_strip_controller.cc
index 3bc4c48..4100601 100644
--- a/chrome/browser/ui/views/tabs/fake_base_tab_strip_controller.cc
+++ b/chrome/browser/ui/views/tabs/fake_base_tab_strip_controller.cc
@@ -79,8 +79,10 @@ void FakeBaseTabStripController::AddSelectionFromAnchorTo(int index) {
void FakeBaseTabStripController::CloseTab(int index, CloseTabSource source) {
}
-void FakeBaseTabStripController::ShowContextMenuForTab(Tab* tab,
- const gfx::Point& p) {
+void FakeBaseTabStripController::ShowContextMenuForTab(
+ Tab* tab,
+ const gfx::Point& p,
+ ui::MenuSourceType source_type) {
}
void FakeBaseTabStripController::UpdateLoadingAnimations() {
diff --git a/chrome/browser/ui/views/tabs/fake_base_tab_strip_controller.h b/chrome/browser/ui/views/tabs/fake_base_tab_strip_controller.h
index 2407366..12d4fa6 100644
--- a/chrome/browser/ui/views/tabs/fake_base_tab_strip_controller.h
+++ b/chrome/browser/ui/views/tabs/fake_base_tab_strip_controller.h
@@ -36,7 +36,8 @@ class FakeBaseTabStripController : public TabStripController {
virtual void AddSelectionFromAnchorTo(int index) OVERRIDE;
virtual void CloseTab(int index, CloseTabSource source) OVERRIDE;
virtual void ShowContextMenuForTab(Tab* tab,
- const gfx::Point& p) OVERRIDE;
+ const gfx::Point& p,
+ ui::MenuSourceType source_type) OVERRIDE;
virtual void UpdateLoadingAnimations() OVERRIDE;
virtual int HasAvailableDragActions() const OVERRIDE;
virtual void OnDropIndexUpdate(int index, bool drop_before) OVERRIDE;
diff --git a/chrome/browser/ui/views/tabs/tab.cc b/chrome/browser/ui/views/tabs/tab.cc
index 53c4f00..acfb5c5 100644
--- a/chrome/browser/ui/views/tabs/tab.cc
+++ b/chrome/browser/ui/views/tabs/tab.cc
@@ -717,9 +717,10 @@ void Tab::ButtonPressed(views::Button* sender, const ui::Event& event) {
// Tab, views::ContextMenuController overrides:
void Tab::ShowContextMenuForView(views::View* source,
- const gfx::Point& point) {
+ const gfx::Point& point,
+ ui::MenuSourceType source_type) {
if (controller() && !closing())
- controller()->ShowContextMenuForTab(this, point);
+ controller()->ShowContextMenuForTab(this, point, source_type);
}
////////////////////////////////////////////////////////////////////////////////
diff --git a/chrome/browser/ui/views/tabs/tab.h b/chrome/browser/ui/views/tabs/tab.h
index 28cfcc9..91ddca8 100644
--- a/chrome/browser/ui/views/tabs/tab.h
+++ b/chrome/browser/ui/views/tabs/tab.h
@@ -161,7 +161,8 @@ class Tab : public TabAudioIndicator::Delegate,
// Overridden from views::ContextMenuController:
virtual void ShowContextMenuForView(views::View* source,
- const gfx::Point& point) OVERRIDE;
+ const gfx::Point& point,
+ ui::MenuSourceType source_type) OVERRIDE;
// Overridden from views::View:
virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
diff --git a/chrome/browser/ui/views/tabs/tab_controller.h b/chrome/browser/ui/views/tabs/tab_controller.h
index 392fcc6..d20a178 100644
--- a/chrome/browser/ui/views/tabs/tab_controller.h
+++ b/chrome/browser/ui/views/tabs/tab_controller.h
@@ -45,7 +45,9 @@ class TabController {
virtual void CloseTab(Tab* tab, CloseTabSource source) = 0;
// Shows a context menu for the tab at the specified point in screen coords.
- virtual void ShowContextMenuForTab(Tab* tab, const gfx::Point& p) = 0;
+ virtual void ShowContextMenuForTab(Tab* tab,
+ const gfx::Point& p,
+ ui::MenuSourceType source_type) = 0;
// Returns true if |tab| is the active tab. The active tab is the one whose
// content is shown in the browser.
diff --git a/chrome/browser/ui/views/tabs/tab_strip.cc b/chrome/browser/ui/views/tabs/tab_strip.cc
index 222d353..68fede9 100644
--- a/chrome/browser/ui/views/tabs/tab_strip.cc
+++ b/chrome/browser/ui/views/tabs/tab_strip.cc
@@ -1021,8 +1021,10 @@ void TabStrip::CloseTab(Tab* tab, CloseTabSource source) {
controller_->CloseTab(model_index, source);
}
-void TabStrip::ShowContextMenuForTab(Tab* tab, const gfx::Point& p) {
- controller_->ShowContextMenuForTab(tab, p);
+void TabStrip::ShowContextMenuForTab(Tab* tab,
+ const gfx::Point& p,
+ ui::MenuSourceType source_type) {
+ controller_->ShowContextMenuForTab(tab, p, source_type);
}
bool TabStrip::IsActiveTab(const Tab* tab) const {
@@ -1568,7 +1570,7 @@ void TabStrip::OnGestureEvent(ui::GestureEvent* event) {
Tab* tab = FindTabForEvent(local_point);
if (tab) {
ConvertPointToScreen(this, &local_point);
- ShowContextMenuForTab(tab, local_point);
+ ShowContextMenuForTab(tab, local_point, ui::MENU_SOURCE_TOUCH);
}
break;
}
diff --git a/chrome/browser/ui/views/tabs/tab_strip.h b/chrome/browser/ui/views/tabs/tab_strip.h
index 49f68e8..8f44c6f 100644
--- a/chrome/browser/ui/views/tabs/tab_strip.h
+++ b/chrome/browser/ui/views/tabs/tab_strip.h
@@ -187,7 +187,8 @@ class TabStrip : public views::View,
virtual void AddSelectionFromAnchorTo(Tab* tab) OVERRIDE;
virtual void CloseTab(Tab* tab, CloseTabSource source) OVERRIDE;
virtual void ShowContextMenuForTab(Tab* tab,
- const gfx::Point& p) OVERRIDE;
+ const gfx::Point& p,
+ ui::MenuSourceType source_type) OVERRIDE;
virtual bool IsActiveTab(const Tab* tab) const OVERRIDE;
virtual bool IsTabSelected(const Tab* tab) const OVERRIDE;
virtual bool IsTabPinned(const Tab* tab) const OVERRIDE;
diff --git a/chrome/browser/ui/views/tabs/tab_strip_controller.h b/chrome/browser/ui/views/tabs/tab_strip_controller.h
index 71055a9..4e53c1b 100644
--- a/chrome/browser/ui/views/tabs/tab_strip_controller.h
+++ b/chrome/browser/ui/views/tabs/tab_strip_controller.h
@@ -6,6 +6,7 @@
#define CHROME_BROWSER_UI_VIEWS_TABS_TAB_STRIP_CONTROLLER_H_
#include "chrome/browser/ui/views/tabs/tab_strip_types.h"
+#include "ui/base/ui_base_types.h"
class GURL;
class Tab;
@@ -66,7 +67,9 @@ class TabStripController {
virtual void CloseTab(int index, CloseTabSource source) = 0;
// Shows a context menu for the tab at the specified point in screen coords.
- virtual void ShowContextMenuForTab(Tab* tab, const gfx::Point& p) = 0;
+ virtual void ShowContextMenuForTab(Tab* tab,
+ const gfx::Point& p,
+ ui::MenuSourceType source_type) = 0;
// Updates the loading animations of all the tabs.
virtual void UpdateLoadingAnimations() = 0;
diff --git a/chrome/browser/ui/views/tabs/tab_unittest.cc b/chrome/browser/ui/views/tabs/tab_unittest.cc
index 5a3b72a..6a175fa 100644
--- a/chrome/browser/ui/views/tabs/tab_unittest.cc
+++ b/chrome/browser/ui/views/tabs/tab_unittest.cc
@@ -32,7 +32,8 @@ class FakeTabController : public TabController {
virtual void AddSelectionFromAnchorTo(Tab* tab) OVERRIDE {}
virtual void CloseTab(Tab* tab, CloseTabSource source) OVERRIDE {}
virtual void ShowContextMenuForTab(Tab* tab,
- const gfx::Point& p) OVERRIDE {}
+ const gfx::Point& p,
+ ui::MenuSourceType source_type) OVERRIDE {}
virtual bool IsActiveTab(const Tab* tab) const OVERRIDE { return false; }
virtual bool IsTabSelected(const Tab* tab) const OVERRIDE {
return false;
diff --git a/chrome/browser/ui/views/task_manager_view.cc b/chrome/browser/ui/views/task_manager_view.cc
index 7b50abe..183a2b4 100644
--- a/chrome/browser/ui/views/task_manager_view.cc
+++ b/chrome/browser/ui/views/task_manager_view.cc
@@ -243,7 +243,8 @@ class TaskManagerView : public views::ButtonListener,
// views::ContextMenuController:
virtual void ShowContextMenuForView(views::View* source,
- const gfx::Point& point) OVERRIDE;
+ const gfx::Point& point,
+ ui::MenuSourceType source_type) OVERRIDE;
// ui::SimpleMenuModel::Delegate:
virtual bool IsCommandIdChecked(int id) const OVERRIDE;
@@ -683,7 +684,8 @@ void TaskManagerView::LinkClicked(views::Link* source, int event_flags) {
}
void TaskManagerView::ShowContextMenuForView(views::View* source,
- const gfx::Point& point) {
+ const gfx::Point& point,
+ ui::MenuSourceType source_type) {
UpdateStatsCounters();
ui::SimpleMenuModel menu_model(this);
for (std::vector<ui::TableColumn>::iterator i(columns_.begin());
@@ -692,7 +694,7 @@ void TaskManagerView::ShowContextMenuForView(views::View* source,
}
menu_runner_.reset(new views::MenuRunner(&menu_model));
if (menu_runner_->RunMenuAt(GetWidget(), NULL, gfx::Rect(point, gfx::Size()),
- views::MenuItemView::TOPLEFT,
+ views::MenuItemView::TOPLEFT, source_type,
views::MenuRunner::CONTEXT_MENU) ==
views::MenuRunner::MENU_DELETED)
return;
diff --git a/chrome/browser/ui/views/website_settings/permission_selector_view.cc b/chrome/browser/ui/views/website_settings/permission_selector_view.cc
index b4d536a..0436925 100644
--- a/chrome/browser/ui/views/website_settings/permission_selector_view.cc
+++ b/chrome/browser/ui/views/website_settings/permission_selector_view.cc
@@ -136,6 +136,7 @@ void PermissionMenuButton::OnMenuButtonClicked(View* source,
this,
gfx::Rect(p, gfx::Size()),
views::MenuItemView::TOPLEFT,
+ ui::MENU_SOURCE_NONE,
views::MenuRunner::HAS_MNEMONICS) == views::MenuRunner::MENU_DELETED)
return;
}
diff --git a/chrome/browser/ui/views/wrench_menu.cc b/chrome/browser/ui/views/wrench_menu.cc
index 28150db..d205584 100644
--- a/chrome/browser/ui/views/wrench_menu.cc
+++ b/chrome/browser/ui/views/wrench_menu.cc
@@ -813,7 +813,8 @@ void WrenchMenu::RunMenu(views::MenuButton* host) {
gfx::Rect bounds(screen_loc, host->size());
content::RecordAction(UserMetricsAction("ShowAppMenu"));
if (menu_runner_->RunMenuAt(host->GetWidget(), host, bounds,
- MenuItemView::TOPRIGHT, views::MenuRunner::HAS_MNEMONICS) ==
+ MenuItemView::TOPRIGHT, ui::MENU_SOURCE_NONE,
+ views::MenuRunner::HAS_MNEMONICS) ==
views::MenuRunner::MENU_DELETED)
return;
if (bookmark_menu_delegate_.get()) {
@@ -898,10 +899,10 @@ int WrenchMenu::OnPerformDrop(MenuItemView* menu,
bool WrenchMenu::ShowContextMenu(MenuItemView* source,
int id,
const gfx::Point& p,
- bool is_mouse_gesture) {
+ ui::MenuSourceType source_type) {
return is_bookmark_command(id) ?
bookmark_menu_delegate_->ShowContextMenu(source, id, p,
- is_mouse_gesture) :
+ source_type) :
false;
}
diff --git a/chrome/browser/ui/views/wrench_menu.h b/chrome/browser/ui/views/wrench_menu.h
index 49a3369..76127ca 100644
--- a/chrome/browser/ui/views/wrench_menu.h
+++ b/chrome/browser/ui/views/wrench_menu.h
@@ -73,7 +73,7 @@ class WrenchMenu : public views::MenuDelegate,
virtual bool ShowContextMenu(views::MenuItemView* source,
int id,
const gfx::Point& p,
- bool is_mouse_gesture) OVERRIDE;
+ ui::MenuSourceType source_type) OVERRIDE;
virtual bool CanDrag(views::MenuItemView* menu) OVERRIDE;
virtual void WriteDragData(views::MenuItemView* sender,
ui::OSExchangeData* data) OVERRIDE;
diff --git a/ui/app_list/views/app_list_item_view.cc b/ui/app_list/views/app_list_item_view.cc
index c397fb0..fa2b123 100644
--- a/ui/app_list/views/app_list_item_view.cc
+++ b/ui/app_list/views/app_list_item_view.cc
@@ -271,7 +271,8 @@ void AppListItemView::GetAccessibleState(ui::AccessibleViewState* state) {
}
void AppListItemView::ShowContextMenuForView(views::View* source,
- const gfx::Point& point) {
+ const gfx::Point& point,
+ ui::MenuSourceType source_type) {
ui::MenuModel* menu_model = model_->GetContextMenuModel();
if (!menu_model)
return;
@@ -279,7 +280,8 @@ void AppListItemView::ShowContextMenuForView(views::View* source,
context_menu_runner_.reset(new views::MenuRunner(menu_model));
if (context_menu_runner_->RunMenuAt(
GetWidget(), NULL, gfx::Rect(point, gfx::Size()),
- views::MenuItemView::TOPLEFT, views::MenuRunner::HAS_MNEMONICS) ==
+ views::MenuItemView::TOPLEFT, source_type,
+ views::MenuRunner::HAS_MNEMONICS) ==
views::MenuRunner::MENU_DELETED)
return;
}
diff --git a/ui/app_list/views/app_list_item_view.h b/ui/app_list/views/app_list_item_view.h
index 713e36e..2a5b4a7 100644
--- a/ui/app_list/views/app_list_item_view.h
+++ b/ui/app_list/views/app_list_item_view.h
@@ -80,7 +80,8 @@ class APP_LIST_EXPORT AppListItemView : public views::CustomButton,
// views::ContextMenuController overrides:
virtual void ShowContextMenuForView(views::View* source,
- const gfx::Point& point) OVERRIDE;
+ const gfx::Point& point,
+ ui::MenuSourceType source_type) OVERRIDE;
// views::CustomButton overrides:
virtual void StateChanged() OVERRIDE;
diff --git a/ui/app_list/views/app_list_menu_views.cc b/ui/app_list/views/app_list_menu_views.cc
index 1f45880..0eb8536 100644
--- a/ui/app_list/views/app_list_menu_views.cc
+++ b/ui/app_list/views/app_list_menu_views.cc
@@ -138,7 +138,8 @@ void AppListMenuViews::RunMenuAt(views::MenuButton* button,
const gfx::Point& point) {
ignore_result(menu_runner_->RunMenuAt(button->GetWidget(), button,
gfx::Rect(point, gfx::Size()),
- MenuItemView::TOPRIGHT, 0));
+ MenuItemView::TOPRIGHT,
+ ui::MENU_SOURCE_NONE, 0));
}
void AppListMenuViews::Cancel() {
diff --git a/ui/app_list/views/search_result_view.cc b/ui/app_list/views/search_result_view.cc
index c9133ec..f92a25b 100644
--- a/ui/app_list/views/search_result_view.cc
+++ b/ui/app_list/views/search_result_view.cc
@@ -290,7 +290,8 @@ void SearchResultView::OnActionIconsChanged() {
}
void SearchResultView::ShowContextMenuForView(views::View* source,
- const gfx::Point& point) {
+ const gfx::Point& point,
+ ui::MenuSourceType source_type) {
ui::MenuModel* menu_model = result_->GetContextMenuModel();
if (!menu_model)
return;
@@ -298,7 +299,8 @@ void SearchResultView::ShowContextMenuForView(views::View* source,
context_menu_runner_.reset(new views::MenuRunner(menu_model));
if (context_menu_runner_->RunMenuAt(
GetWidget(), NULL, gfx::Rect(point, gfx::Size()),
- views::MenuItemView::TOPLEFT, views::MenuRunner::HAS_MNEMONICS) ==
+ views::MenuItemView::TOPLEFT, source_type,
+ views::MenuRunner::HAS_MNEMONICS) ==
views::MenuRunner::MENU_DELETED)
return;
}
diff --git a/ui/app_list/views/search_result_view.h b/ui/app_list/views/search_result_view.h
index 08135fd..c443664 100644
--- a/ui/app_list/views/search_result_view.h
+++ b/ui/app_list/views/search_result_view.h
@@ -66,7 +66,8 @@ class SearchResultView : public views::CustomButton,
// views::ContextMenuController overrides:
virtual void ShowContextMenuForView(views::View* source,
- const gfx::Point& point) OVERRIDE;
+ const gfx::Point& point,
+ ui::MenuSourceType source_type) OVERRIDE;
// SearchResultObserver overrides:
virtual void OnIconChanged() OVERRIDE;
diff --git a/ui/base/ui_base_types.cc b/ui/base/ui_base_types.cc
new file mode 100644
index 0000000..2d3f8127
--- /dev/null
+++ b/ui/base/ui_base_types.cc
@@ -0,0 +1,20 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/base/ui_base_types.h"
+
+#include "ui/base/events/event.h"
+
+namespace ui {
+
+MenuSourceType GetMenuSourceTypeForEvent(const ui::Event& event) {
+ ui::MenuSourceType source_type = ui::MENU_SOURCE_MOUSE;
+ if (event.IsKeyEvent())
+ source_type = ui::MENU_SOURCE_KEYBOARD;
+ if (event.IsTouchEvent() || event.IsGestureEvent())
+ source_type = ui::MENU_SOURCE_TOUCH;
+ return source_type;
+}
+
+} // namespace ui
diff --git a/ui/base/ui_base_types.h b/ui/base/ui_base_types.h
index 2f1bcec..3b8ee9c 100644
--- a/ui/base/ui_base_types.h
+++ b/ui/base/ui_base_types.h
@@ -5,8 +5,12 @@
#ifndef UI_BASE_UI_BASE_TYPES_H_
#define UI_BASE_UI_BASE_TYPES_H_
+#include "ui/base/ui_export.h"
+
namespace ui {
+class Event;
+
// Window "show" state. These values are written to disk so should not be
// changed.
enum WindowShowState {
@@ -37,6 +41,17 @@ enum ModalType {
MODAL_TYPE_SYSTEM = 3 // Window is modal to all other windows.
};
+// TODO(varunjain): Remove MENU_SOURCE_NONE (crbug.com/250964)
+enum MenuSourceType {
+ MENU_SOURCE_NONE = 0,
+ MENU_SOURCE_MOUSE = 1,
+ MENU_SOURCE_KEYBOARD = 2,
+ MENU_SOURCE_TOUCH = 3,
+ MENU_SOURCE_TOUCH_EDIT_MENU = 4,
+};
+
+UI_EXPORT MenuSourceType GetMenuSourceTypeForEvent(const ui::Event& event);
+
} // namespace ui
#endif // UI_BASE_UI_BASE_TYPES_H_
diff --git a/ui/message_center/views/message_view.cc b/ui/message_center/views/message_view.cc
index 9d36feb..382124c 100644
--- a/ui/message_center/views/message_view.cc
+++ b/ui/message_center/views/message_view.cc
@@ -301,7 +301,8 @@ class MessageViewContextMenuController : public views::ContextMenuController {
protected:
// Overridden from views::ContextMenuController:
virtual void ShowContextMenuForView(views::View* source,
- const gfx::Point& point) OVERRIDE;
+ const gfx::Point& point,
+ ui::MenuSourceType source_type) OVERRIDE;
message_center::MessageCenter* message_center_;
std::string notification_id_;
@@ -323,7 +324,8 @@ MessageViewContextMenuController::~MessageViewContextMenuController() {
void MessageViewContextMenuController::ShowContextMenuForView(
views::View* source,
- const gfx::Point& point) {
+ const gfx::Point& point,
+ ui::MenuSourceType source_type) {
MenuModel menu_model(message_center_, notification_id_,
display_source_, extension_id_);
if (menu_model.GetItemCount() == 0)
@@ -336,6 +338,7 @@ void MessageViewContextMenuController::ShowContextMenuForView(
NULL,
gfx::Rect(point, gfx::Size()),
views::MenuItemView::TOPRIGHT,
+ source_type,
views::MenuRunner::HAS_MNEMONICS));
}
diff --git a/ui/ui.gyp b/ui/ui.gyp
index 8effb69..4540630 100644
--- a/ui/ui.gyp
+++ b/ui/ui.gyp
@@ -339,6 +339,7 @@
'base/ui_base_switches.h',
'base/ui_base_switches_util.cc',
'base/ui_base_switches_util.h',
+ 'base/ui_base_types.cc',
'base/ui_base_types.h',
'base/ui_export.h',
'base/view_prop.cc',
diff --git a/ui/views/context_menu_controller.h b/ui/views/context_menu_controller.h
index 23ebd27..dd137a9 100644
--- a/ui/views/context_menu_controller.h
+++ b/ui/views/context_menu_controller.h
@@ -5,6 +5,7 @@
#ifndef UI_VIEWS_CONTEXT_MENU_CONTROLLER_H_
#define UI_VIEWS_CONTEXT_MENU_CONTROLLER_H_
+#include "ui/base/ui_base_types.h"
#include "ui/views/views_export.h"
namespace gfx {
@@ -30,7 +31,8 @@ class VIEWS_EXPORT ContextMenuController {
// Invoked to show the context menu for |source|.
// |point| is in screen coordinates.
virtual void ShowContextMenuForView(View* source,
- const gfx::Point& point) = 0;
+ const gfx::Point& point,
+ ui::MenuSourceType source_type) = 0;
protected:
virtual ~ContextMenuController() {}
diff --git a/ui/views/controls/button/button_dropdown.cc b/ui/views/controls/button/button_dropdown.cc
index a243cee..fa57e3b 100644
--- a/ui/views/controls/button/button_dropdown.cc
+++ b/ui/views/controls/button/button_dropdown.cc
@@ -70,7 +70,8 @@ bool ButtonDropDown::OnMousePressed(const ui::MouseEvent& event) {
base::MessageLoop::current()->PostDelayedTask(
FROM_HERE,
base::Bind(&ButtonDropDown::ShowDropDownMenu,
- show_menu_factory_.GetWeakPtr()),
+ show_menu_factory_.GetWeakPtr(),
+ ui::GetMenuSourceTypeForEvent(event)),
base::TimeDelta::FromMilliseconds(kMenuTimerDelay));
}
return ImageButton::OnMousePressed(event);
@@ -85,7 +86,7 @@ bool ButtonDropDown::OnMouseDragged(const ui::MouseEvent& event) {
// it immediately.
if (event.y() > y_position_on_lbuttondown_ + GetHorizontalDragThreshold()) {
show_menu_factory_.InvalidateWeakPtrs();
- ShowDropDownMenu();
+ ShowDropDownMenu(ui::GetMenuSourceTypeForEvent(event));
}
}
@@ -132,12 +133,13 @@ void ButtonDropDown::GetAccessibleState(ui::AccessibleViewState* state) {
}
void ButtonDropDown::ShowContextMenuForView(View* source,
- const gfx::Point& point) {
+ const gfx::Point& point,
+ ui::MenuSourceType source_type) {
if (!enabled())
return;
show_menu_factory_.InvalidateWeakPtrs();
- ShowDropDownMenu();
+ ShowDropDownMenu(source_type);
}
bool ButtonDropDown::ShouldEnterPushedState(const ui::Event& event) {
@@ -153,7 +155,7 @@ bool ButtonDropDown::ShouldShowMenu() {
return true;
}
-void ButtonDropDown::ShowDropDownMenu() {
+void ButtonDropDown::ShowDropDownMenu(ui::MenuSourceType source_type) {
if (!ShouldShowMenu())
return;
@@ -191,6 +193,7 @@ void ButtonDropDown::ShowDropDownMenu() {
menu_runner_->RunMenuAt(GetWidget(), NULL,
gfx::Rect(menu_position, gfx::Size(0, 0)),
MenuItemView::TOPLEFT,
+ source_type,
MenuRunner::HAS_MNEMONICS);
if (result == MenuRunner::MENU_DELETED)
return;
@@ -202,6 +205,7 @@ void ButtonDropDown::ShowDropDownMenu() {
menu_runner_->RunMenuAt(GetWidget(), NULL,
gfx::Rect(menu_position, gfx::Size(0, 0)),
MenuItemView::TOPLEFT,
+ source_type,
MenuRunner::HAS_MNEMONICS);
if (result == MenuRunner::MENU_DELETED)
return;
diff --git a/ui/views/controls/button/button_dropdown.h b/ui/views/controls/button/button_dropdown.h
index 2842b04..f0a18fa 100644
--- a/ui/views/controls/button/button_dropdown.h
+++ b/ui/views/controls/button/button_dropdown.h
@@ -54,7 +54,8 @@ class VIEWS_EXPORT ButtonDropDown : public ImageButton,
// Overridden from views::ContextMenuController
virtual void ShowContextMenuForView(View* source,
- const gfx::Point& point) OVERRIDE;
+ const gfx::Point& point,
+ ui::MenuSourceType source_type) OVERRIDE;
protected:
// Overridden from CustomButton. Returns true if the button should become
@@ -67,7 +68,7 @@ class VIEWS_EXPORT ButtonDropDown : public ImageButton,
virtual bool ShouldShowMenu();
// Function to show the dropdown menu.
- virtual void ShowDropDownMenu();
+ virtual void ShowDropDownMenu(ui::MenuSourceType source_type);
private:
// The model that populates the attached menu.
diff --git a/ui/views/controls/button/custom_button.cc b/ui/views/controls/button/custom_button.cc
index afb50bc..92e0a8e 100644
--- a/ui/views/controls/button/custom_button.cc
+++ b/ui/views/controls/button/custom_button.cc
@@ -247,7 +247,8 @@ bool CustomButton::AcceleratorPressed(const ui::Accelerator& accelerator) {
return true;
}
-void CustomButton::ShowContextMenu(const gfx::Point& p, bool is_mouse_gesture) {
+void CustomButton::ShowContextMenu(const gfx::Point& p,
+ ui::MenuSourceType source_type) {
if (!context_menu_controller())
return;
@@ -255,7 +256,7 @@ void CustomButton::ShowContextMenu(const gfx::Point& p, bool is_mouse_gesture) {
// we won't get a mouse exited and reset state. Reset it now to be sure.
if (state_ != STATE_DISABLED)
SetState(STATE_NORMAL);
- View::ShowContextMenu(p, is_mouse_gesture);
+ View::ShowContextMenu(p, source_type);
}
void CustomButton::OnDragDone() {
diff --git a/ui/views/controls/button/custom_button.h b/ui/views/controls/button/custom_button.h
index 7134502..37942a2 100644
--- a/ui/views/controls/button/custom_button.h
+++ b/ui/views/controls/button/custom_button.h
@@ -84,7 +84,7 @@ class VIEWS_EXPORT CustomButton : public Button,
virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE;
virtual void ShowContextMenu(const gfx::Point& p,
- bool is_mouse_gesture) OVERRIDE;
+ ui::MenuSourceType source_type) OVERRIDE;
virtual void OnDragDone() OVERRIDE;
virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
virtual void VisibilityChanged(View* starting_from, bool is_visible) OVERRIDE;
diff --git a/ui/views/controls/combobox/native_combobox_views.cc b/ui/views/controls/combobox/native_combobox_views.cc
index 791598b..8ef1efa 100644
--- a/ui/views/controls/combobox/native_combobox_views.cc
+++ b/ui/views/controls/combobox/native_combobox_views.cc
@@ -99,7 +99,7 @@ bool NativeComboboxViews::OnMousePressed(const ui::MouseEvent& mouse_event) {
combobox_->RequestFocus();
if (mouse_event.IsLeftMouseButton()) {
UpdateFromModel();
- ShowDropDownMenu();
+ ShowDropDownMenu(ui::MENU_SOURCE_MOUSE);
}
return true;
@@ -181,7 +181,7 @@ void NativeComboboxViews::OnBlur() {
void NativeComboboxViews::OnGestureEvent(ui::GestureEvent* gesture) {
if (gesture->type() == ui::ET_GESTURE_TAP) {
UpdateFromModel();
- ShowDropDownMenu();
+ ShowDropDownMenu(ui::MENU_SOURCE_TOUCH);
gesture->StopPropagation();
return;
}
@@ -368,7 +368,7 @@ void NativeComboboxViews::PaintText(gfx::Canvas* canvas) {
canvas->Restore();
}
-void NativeComboboxViews::ShowDropDownMenu() {
+void NativeComboboxViews::ShowDropDownMenu(ui::MenuSourceType source_type) {
if (!dropdown_list_menu_runner_.get())
UpdateFromModel();
@@ -397,7 +397,8 @@ void NativeComboboxViews::ShowDropDownMenu() {
dropdown_open_ = true;
if (dropdown_list_menu_runner_->RunMenuAt(
GetWidget(), NULL, bounds, MenuItemView::TOPLEFT,
- MenuRunner::HAS_MNEMONICS) == MenuRunner::MENU_DELETED)
+ source_type, MenuRunner::HAS_MNEMONICS) ==
+ MenuRunner::MENU_DELETED)
return;
dropdown_open_ = false;
diff --git a/ui/views/controls/combobox/native_combobox_views.h b/ui/views/controls/combobox/native_combobox_views.h
index 18f636c..3384b8a 100644
--- a/ui/views/controls/combobox/native_combobox_views.h
+++ b/ui/views/controls/combobox/native_combobox_views.h
@@ -73,7 +73,7 @@ class NativeComboboxViews : public views::View,
void PaintText(gfx::Canvas* canvas);
// Show the drop down list
- void ShowDropDownMenu();
+ void ShowDropDownMenu(ui::MenuSourceType source_type);
// The parent combobox, the owner of this object.
Combobox* combobox_;
diff --git a/ui/views/controls/menu/menu_controller.cc b/ui/views/controls/menu/menu_controller.cc
index 86cd597..f6c2abd 100644
--- a/ui/views/controls/menu/menu_controller.cc
+++ b/ui/views/controls/menu/menu_controller.cc
@@ -4,6 +4,10 @@
#include "ui/views/controls/menu/menu_controller.h"
+#if defined(OS_WIN)
+#include <windowsx.h>
+#endif
+
#include "base/i18n/case_conversion.h"
#include "base/i18n/rtl.h"
#include "base/run_loop.h"
@@ -490,7 +494,8 @@ void MenuController::OnMouseReleased(SubmenuView* source,
== views::MenuItemView::kEmptyMenuItemViewID)
menu = part.parent;
- if (menu != NULL && ShowContextMenu(menu, source, event))
+ if (menu != NULL && ShowContextMenu(menu, source, event,
+ ui::MENU_SOURCE_MOUSE))
return;
}
@@ -554,7 +559,7 @@ void MenuController::OnGestureEvent(SubmenuView* source,
event->StopPropagation();
} else if (event->type() == ui::ET_GESTURE_LONG_PRESS) {
if (part.type == MenuPart::MENU_ITEM && part.menu) {
- if (ShowContextMenu(part.menu, source, *event))
+ if (ShowContextMenu(part.menu, source, *event, ui::MENU_SOURCE_TOUCH))
event->StopPropagation();
}
} else if (event->type() == ui::ET_GESTURE_TAP) {
@@ -957,8 +962,11 @@ bool MenuController::Dispatch(const MSG& msg) {
if (item && item->GetRootMenuItem() != item) {
gfx::Point screen_loc(0, item->height());
View::ConvertPointToScreen(item, &screen_loc);
+ ui::MenuSourceType source_type = ui::MENU_SOURCE_MOUSE;
+ if (GET_X_LPARAM(msg.lParam) == -1 && GET_Y_LPARAM(msg.lParam) == -1)
+ source_type = ui::MENU_SOURCE_KEYBOARD;
item->GetDelegate()->ShowContextMenu(item, item->GetCommand(),
- screen_loc, false);
+ screen_loc, source_type);
}
return true;
}
@@ -1270,7 +1278,8 @@ bool MenuController::ShowSiblingMenu(SubmenuView* source,
bool MenuController::ShowContextMenu(MenuItemView* menu_item,
SubmenuView* source,
- const ui::LocatedEvent& event) {
+ const ui::LocatedEvent& event,
+ ui::MenuSourceType source_type) {
// Set the selection immediately, making sure the submenu is only open
// if it already was.
int selection_types = SELECTION_UPDATE_IMMEDIATELY;
@@ -1281,7 +1290,7 @@ bool MenuController::ShowContextMenu(MenuItemView* menu_item,
View::ConvertPointToScreen(source->GetScrollViewContainer(), &loc);
if (menu_item->GetDelegate()->ShowContextMenu(
- menu_item, menu_item->GetCommand(), loc, true)) {
+ menu_item, menu_item->GetCommand(), loc, source_type)) {
SendMouseCaptureLostToActiveView();
return true;
}
diff --git a/ui/views/controls/menu/menu_controller.h b/ui/views/controls/menu/menu_controller.h
index 8f0a847..45f38e5 100644
--- a/ui/views/controls/menu/menu_controller.h
+++ b/ui/views/controls/menu/menu_controller.h
@@ -291,7 +291,8 @@ class VIEWS_EXPORT MenuController : public base::MessageLoop::Dispatcher,
// button. Returns whether a context menu was shown.
bool ShowContextMenu(MenuItemView* menu_item,
SubmenuView* source,
- const ui::LocatedEvent& event);
+ const ui::LocatedEvent& event,
+ ui::MenuSourceType source_type);
// Closes all menus, including any menus of nested invocations of Run.
void CloseAllNestedMenus();
diff --git a/ui/views/controls/menu/menu_delegate.cc b/ui/views/controls/menu/menu_delegate.cc
index cced8f2..90ab5cb 100644
--- a/ui/views/controls/menu/menu_delegate.cc
+++ b/ui/views/controls/menu/menu_delegate.cc
@@ -45,7 +45,7 @@ bool MenuDelegate::GetAccelerator(int id, ui::Accelerator* accelerator) {
bool MenuDelegate::ShowContextMenu(MenuItemView* source,
int id,
const gfx::Point& p,
- bool is_mouse_gesture) {
+ ui::MenuSourceType source_type) {
return false;
}
diff --git a/ui/views/controls/menu/menu_delegate.h b/ui/views/controls/menu/menu_delegate.h
index f530642..f171d57 100644
--- a/ui/views/controls/menu/menu_delegate.h
+++ b/ui/views/controls/menu/menu_delegate.h
@@ -99,7 +99,7 @@ class VIEWS_EXPORT MenuDelegate {
virtual bool ShowContextMenu(MenuItemView* source,
int id,
const gfx::Point& p,
- bool is_mouse_gesture);
+ ui::MenuSourceType source_type);
// Controller
virtual bool SupportsCommand(int id) const;
diff --git a/ui/views/controls/menu/menu_runner.cc b/ui/views/controls/menu/menu_runner.cc
index 1e8256e..3d19c4e 100644
--- a/ui/views/controls/menu/menu_runner.cc
+++ b/ui/views/controls/menu/menu_runner.cc
@@ -333,6 +333,7 @@ MenuRunner::RunResult MenuRunner::RunMenuAt(Widget* parent,
MenuButton* button,
const gfx::Rect& bounds,
MenuItemView::AnchorPosition anchor,
+ ui::MenuSourceType source_type,
int32 types) {
// The parent of the nested menu will have created a DisplayChangeListener, so
// we avoid creating a DisplayChangeListener if nested. Drop menus are
@@ -341,12 +342,22 @@ MenuRunner::RunResult MenuRunner::RunMenuAt(Widget* parent,
display_change_listener_.reset(
internal::DisplayChangeListener::Create(parent, this));
}
- if ((types & MenuRunner::CONTEXT_MENU) &&
- parent &&
- parent->GetCurrentEvent() &&
- !MenuItemView::IsBubble(anchor))
- anchor = parent->GetCurrentEvent()->IsGestureEvent() ?
- MenuItemView::BOTTOMCENTER : MenuItemView::TOPLEFT;
+
+ if (types & CONTEXT_MENU) {
+ switch (source_type) {
+ case ui::MENU_SOURCE_NONE:
+ case ui::MENU_SOURCE_KEYBOARD:
+ case ui::MENU_SOURCE_MOUSE:
+ anchor = MenuItemView::TOPLEFT;
+ break;
+ case ui::MENU_SOURCE_TOUCH:
+ case ui::MENU_SOURCE_TOUCH_EDIT_MENU:
+ anchor = MenuItemView::BOTTOMCENTER;
+ break;
+ default:
+ break;
+ }
+ }
return holder_->RunMenuAt(parent, button, bounds, anchor, types);
}
diff --git a/ui/views/controls/menu/menu_runner.h b/ui/views/controls/menu/menu_runner.h
index 2e9a133..0744373 100644
--- a/ui/views/controls/menu/menu_runner.h
+++ b/ui/views/controls/menu/menu_runner.h
@@ -95,6 +95,7 @@ class VIEWS_EXPORT MenuRunner {
MenuButton* button,
const gfx::Rect& bounds,
MenuItemView::AnchorPosition anchor,
+ ui::MenuSourceType source_type,
int32 types) WARN_UNUSED_RESULT;
// Returns true if we're in a nested message loop running the menu.
diff --git a/ui/views/controls/native_control.cc b/ui/views/controls/native_control.cc
index 687f193..e6219e7 100644
--- a/ui/views/controls/native_control.cc
+++ b/ui/views/controls/native_control.cc
@@ -269,10 +269,12 @@ void NativeControl::OnContextMenu(const POINT& location) {
if (!context_menu_controller())
return;
- if (location.x == -1 && location.y == -1)
- ShowContextMenu(GetKeyboardContextMenuLocation(), false);
- else
- ShowContextMenu(gfx::Point(location), true);
+ if (location.x == -1 && location.y == -1) {
+ ShowContextMenu(GetKeyboardContextMenuLocation(),
+ ui::MENU_SOURCE_KEYBOARD);
+ } else {
+ ShowContextMenu(gfx::Point(location), ui::MENU_SOURCE_MOUSE);
+ }
}
void NativeControl::OnFocus() {
diff --git a/ui/views/controls/native_control_win.cc b/ui/views/controls/native_control_win.cc
index 1b4f583..2b6c6d4 100644
--- a/ui/views/controls/native_control_win.cc
+++ b/ui/views/controls/native_control_win.cc
@@ -124,10 +124,12 @@ void NativeControlWin::ShowContextMenu(const gfx::Point& location) {
if (!context_menu_controller())
return;
- if (location.x() == -1 && location.y() == -1)
- View::ShowContextMenu(GetKeyboardContextMenuLocation(), false);
- else
- View::ShowContextMenu(location, true);
+ if (location.x() == -1 && location.y() == -1) {
+ View::ShowContextMenu(GetKeyboardContextMenuLocation(),
+ ui::MENU_SOURCE_KEYBOARD);
+ } else {
+ View::ShowContextMenu(location, ui::MENU_SOURCE_MOUSE);
+ }
}
void NativeControlWin::NativeControlCreated(HWND native_control) {
diff --git a/ui/views/controls/scrollbar/base_scroll_bar.cc b/ui/views/controls/scrollbar/base_scroll_bar.cc
index 64b1d13..bf96a98 100644
--- a/ui/views/controls/scrollbar/base_scroll_bar.cc
+++ b/ui/views/controls/scrollbar/base_scroll_bar.cc
@@ -273,7 +273,9 @@ enum ScrollBarContextMenuCommands {
ScrollBarContextMenuCommand_ScrollNext
};
-void BaseScrollBar::ShowContextMenuForView(View* source, const gfx::Point& p) {
+void BaseScrollBar::ShowContextMenuForView(View* source,
+ const gfx::Point& p,
+ ui::MenuSourceType source_type) {
Widget* widget = GetWidget();
gfx::Rect widget_bounds = widget->GetWindowBoundsInScreen();
gfx::Point temp_pt(p.x() - widget_bounds.x(), p.y() - widget_bounds.y());
@@ -294,7 +296,7 @@ void BaseScrollBar::ShowContextMenuForView(View* source, const gfx::Point& p) {
menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollPrev);
menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollNext);
if (menu_runner_->RunMenuAt(GetWidget(), NULL, gfx::Rect(p, gfx::Size()),
- MenuItemView::TOPLEFT, MenuRunner::HAS_MNEMONICS |
+ views::MenuItemView::TOPLEFT, source_type, MenuRunner::HAS_MNEMONICS |
views::MenuRunner::CONTEXT_MENU) ==
MenuRunner::MENU_DELETED)
return;
diff --git a/ui/views/controls/scrollbar/base_scroll_bar.h b/ui/views/controls/scrollbar/base_scroll_bar.h
index a62c3d8..a517b6c 100644
--- a/ui/views/controls/scrollbar/base_scroll_bar.h
+++ b/ui/views/controls/scrollbar/base_scroll_bar.h
@@ -89,7 +89,8 @@ class VIEWS_EXPORT BaseScrollBar : public ScrollBar,
// ContextMenuController overrides:
virtual void ShowContextMenuForView(View* source,
- const gfx::Point& point) OVERRIDE;
+ const gfx::Point& point,
+ ui::MenuSourceType source_type) OVERRIDE;
// Menu::Delegate overrides:
virtual string16 GetLabel(int id) const OVERRIDE;
diff --git a/ui/views/controls/textfield/native_textfield_views.cc b/ui/views/controls/textfield/native_textfield_views.cc
index a86e5bc..b1f45eb 100644
--- a/ui/views/controls/textfield/native_textfield_views.cc
+++ b/ui/views/controls/textfield/native_textfield_views.cc
@@ -426,7 +426,7 @@ bool NativeTextfieldViews::DrawsHandles() {
void NativeTextfieldViews::OpenContextMenu(const gfx::Point& anchor) {
touch_selection_controller_.reset();
- ShowContextMenu(anchor, false);
+ ShowContextMenu(anchor, ui::MENU_SOURCE_TOUCH_EDIT_MENU);
}
gfx::NativeCursor NativeTextfieldViews::GetCursor(const ui::MouseEvent& event) {
@@ -444,11 +444,14 @@ gfx::NativeCursor NativeTextfieldViews::GetCursor(const ui::MouseEvent& event) {
/////////////////////////////////////////////////////////////////
// NativeTextfieldViews, ContextMenuController overrides:
-void NativeTextfieldViews::ShowContextMenuForView(View* source,
- const gfx::Point& point) {
+void NativeTextfieldViews::ShowContextMenuForView(
+ View* source,
+ const gfx::Point& point,
+ ui::MenuSourceType source_type) {
UpdateContextMenu();
if (context_menu_runner_->RunMenuAt(GetWidget(), NULL,
gfx::Rect(point, gfx::Size()), views::MenuItemView::TOPLEFT,
+ source_type,
MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU) ==
MenuRunner::MENU_DELETED)
return;
diff --git a/ui/views/controls/textfield/native_textfield_views.h b/ui/views/controls/textfield/native_textfield_views.h
index 7e7dd28..9986a51 100644
--- a/ui/views/controls/textfield/native_textfield_views.h
+++ b/ui/views/controls/textfield/native_textfield_views.h
@@ -93,7 +93,8 @@ class VIEWS_EXPORT NativeTextfieldViews : public View,
// ContextMenuController overrides:
virtual void ShowContextMenuForView(View* source,
- const gfx::Point& point) OVERRIDE;
+ const gfx::Point& point,
+ ui::MenuSourceType source_type) OVERRIDE;
// Overridden from DragController:
virtual void WriteDragDataForView(View* sender,
diff --git a/ui/views/controls/textfield/native_textfield_win.cc b/ui/views/controls/textfield/native_textfield_win.cc
index 5dae06f..8866cfe 100644
--- a/ui/views/controls/textfield/native_textfield_win.cc
+++ b/ui/views/controls/textfield/native_textfield_win.cc
@@ -613,7 +613,9 @@ void NativeTextfieldWin::OnChar(TCHAR ch, UINT repeat_count, UINT flags) {
void NativeTextfieldWin::OnContextMenu(HWND window, const POINT& point) {
POINT p(point);
+ ui::MenuSourceType source_type = ui::MENU_SOURCE_MOUSE;
if (point.x == -1 || point.y == -1) {
+ source_type = ui::MENU_SOURCE_KEYBOARD;
GetCaretPos(&p);
MapWindowPoints(HWND_DESKTOP, &p, 1);
}
@@ -624,7 +626,7 @@ void NativeTextfieldWin::OnContextMenu(HWND window, const POINT& point) {
ignore_result(context_menu_runner_->RunMenuAt(textfield_->GetWidget(), NULL,
gfx::Rect(gfx::Point(p), gfx::Size()), MenuItemView::TOPLEFT,
- MenuRunner::HAS_MNEMONICS));
+ source_type, MenuRunner::HAS_MNEMONICS));
}
void NativeTextfieldWin::OnCopy() {
diff --git a/ui/views/controls/tree/tree_view.cc b/ui/views/controls/tree/tree_view.cc
index e60b9c0..083a585 100644
--- a/ui/views/controls/tree/tree_view.cc
+++ b/ui/views/controls/tree/tree_view.cc
@@ -380,10 +380,11 @@ void TreeView::OnGestureEvent(ui::GestureEvent* event) {
}
}
-void TreeView::ShowContextMenu(const gfx::Point& p, bool is_mouse_gesture) {
+void TreeView::ShowContextMenu(const gfx::Point& p,
+ ui::MenuSourceType source_type) {
if (!model_)
return;
- if (is_mouse_gesture) {
+ if (source_type == ui::MENU_SOURCE_MOUSE) {
// Only invoke View's implementation (which notifies the
// ContextMenuController) if over a node.
gfx::Point local_point(p);
@@ -397,7 +398,7 @@ void TreeView::ShowContextMenu(const gfx::Point& p, bool is_mouse_gesture) {
if (!bounds.Contains(local_point))
return;
}
- View::ShowContextMenu(p, is_mouse_gesture);
+ View::ShowContextMenu(p, source_type);
}
void TreeView::GetAccessibleState(ui::AccessibleViewState* state) {
diff --git a/ui/views/controls/tree/tree_view.h b/ui/views/controls/tree/tree_view.h
index 295c20b..cca0b33 100644
--- a/ui/views/controls/tree/tree_view.h
+++ b/ui/views/controls/tree/tree_view.h
@@ -122,7 +122,7 @@ class VIEWS_EXPORT TreeView : public View,
virtual ui::TextInputClient* GetTextInputClient() OVERRIDE;
virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
virtual void ShowContextMenu(const gfx::Point& p,
- bool is_mouse_gesture) OVERRIDE;
+ ui::MenuSourceType source_type) OVERRIDE;
virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
// TreeModelObserver overrides:
diff --git a/ui/views/examples/menu_example.cc b/ui/views/examples/menu_example.cc
index 5da8d3c..307a6ca 100644
--- a/ui/views/examples/menu_example.cc
+++ b/ui/views/examples/menu_example.cc
@@ -189,7 +189,8 @@ void ExampleMenuButton::OnMenuButtonClicked(View* source,
if (menu_runner_->RunMenuAt(source->GetWidget()->GetTopLevelWidget(), this,
gfx::Rect(point, gfx::Size()), MenuItemView::TOPRIGHT,
- MenuRunner::HAS_MNEMONICS) == MenuRunner::MENU_DELETED)
+ ui::MENU_SOURCE_NONE, MenuRunner::HAS_MNEMONICS) ==
+ MenuRunner::MENU_DELETED)
return;
}
diff --git a/ui/views/examples/tree_view_example.cc b/ui/views/examples/tree_view_example.cc
index 9d1af4e..a7a51cb 100644
--- a/ui/views/examples/tree_view_example.cc
+++ b/ui/views/examples/tree_view_example.cc
@@ -123,14 +123,15 @@ bool TreeViewExample::CanEdit(TreeView* tree_view,
}
void TreeViewExample::ShowContextMenuForView(View* source,
- const gfx::Point& point) {
+ const gfx::Point& point,
+ ui::MenuSourceType source_type) {
ui::SimpleMenuModel context_menu_model(this);
context_menu_model.AddItem(ID_EDIT, ASCIIToUTF16("Edit"));
context_menu_model.AddItem(ID_REMOVE, ASCIIToUTF16("Remove"));
context_menu_model.AddItem(ID_ADD, ASCIIToUTF16("Add"));
context_menu_runner_.reset(new MenuRunner(&context_menu_model));
if (context_menu_runner_->RunMenuAt(source->GetWidget(), NULL,
- gfx::Rect(point, gfx::Size()), MenuItemView::TOPLEFT, 0) ==
+ gfx::Rect(point, gfx::Size()), MenuItemView::TOPLEFT, source_type, 0) ==
MenuRunner::MENU_DELETED)
return;
}
diff --git a/ui/views/examples/tree_view_example.h b/ui/views/examples/tree_view_example.h
index 74663d1..ffac4dd 100644
--- a/ui/views/examples/tree_view_example.h
+++ b/ui/views/examples/tree_view_example.h
@@ -56,7 +56,8 @@ class TreeViewExample : public ExampleBase,
// ContextMenuController:
virtual void ShowContextMenuForView(View* source,
- const gfx::Point& point) OVERRIDE;
+ const gfx::Point& point,
+ ui::MenuSourceType source_type) OVERRIDE;
// SimpleMenuModel::Delegate:
virtual bool IsCommandIdChecked(int command_id) const OVERRIDE;
diff --git a/ui/views/view.cc b/ui/views/view.cc
index d897859..637fcf8 100644
--- a/ui/views/view.cc
+++ b/ui/views/view.cc
@@ -137,7 +137,7 @@ class PostEventDispatchHandler : public ui::EventHandler {
event->type() == ui::ET_GESTURE_TWO_FINGER_TAP)) {
gfx::Point location(event->location());
View::ConvertPointToScreen(owner_, &location);
- owner_->ShowContextMenu(location, true);
+ owner_->ShowContextMenu(location, ui::MENU_SOURCE_TOUCH);
event->StopPropagation();
}
}
@@ -1148,11 +1148,12 @@ bool View::GetTooltipTextOrigin(const gfx::Point& p, gfx::Point* loc) const {
// Context menus ---------------------------------------------------------------
-void View::ShowContextMenu(const gfx::Point& p, bool is_mouse_gesture) {
+void View::ShowContextMenu(const gfx::Point& p,
+ ui::MenuSourceType source_type) {
if (!context_menu_controller_)
return;
- context_menu_controller_->ShowContextMenuForView(this, p);
+ context_menu_controller_->ShowContextMenuForView(this, p, source_type);
}
// static
@@ -2117,7 +2118,7 @@ bool View::ProcessMousePressed(const ui::MouseEvent& event) {
gfx::Point location(event.location());
if (HitTestPoint(location)) {
ConvertPointToScreen(this, &location);
- ShowContextMenu(location, true);
+ ShowContextMenu(location, ui::MENU_SOURCE_MOUSE);
return true;
}
}
@@ -2160,7 +2161,7 @@ void View::ProcessMouseReleased(const ui::MouseEvent& event) {
OnMouseReleased(event);
if (HitTestPoint(location)) {
ConvertPointToScreen(this, &location);
- ShowContextMenu(location, true);
+ ShowContextMenu(location, ui::MENU_SOURCE_MOUSE);
}
} else {
OnMouseReleased(event);
diff --git a/ui/views/view.h b/ui/views/view.h
index 4b10f0c..2e3420b 100644
--- a/ui/views/view.h
+++ b/ui/views/view.h
@@ -22,6 +22,7 @@
#include "ui/base/dragdrop/os_exchange_data.h"
#include "ui/base/events/event.h"
#include "ui/base/events/event_target.h"
+#include "ui/base/ui_base_types.h"
#include "ui/compositor/layer_delegate.h"
#include "ui/compositor/layer_owner.h"
#include "ui/gfx/native_widget_types.h"
@@ -826,7 +827,8 @@ class VIEWS_EXPORT View : public ui::LayerDelegate,
// to provide right-click menu display triggerd by the keyboard (i.e. for the
// Chrome toolbar Back and Forward buttons). No source needs to be specified,
// as it is always equal to the current View.
- virtual void ShowContextMenu(const gfx::Point& p, bool is_mouse_gesture);
+ virtual void ShowContextMenu(const gfx::Point& p,
+ ui::MenuSourceType source_type);
// On some platforms, we show context menu on mouse press instead of release.
// This method returns true for those platforms.
diff --git a/ui/views/widget/root_view.cc b/ui/views/widget/root_view.cc
index a82e22c..98bf6e6 100644
--- a/ui/views/widget/root_view.cc
+++ b/ui/views/widget/root_view.cc
@@ -117,7 +117,8 @@ void RootView::DispatchKeyEvent(ui::KeyEvent* event) {
// keyboard.
if (v && v->enabled() && ((event->key_code() == ui::VKEY_APPS) ||
(event->key_code() == ui::VKEY_F10 && event->IsShiftDown()))) {
- v->ShowContextMenu(v->GetKeyboardContextMenuLocation(), false);
+ v->ShowContextMenu(v->GetKeyboardContextMenuLocation(),
+ ui::MENU_SOURCE_KEYBOARD);
event->StopPropagation();
return;
}