diff options
author | ananta <ananta@chromium.org> | 2016-01-26 17:22:27 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-01-27 01:24:40 +0000 |
commit | 126116ae6dc4769c6864463753cd960d741f1bbe (patch) | |
tree | 82ab3469b20439b3baee149277b4b27e6bc6a004 /content/browser | |
parent | 34844e9851ab5bd984a52abb72d1728a06858bc8 (diff) | |
download | chromium_src-126116ae6dc4769c6864463753cd960d741f1bbe.zip chromium_src-126116ae6dc4769c6864463753cd960d741f1bbe.tar.gz chromium_src-126116ae6dc4769c6864463753cd960d741f1bbe.tar.bz2 |
Add a new source type MENU_SOURCE_LONG_PRESS to identify context menu's being opened via the long press gesture.
For context, please refer to this patch https://codereview.chromium.org/1602903003/, where we display the context menu
on Windows when the long press gesture is released. This patch used the MENU_SOURCE_TOUCH source type in the context menu
params to determine whether a menu is being opened via the long press gesture. Turns out that the MENU_SOURCE_TOUCH is
used in places like devtools to open the context menu, which does not work due to the above patch.
Fix is to add a new menu source type MENU_SOURCE_LONG_PRESS We use this in RenderWidgetHostViewAura to identify context
menus opening via the long press gesture. Added another menu source type MENU_SOURCE_LONG_TAP which indicates menus
opening via the long tap gesture.
This should fix this regression.
BUG=581005
TEST=RenderWidgetHostViewAuraWithViewHarnessTest.ContextMenuTest. Updated this test to test for the MENU_SOURCE_LONG_PRESS gesture
type.
Review URL: https://codereview.chromium.org/1637743002
Cr-Commit-Position: refs/heads/master@{#371672}
Diffstat (limited to 'content/browser')
-rw-r--r-- | content/browser/renderer_host/render_widget_host_view_aura.cc | 10 | ||||
-rw-r--r-- | content/browser/renderer_host/render_widget_host_view_aura_unittest.cc | 26 |
2 files changed, 28 insertions, 8 deletions
diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc index a51d75e..7767a94 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.cc +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc @@ -2723,7 +2723,7 @@ bool RenderWidgetHostViewAura::OnShowContextMenu( #if defined(OS_WIN) last_context_menu_params_.reset(); - if (params.source_type == ui::MENU_SOURCE_TOUCH) { + if (params.source_type == ui::MENU_SOURCE_LONG_PRESS) { last_context_menu_params_.reset(new ContextMenuParams); *last_context_menu_params_ = params; return false; @@ -2953,12 +2953,12 @@ void RenderWidgetHostViewAura::HandleGestureForTouchSelection( // On Windows we want to display the context menu when the long press // gesture is released. To achieve that, we switch the saved context - // menu params source type to MENU_SOURCE_MOUSE. This is to ensure that + // menu params source type to MENU_SOURCE_TOUCH. This is to ensure that // the RenderWidgetHostViewAura::OnShowContextMenu function which is // called from the ShowContextMenu call below, does not treat it as - // a context menu request coming in from touch. - DCHECK(context_menu_params->source_type == ui::MENU_SOURCE_TOUCH); - context_menu_params->source_type = ui::MENU_SOURCE_MOUSE; + // a context menu request coming in from the long press gesture. + DCHECK(context_menu_params->source_type == ui::MENU_SOURCE_LONG_PRESS); + context_menu_params->source_type = ui::MENU_SOURCE_TOUCH; RenderViewHostDelegateView* delegate_view = GetRenderViewHostDelegateView(); diff --git a/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc b/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc index 374adaf..12266b34 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc +++ b/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc @@ -3756,12 +3756,32 @@ TEST_F(RenderWidgetHostViewAuraWithViewHarnessTest, // A context menu request with the MENU_SOURCE_TOUCH source type should // result in the MockWebContentsViewDelegate::ShowContextMenu method - // getting called on non Windows platforms. This means that the request - // worked correctly. On Windows this should be blocked. + // getting called on all platforms. This means that the request worked + // correctly. delegate->ClearState(); context_menu_params.source_type = ui::MENU_SOURCE_TOUCH; contents()->ShowContextMenu(contents()->GetRenderViewHost()->GetMainFrame(), context_menu_params); + EXPECT_TRUE(delegate->context_menu_request_received()); + + // A context menu request with the MENU_SOURCE_LONG_TAP source type should + // result in the MockWebContentsViewDelegate::ShowContextMenu method + // getting called on all platforms. This means that the request worked + // correctly. + delegate->ClearState(); + context_menu_params.source_type = ui::MENU_SOURCE_LONG_TAP; + contents()->ShowContextMenu(contents()->GetRenderViewHost()->GetMainFrame(), + context_menu_params); + EXPECT_TRUE(delegate->context_menu_request_received()); + + // A context menu request with the MENU_SOURCE_LONG_PRESS source type should + // result in the MockWebContentsViewDelegate::ShowContextMenu method + // getting called on non Windows platforms. This means that the request + // worked correctly. On Windows this should be blocked. + delegate->ClearState(); + context_menu_params.source_type = ui::MENU_SOURCE_LONG_PRESS; + contents()->ShowContextMenu(contents()->GetRenderViewHost()->GetMainFrame(), + context_menu_params); #if defined(OS_WIN) EXPECT_FALSE(delegate->context_menu_request_received()); #else @@ -3780,7 +3800,7 @@ TEST_F(RenderWidgetHostViewAuraWithViewHarnessTest, view()->OnGestureEvent(&gesture_event); EXPECT_TRUE(delegate->context_menu_request_received()); - EXPECT_EQ(delegate->context_menu_source_type(), ui::MENU_SOURCE_MOUSE); + EXPECT_EQ(delegate->context_menu_source_type(), ui::MENU_SOURCE_TOUCH); #endif RenderViewHostFactory::set_is_real_render_view_host(false); |