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 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); | 621 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); |
622 if (j_obj.is_null()) | 622 if (j_obj.is_null()) |
623 return; | 623 return; |
624 | 624 |
625 Java_ContentViewCore_onSelectionEvent( | 625 Java_ContentViewCore_onSelectionEvent( |
626 env, j_obj, event, selection_anchor.x(), selection_anchor.y(), | 626 env, j_obj, event, selection_anchor.x(), selection_anchor.y(), |
627 selection_rect.x(), selection_rect.y(), selection_rect.right(), | 627 selection_rect.x(), selection_rect.y(), selection_rect.right(), |
628 selection_rect.bottom()); | 628 selection_rect.bottom()); |
629 } | 629 } |
630 | 630 |
631 void ContentViewCoreImpl::ShowPastePopup(int x_dip, int y_dip) { | 631 bool ContentViewCoreImpl::ShowPastePopup(const ContextMenuParams& params) { |
| 632 // Display paste pop-up only when selection is empty and editable. |
| 633 if (!(params.is_editable && params.selection_text.empty())) |
| 634 return false; |
| 635 |
632 RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid(); | 636 RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid(); |
633 if (!view) | 637 if (!view) |
634 return; | 638 return false; |
635 | 639 |
636 JNIEnv* env = AttachCurrentThread(); | 640 JNIEnv* env = AttachCurrentThread(); |
637 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 641 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
638 if (obj.is_null()) | 642 if (obj.is_null()) |
639 return; | 643 return false; |
640 Java_ContentViewCore_showPastePopup(env, obj, x_dip, | 644 Java_ContentViewCore_showPastePopup(env, obj, params.selection_start.x(), |
641 y_dip); | 645 params.selection_start.y()); |
| 646 return true; |
642 } | 647 } |
643 | 648 |
644 void ContentViewCoreImpl::ShowDisambiguationPopup( | 649 void ContentViewCoreImpl::ShowDisambiguationPopup( |
645 const gfx::Rect& rect_pixels, | 650 const gfx::Rect& rect_pixels, |
646 const SkBitmap& zoomed_bitmap) { | 651 const SkBitmap& zoomed_bitmap) { |
647 JNIEnv* env = AttachCurrentThread(); | 652 JNIEnv* env = AttachCurrentThread(); |
648 | 653 |
649 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 654 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
650 if (obj.is_null()) | 655 if (obj.is_null()) |
651 return; | 656 return; |
(...skipping 874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1526 return ScopedJavaLocalRef<jobject>(); | 1531 return ScopedJavaLocalRef<jobject>(); |
1527 | 1532 |
1528 return view->GetJavaObject(); | 1533 return view->GetJavaObject(); |
1529 } | 1534 } |
1530 | 1535 |
1531 bool RegisterContentViewCore(JNIEnv* env) { | 1536 bool RegisterContentViewCore(JNIEnv* env) { |
1532 return RegisterNativesImpl(env); | 1537 return RegisterNativesImpl(env); |
1533 } | 1538 } |
1534 | 1539 |
1535 } // namespace content | 1540 } // namespace content |
OLD | NEW |