Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1063)

Unified Diff: content/browser/renderer_host/render_widget_host_view_aura.cc

Issue 1602903003: Display the context menu on Windows on long press release (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove space Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/render_widget_host_view_aura.cc
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 c5494d9976f4698c4ae8ed9592e4a49ad703fbb0..8bc0b2e5493ecfe8b9a8001b6b9609ac0324fd33 100644
--- a/content/browser/renderer_host/render_widget_host_view_aura.cc
+++ b/content/browser/renderer_host/render_widget_host_view_aura.cc
@@ -2720,10 +2720,19 @@ void RenderWidgetHostViewAura::SnapToPhysicalPixelBoundary() {
has_snapped_to_boundary_ = true;
}
-void RenderWidgetHostViewAura::OnShowContextMenu() {
+bool RenderWidgetHostViewAura::OnShowContextMenu(
+ const ContextMenuParams& params) {
#if defined(OS_WIN)
showing_context_menu_ = true;
tdresser 2016/01/20 15:26:12 Should showing_context_menu_ be true in the case w
ananta 2016/01/21 02:08:53 Yeah. Good point. Moved it to after the if check
+ last_context_menu_params_.reset();
+
+ if (params.source_type == ui::MENU_SOURCE_TOUCH) {
+ last_context_menu_params_.reset(new ContextMenuParams);
+ *last_context_menu_params_ = params;
+ return false;
+ }
#endif
+ return true;
}
void RenderWidgetHostViewAura::SetSelectionControllerClientForTest(
@@ -2931,17 +2940,51 @@ void RenderWidgetHostViewAura::HandleGestureForTouchSelection(
}
break;
case ui::ET_GESTURE_SCROLL_BEGIN:
- selection_controller_->OnScrollBeginEvent();
selection_controller_client_->OnScrollStarted();
break;
case ui::ET_GESTURE_SCROLL_END:
selection_controller_client_->OnScrollCompleted();
break;
+#if defined(OS_WIN)
+ case ui::ET_GESTURE_LONG_TAP: {
+ if (!last_context_menu_params_)
+ break;
+
+ ContextMenuParams params = *last_context_menu_params_;
tdresser 2016/01/20 15:26:12 You shouldn't need to copy the ContextMenuParams h
ananta 2016/01/21 02:08:53 Done.
+ DCHECK(params.source_type == ui::MENU_SOURCE_TOUCH);
+ params.source_type = ui::MENU_SOURCE_MOUSE;
tdresser 2016/01/20 15:26:12 It might be worth adding a comment here - settings
ananta 2016/01/21 02:08:53 Done.
+
+ last_context_menu_params_.reset();
+
+ RenderViewHostDelegateView* delegate_view =
+ GetRenderViewHostDelegateView();
+ if (delegate_view)
+ delegate_view->ShowContextMenu(GetFocusedFrame(), params);
+ event->SetHandled();
+ // WARNING: we may have been deleted during the call to ShowContextMenu().
+ break;
+ }
+#endif
default:
break;
}
}
+RenderViewHostDelegateView*
+RenderWidgetHostViewAura::GetRenderViewHostDelegateView() {
+ // Use RenderViewHostDelegate to get to the WebContentsViewAura, which will
+ // actually show the disambiguation popup.
+ RenderViewHost* rvh = RenderViewHost::From(host_);
+ if (!rvh)
+ return nullptr;
+
+ RenderViewHostDelegate* delegate = rvh->GetDelegate();
+ if (!delegate)
+ return nullptr;
+
+ return delegate->GetDelegateView();
+}
+
////////////////////////////////////////////////////////////////////////////////
// DelegatedFrameHost, public:
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_aura.h ('k') | content/browser/web_contents/web_contents_view_aura.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698