| 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 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 | 646 |
| 647 void ContentViewCoreImpl::OnSelectionChanged(const std::string& text) { | 647 void ContentViewCoreImpl::OnSelectionChanged(const std::string& text) { |
| 648 JNIEnv* env = AttachCurrentThread(); | 648 JNIEnv* env = AttachCurrentThread(); |
| 649 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 649 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 650 if (obj.is_null()) | 650 if (obj.is_null()) |
| 651 return; | 651 return; |
| 652 ScopedJavaLocalRef<jstring> jtext = ConvertUTF8ToJavaString(env, text); | 652 ScopedJavaLocalRef<jstring> jtext = ConvertUTF8ToJavaString(env, text); |
| 653 Java_ContentViewCore_onSelectionChanged(env, obj.obj(), jtext.obj()); | 653 Java_ContentViewCore_onSelectionChanged(env, obj.obj(), jtext.obj()); |
| 654 } | 654 } |
| 655 | 655 |
| 656 void ContentViewCoreImpl::OnSelectionEvent(ui::SelectionEventType event, | 656 void ContentViewCoreImpl::OnSelectionEvent( |
| 657 const gfx::PointF& selection_anchor, | 657 ui::SelectionEventType event, const gfx::PointF& selection_anchor) { |
| 658 const gfx::RectF& selection_rect) { | |
| 659 JNIEnv* env = AttachCurrentThread(); | 658 JNIEnv* env = AttachCurrentThread(); |
| 660 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); | 659 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); |
| 661 if (j_obj.is_null()) | 660 if (j_obj.is_null()) |
| 662 return; | 661 return; |
| 663 | 662 |
| 664 gfx::PointF selection_anchor_pix = | 663 gfx::PointF selection_anchor_pix = |
| 665 gfx::ScalePoint(selection_anchor, dpi_scale()); | 664 gfx::ScalePoint(selection_anchor, dpi_scale()); |
| 666 gfx::RectF selection_rect_pix = gfx::ScaleRect(selection_rect, dpi_scale()); | |
| 667 Java_ContentViewCore_onSelectionEvent( | 665 Java_ContentViewCore_onSelectionEvent( |
| 668 env, j_obj.obj(), event, selection_anchor_pix.x(), | 666 env, j_obj.obj(), event, selection_anchor_pix.x(), |
| 669 selection_anchor_pix.y(), selection_rect_pix.x(), selection_rect_pix.y(), | 667 selection_anchor_pix.y()); |
| 670 selection_rect_pix.right(), selection_rect_pix.bottom()); | |
| 671 } | |
| 672 | |
| 673 bool ContentViewCoreImpl::ShowPastePopup(int x_dip, int y_dip) { | |
| 674 RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid(); | |
| 675 if (!view) | |
| 676 return false; | |
| 677 | |
| 678 view->OnShowingPastePopup(gfx::PointF(x_dip, y_dip)); | |
| 679 | |
| 680 JNIEnv* env = AttachCurrentThread(); | |
| 681 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | |
| 682 if (obj.is_null()) | |
| 683 return false; | |
| 684 return Java_ContentViewCore_showPastePopupWithFeedback( | |
| 685 env, obj.obj(), static_cast<jint>(x_dip * dpi_scale()), | |
| 686 static_cast<jint>(y_dip * dpi_scale())); | |
| 687 } | 668 } |
| 688 | 669 |
| 689 void ContentViewCoreImpl::StartContentIntent(const GURL& content_url, | 670 void ContentViewCoreImpl::StartContentIntent(const GURL& content_url, |
| 690 bool is_main_frame) { | 671 bool is_main_frame) { |
| 691 JNIEnv* env = AttachCurrentThread(); | 672 JNIEnv* env = AttachCurrentThread(); |
| 692 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); | 673 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); |
| 693 if (j_obj.is_null()) | 674 if (j_obj.is_null()) |
| 694 return; | 675 return; |
| 695 ScopedJavaLocalRef<jstring> jcontent_url = | 676 ScopedJavaLocalRef<jstring> jcontent_url = |
| 696 ConvertUTF8ToJavaString(env, content_url.spec()); | 677 ConvertUTF8ToJavaString(env, content_url.spec()); |
| (...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1581 return ScopedJavaLocalRef<jobject>(); | 1562 return ScopedJavaLocalRef<jobject>(); |
| 1582 | 1563 |
| 1583 return view->GetJavaObject(); | 1564 return view->GetJavaObject(); |
| 1584 } | 1565 } |
| 1585 | 1566 |
| 1586 bool RegisterContentViewCore(JNIEnv* env) { | 1567 bool RegisterContentViewCore(JNIEnv* env) { |
| 1587 return RegisterNativesImpl(env); | 1568 return RegisterNativesImpl(env); |
| 1588 } | 1569 } |
| 1589 | 1570 |
| 1590 } // namespace content | 1571 } // namespace content |
| OLD | NEW |