OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
10 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 324 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
325 if (obj.is_null()) | 325 if (obj.is_null()) |
326 return false; | 326 return false; |
327 return Java_ContentViewCore_hasFocus(env, obj.obj()); | 327 return Java_ContentViewCore_hasFocus(env, obj.obj()); |
328 } | 328 } |
329 | 329 |
330 void ContentViewCoreImpl::OnSelectionChanged(const std::string& text) { | 330 void ContentViewCoreImpl::OnSelectionChanged(const std::string& text) { |
331 NOTIMPLEMENTED() << "not upstreamed yet"; | 331 NOTIMPLEMENTED() << "not upstreamed yet"; |
332 } | 332 } |
333 | 333 |
| 334 void ContentViewCoreImpl::SelectText(const string16& selected_text, |
| 335 int selection_start_x, |
| 336 int selection_start_y) { |
| 337 JNIEnv* env = AttachCurrentThread(); |
| 338 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 339 if (obj.is_null()) |
| 340 return; |
| 341 ScopedJavaLocalRef<jstring> jtext = |
| 342 ConvertUTF16ToJavaString(env, selected_text); |
| 343 Java_ContentViewCore_onTextSelected(env, obj.obj(), |
| 344 jtext.obj(), |
| 345 static_cast<jint>(selection_start_x), |
| 346 static_cast<jint>(selection_start_y)); |
| 347 } |
| 348 |
334 void ContentViewCoreImpl::StartContentIntent(const GURL& content_url) { | 349 void ContentViewCoreImpl::StartContentIntent(const GURL& content_url) { |
335 JNIEnv* env = AttachCurrentThread(); | 350 JNIEnv* env = AttachCurrentThread(); |
336 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); | 351 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); |
337 if (j_obj.is_null()) | 352 if (j_obj.is_null()) |
338 return; | 353 return; |
339 ScopedJavaLocalRef<jstring> jcontent_url = | 354 ScopedJavaLocalRef<jstring> jcontent_url = |
340 ConvertUTF8ToJavaString(env, content_url.spec()); | 355 ConvertUTF8ToJavaString(env, content_url.spec()); |
341 Java_ContentViewCore_startContentIntent(env, | 356 Java_ContentViewCore_startContentIntent(env, |
342 j_obj.obj(), | 357 j_obj.obj(), |
343 jcontent_url.obj()); | 358 jcontent_url.obj()); |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
820 if (!HasField(env, clazz, "mNativeContentViewCore", "I")) { | 835 if (!HasField(env, clazz, "mNativeContentViewCore", "I")) { |
821 DLOG(ERROR) << "Unable to find ContentView.mNativeContentViewCore!"; | 836 DLOG(ERROR) << "Unable to find ContentView.mNativeContentViewCore!"; |
822 return false; | 837 return false; |
823 } | 838 } |
824 g_native_content_view = GetFieldID(env, clazz, "mNativeContentViewCore", "I"); | 839 g_native_content_view = GetFieldID(env, clazz, "mNativeContentViewCore", "I"); |
825 | 840 |
826 return RegisterNativesImpl(env) >= 0; | 841 return RegisterNativesImpl(env) >= 0; |
827 } | 842 } |
828 | 843 |
829 } // namespace content | 844 } // namespace content |
OLD | NEW |