OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/android/content_view_core_impl.h" | 5 #include "content/browser/android/content_view_core_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
10 #include "base/android/jni_array.h" | 10 #include "base/android/jni_array.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
71 using base::android::AttachCurrentThread; | 71 using base::android::AttachCurrentThread; |
72 using base::android::ConvertJavaStringToUTF16; | 72 using base::android::ConvertJavaStringToUTF16; |
73 using base::android::ConvertJavaStringToUTF8; | 73 using base::android::ConvertJavaStringToUTF8; |
74 using base::android::ConvertUTF16ToJavaString; | 74 using base::android::ConvertUTF16ToJavaString; |
75 using base::android::ConvertUTF8ToJavaString; | 75 using base::android::ConvertUTF8ToJavaString; |
76 using base::android::JavaParamRef; | 76 using base::android::JavaParamRef; |
77 using base::android::JavaRef; | 77 using base::android::JavaRef; |
78 using base::android::ScopedJavaLocalRef; | 78 using base::android::ScopedJavaLocalRef; |
79 using blink::WebContextMenuData; | 79 using blink::WebContextMenuData; |
80 using blink::WebGestureEvent; | 80 using blink::WebGestureEvent; |
81 using blink::WebContextMenuData; | |
81 using blink::WebInputEvent; | 82 using blink::WebInputEvent; |
82 using ui::MotionEventAndroid; | 83 using ui::MotionEventAndroid; |
83 | 84 |
84 namespace content { | 85 namespace content { |
85 | 86 |
86 namespace { | 87 namespace { |
87 | 88 |
88 // Describes the type and enabled state of a select popup item. | 89 // Describes the type and enabled state of a select popup item. |
89 // | 90 // |
90 // A Java counterpart will be generated for this enum. | 91 // A Java counterpart will be generated for this enum. |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
612 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); | 613 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); |
613 if (j_obj.is_null()) | 614 if (j_obj.is_null()) |
614 return; | 615 return; |
615 | 616 |
616 Java_ContentViewCore_onSelectionEvent( | 617 Java_ContentViewCore_onSelectionEvent( |
617 env, j_obj, event, selection_anchor.x(), selection_anchor.y(), | 618 env, j_obj, event, selection_anchor.x(), selection_anchor.y(), |
618 selection_rect.x(), selection_rect.y(), selection_rect.right(), | 619 selection_rect.x(), selection_rect.y(), selection_rect.right(), |
619 selection_rect.bottom()); | 620 selection_rect.bottom()); |
620 } | 621 } |
621 | 622 |
622 bool ContentViewCoreImpl::ShowPastePopup(const ContextMenuParams& params) { | 623 bool ContentViewCoreImpl::ShowSelectionMenu(const ContextMenuParams& params) { |
623 // Display paste pop-up only when selection is empty and editable. | 624 // Display paste pop-up only when selection is empty and editable. |
624 if (!(params.is_editable && params.selection_text.empty())) | 625 const bool from_touch = params.source_type == ui::MENU_SOURCE_TOUCH || |
626 params.source_type == ui::MENU_SOURCE_LONG_PRESS || | |
627 params.from_touch; | |
aelias_OOO_until_Jul13
2017/04/21 21:42:19
Is it possible to use the existing source_type enu
| |
628 if (!from_touch || (!params.is_editable && params.selection_text.empty())) | |
625 return false; | 629 return false; |
626 | 630 |
627 RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid(); | 631 RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid(); |
628 if (!view) | 632 if (!view) |
629 return false; | 633 return false; |
630 | 634 |
631 JNIEnv* env = AttachCurrentThread(); | 635 JNIEnv* env = AttachCurrentThread(); |
632 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 636 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
633 if (obj.is_null()) | 637 if (obj.is_null()) |
634 return false; | 638 return false; |
639 | |
635 const bool can_select_all = | 640 const bool can_select_all = |
636 !!(params.edit_flags & WebContextMenuData::kCanSelectAll); | 641 !!(params.edit_flags & WebContextMenuData::kCanSelectAll); |
637 Java_ContentViewCore_showPastePopup(env, obj, params.selection_start.x(), | 642 const bool is_password_type = |
638 params.selection_start.y(), | 643 params.input_field_type == |
639 can_select_all); | 644 blink::WebContextMenuData::kInputFieldTypePassword; |
645 const ScopedJavaLocalRef<jstring> jselected_text = | |
646 ConvertUTF16ToJavaString(env, params.selection_text); | |
647 | |
648 Java_ContentViewCore_showSelectionMenu( | |
649 env, obj, params.selection_start.x(), params.selection_start.y(), | |
650 params.selection_rect.x(), params.selection_rect.y(), | |
651 params.selection_rect.right(), params.selection_rect.bottom(), | |
652 params.is_editable, is_password_type, jselected_text, can_select_all); | |
640 return true; | 653 return true; |
641 } | 654 } |
642 | 655 |
643 void ContentViewCoreImpl::ShowDisambiguationPopup( | 656 void ContentViewCoreImpl::ShowDisambiguationPopup( |
644 const gfx::Rect& rect_pixels, | 657 const gfx::Rect& rect_pixels, |
645 const SkBitmap& zoomed_bitmap) { | 658 const SkBitmap& zoomed_bitmap) { |
646 JNIEnv* env = AttachCurrentThread(); | 659 JNIEnv* env = AttachCurrentThread(); |
647 | 660 |
648 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 661 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
649 if (obj.is_null()) | 662 if (obj.is_null()) |
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1313 return ScopedJavaLocalRef<jobject>(); | 1326 return ScopedJavaLocalRef<jobject>(); |
1314 | 1327 |
1315 return view->GetJavaObject(); | 1328 return view->GetJavaObject(); |
1316 } | 1329 } |
1317 | 1330 |
1318 bool RegisterContentViewCore(JNIEnv* env) { | 1331 bool RegisterContentViewCore(JNIEnv* env) { |
1319 return RegisterNativesImpl(env); | 1332 return RegisterNativesImpl(env); |
1320 } | 1333 } |
1321 | 1334 |
1322 } // namespace content | 1335 } // namespace content |
OLD | NEW |