| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/selection_popup_controller.h" | 5 #include "content/browser/android/selection_popup_controller.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
| 9 #include "base/android/scoped_java_ref.h" | 9 #include "base/android/scoped_java_ref.h" |
| 10 #include "content/browser/renderer_host/render_widget_host_view_android.h" | 10 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 RenderWidgetHostViewAndroid* old_rwhva, | 44 RenderWidgetHostViewAndroid* old_rwhva, |
| 45 RenderWidgetHostViewAndroid* new_rwhva) { | 45 RenderWidgetHostViewAndroid* new_rwhva) { |
| 46 if (old_rwhva) | 46 if (old_rwhva) |
| 47 old_rwhva->set_selection_popup_controller(nullptr); | 47 old_rwhva->set_selection_popup_controller(nullptr); |
| 48 if (new_rwhva) | 48 if (new_rwhva) |
| 49 new_rwhva->set_selection_popup_controller(this); | 49 new_rwhva->set_selection_popup_controller(this); |
| 50 } | 50 } |
| 51 | 51 |
| 52 void SelectionPopupController::OnSelectionEvent( | 52 void SelectionPopupController::OnSelectionEvent( |
| 53 ui::SelectionEventType event, | 53 ui::SelectionEventType event, |
| 54 const gfx::PointF& selection_anchor, | |
| 55 const gfx::RectF& selection_rect) { | 54 const gfx::RectF& selection_rect) { |
| 56 JNIEnv* env = AttachCurrentThread(); | 55 JNIEnv* env = AttachCurrentThread(); |
| 57 ScopedJavaLocalRef<jobject> obj = java_obj_.get(env); | 56 ScopedJavaLocalRef<jobject> obj = java_obj_.get(env); |
| 58 if (obj.is_null()) | 57 if (obj.is_null()) |
| 59 return; | 58 return; |
| 60 | 59 |
| 61 Java_SelectionPopupController_onSelectionEvent( | 60 Java_SelectionPopupController_onSelectionEvent( |
| 62 env, obj, event, selection_anchor.x(), selection_anchor.y(), | 61 env, obj, event, selection_rect.x(), selection_rect.y(), |
| 63 selection_rect.x(), selection_rect.y(), selection_rect.right(), | 62 selection_rect.right(), selection_rect.bottom()); |
| 64 selection_rect.bottom()); | |
| 65 } | 63 } |
| 66 | 64 |
| 67 void SelectionPopupController::OnSelectionChanged(const std::string& text) { | 65 void SelectionPopupController::OnSelectionChanged(const std::string& text) { |
| 68 JNIEnv* env = AttachCurrentThread(); | 66 JNIEnv* env = AttachCurrentThread(); |
| 69 ScopedJavaLocalRef<jobject> obj = java_obj_.get(env); | 67 ScopedJavaLocalRef<jobject> obj = java_obj_.get(env); |
| 70 if (obj.is_null()) | 68 if (obj.is_null()) |
| 71 return; | 69 return; |
| 72 ScopedJavaLocalRef<jstring> jtext = ConvertUTF8ToJavaString(env, text); | 70 ScopedJavaLocalRef<jstring> jtext = ConvertUTF8ToJavaString(env, text); |
| 73 Java_SelectionPopupController_onSelectionChanged(env, obj, jtext); | 71 Java_SelectionPopupController_onSelectionChanged(env, obj, jtext); |
| 74 } | 72 } |
| 75 | 73 |
| 76 } // namespace content | 74 } // namespace content |
| OLD | NEW |