Chromium Code Reviews| Index: content/browser/android/content_view_core_impl.cc |
| diff --git a/content/browser/android/content_view_core_impl.cc b/content/browser/android/content_view_core_impl.cc |
| index b53f88c6e6b77162cbbf8c0b31e3a5760de7f35d..c15f606512e0978613fb02ab2b8a5641b2df5978 100644 |
| --- a/content/browser/android/content_view_core_impl.cc |
| +++ b/content/browser/android/content_view_core_impl.cc |
| @@ -78,6 +78,7 @@ using base::android::JavaRef; |
| using base::android::ScopedJavaLocalRef; |
| using blink::WebContextMenuData; |
| using blink::WebGestureEvent; |
| +using blink::WebContextMenuData; |
| using blink::WebInputEvent; |
| using ui::MotionEventAndroid; |
| @@ -619,9 +620,12 @@ void ContentViewCoreImpl::OnSelectionEvent(ui::SelectionEventType event, |
| selection_rect.bottom()); |
| } |
| -bool ContentViewCoreImpl::ShowPastePopup(const ContextMenuParams& params) { |
| +bool ContentViewCoreImpl::ShowSelectionMenu(const ContextMenuParams& params) { |
| // Display paste pop-up only when selection is empty and editable. |
| - if (!(params.is_editable && params.selection_text.empty())) |
| + const bool from_touch = params.source_type == ui::MENU_SOURCE_TOUCH || |
| + params.source_type == ui::MENU_SOURCE_LONG_PRESS || |
| + params.from_touch; |
|
aelias_OOO_until_Jul13
2017/04/21 21:42:19
Is it possible to use the existing source_type enu
|
| + if (!from_touch || (!params.is_editable && params.selection_text.empty())) |
| return false; |
| RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid(); |
| @@ -632,11 +636,20 @@ bool ContentViewCoreImpl::ShowPastePopup(const ContextMenuParams& params) { |
| ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| if (obj.is_null()) |
| return false; |
| + |
| const bool can_select_all = |
| !!(params.edit_flags & WebContextMenuData::kCanSelectAll); |
| - Java_ContentViewCore_showPastePopup(env, obj, params.selection_start.x(), |
| - params.selection_start.y(), |
| - can_select_all); |
| + const bool is_password_type = |
| + params.input_field_type == |
| + blink::WebContextMenuData::kInputFieldTypePassword; |
| + const ScopedJavaLocalRef<jstring> jselected_text = |
| + ConvertUTF16ToJavaString(env, params.selection_text); |
| + |
| + Java_ContentViewCore_showSelectionMenu( |
| + env, obj, params.selection_start.x(), params.selection_start.y(), |
| + params.selection_rect.x(), params.selection_rect.y(), |
| + params.selection_rect.right(), params.selection_rect.bottom(), |
| + params.is_editable, is_password_type, jselected_text, can_select_all); |
| return true; |
| } |