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 dc121514f9d9b3444ce365c89763ed8311006b5c..77280ee13ccf19bd1dd41a5f3baf05f8fecf7560 100644 |
| --- a/content/browser/android/content_view_core_impl.cc |
| +++ b/content/browser/android/content_view_core_impl.cc |
| @@ -68,7 +68,8 @@ jfieldID g_native_content_view; |
| namespace content { |
| struct ContentViewCoreImpl::JavaObject { |
| - |
| + ScopedJavaGlobalRef<jclass> rect_clazz; |
| + jmethodID rect_constructor; |
| }; |
| ContentViewCore* ContentViewCore::GetNativeContentViewCore(JNIEnv* env, |
| @@ -162,6 +163,9 @@ void ContentViewCoreImpl::Observe(int type, |
| void ContentViewCoreImpl::InitJNI(JNIEnv* env, jobject obj) { |
| java_object_ = new JavaObject; |
| + java_object_->rect_clazz.Reset(GetClass(env, "android/graphics/Rect")); |
| + java_object_->rect_constructor = |
| + GetMethodID(env, java_object_->rect_clazz, "<init>", "(IIII)V"); |
|
bulach
2012/10/05 12:50:59
FYI: one of us :) will need to change this dependi
Iain Merrick
2012/10/05 19:01:52
Thanks for the heads-up -- I'll rely on the trybot
|
| } |
| RenderWidgetHostViewAndroid* |
| @@ -328,7 +332,40 @@ bool ContentViewCoreImpl::HasFocus() { |
| } |
| void ContentViewCoreImpl::OnSelectionChanged(const std::string& text) { |
| - NOTIMPLEMENTED() << "not upstreamed yet"; |
| + JNIEnv* env = AttachCurrentThread(); |
| + ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| + if (obj.is_null()) |
| + return; |
| + ScopedJavaLocalRef<jstring> jtext = ConvertUTF8ToJavaString(env, text); |
| + Java_ContentViewCore_onSelectionChanged(env, obj.obj(), jtext.obj()); |
| +} |
| + |
| +void ContentViewCoreImpl::OnSelectionBoundsChanged( |
| + const gfx::Rect& start_rect, base::i18n::TextDirection start_dir, |
| + const gfx::Rect& end_rect, base::i18n::TextDirection end_dir) { |
| + JNIEnv* env = AttachCurrentThread(); |
| + ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| + if (obj.is_null()) |
| + return; |
| + ScopedJavaLocalRef<jobject> start_rect_object(env, |
| + env->NewObject(java_object_->rect_clazz.obj(), |
| + java_object_->rect_constructor, |
| + start_rect.x(), |
| + start_rect.y(), |
| + start_rect.right(), |
| + start_rect.bottom())); |
| + ScopedJavaLocalRef<jobject> end_rect_object(env, |
| + env->NewObject(java_object_->rect_clazz.obj(), |
| + java_object_->rect_constructor, |
| + end_rect.x(), |
| + end_rect.y(), |
| + end_rect.right(), |
| + end_rect.bottom())); |
| + Java_ContentViewCore_onSelectionBoundsChanged(env, obj.obj(), |
| + start_rect_object.obj(), |
| + start_dir, |
| + end_rect_object.obj(), |
| + end_dir); |
| } |
| void ContentViewCoreImpl::StartContentIntent(const GURL& content_url) { |