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 "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 1594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1605 return; | 1605 return; |
1606 if (GetRenderWidgetHostViewAndroid()) { | 1606 if (GetRenderWidgetHostViewAndroid()) { |
1607 GetRenderWidgetHostViewAndroid()->SetTextSurroundingSelectionCallback( | 1607 GetRenderWidgetHostViewAndroid()->SetTextSurroundingSelectionCallback( |
1608 callback); | 1608 callback); |
1609 focused_frame->Send(new FrameMsg_TextSurroundingSelectionRequest( | 1609 focused_frame->Send(new FrameMsg_TextSurroundingSelectionRequest( |
1610 focused_frame->GetRoutingID(), max_length)); | 1610 focused_frame->GetRoutingID(), max_length)); |
1611 } | 1611 } |
1612 } | 1612 } |
1613 | 1613 |
1614 void ContentViewCoreImpl::OnSmartClipDataExtracted( | 1614 void ContentViewCoreImpl::OnSmartClipDataExtracted( |
1615 const gfx::Rect& clip_rect, | 1615 const base::string16& text, |
1616 const base::string16& result) { | 1616 const base::string16& html, |
| 1617 const gfx::Rect& clip_rect) { |
1617 JNIEnv* env = AttachCurrentThread(); | 1618 JNIEnv* env = AttachCurrentThread(); |
1618 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 1619 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
1619 if (obj.is_null()) | 1620 if (obj.is_null()) |
1620 return; | 1621 return; |
| 1622 ScopedJavaLocalRef<jstring> jtext = ConvertUTF16ToJavaString(env, text); |
| 1623 ScopedJavaLocalRef<jstring> jhtml = ConvertUTF16ToJavaString(env, html); |
1621 ScopedJavaLocalRef<jobject> clip_rect_object(CreateJavaRect(env, clip_rect)); | 1624 ScopedJavaLocalRef<jobject> clip_rect_object(CreateJavaRect(env, clip_rect)); |
1622 ScopedJavaLocalRef<jstring> jresult = ConvertUTF16ToJavaString(env, result); | |
1623 Java_ContentViewCore_onSmartClipDataExtracted( | 1625 Java_ContentViewCore_onSmartClipDataExtracted( |
1624 env, obj.obj(), jresult.obj(), clip_rect_object.obj()); | 1626 env, obj.obj(), jtext.obj(), jhtml.obj(), clip_rect_object.obj()); |
1625 } | 1627 } |
1626 | 1628 |
1627 void ContentViewCoreImpl::WebContentsDestroyed() { | 1629 void ContentViewCoreImpl::WebContentsDestroyed() { |
1628 WebContentsViewAndroid* wcva = static_cast<WebContentsViewAndroid*>( | 1630 WebContentsViewAndroid* wcva = static_cast<WebContentsViewAndroid*>( |
1629 static_cast<WebContentsImpl*>(web_contents())->GetView()); | 1631 static_cast<WebContentsImpl*>(web_contents())->GetView()); |
1630 DCHECK(wcva); | 1632 DCHECK(wcva); |
1631 wcva->SetContentViewCore(NULL); | 1633 wcva->SetContentViewCore(NULL); |
1632 } | 1634 } |
1633 | 1635 |
1634 // This is called for each ContentView. | 1636 // This is called for each ContentView. |
(...skipping 10 matching lines...) Expand all Loading... |
1645 reinterpret_cast<ui::WindowAndroid*>(window_android), | 1647 reinterpret_cast<ui::WindowAndroid*>(window_android), |
1646 retained_objects_set); | 1648 retained_objects_set); |
1647 return reinterpret_cast<intptr_t>(view); | 1649 return reinterpret_cast<intptr_t>(view); |
1648 } | 1650 } |
1649 | 1651 |
1650 bool RegisterContentViewCore(JNIEnv* env) { | 1652 bool RegisterContentViewCore(JNIEnv* env) { |
1651 return RegisterNativesImpl(env); | 1653 return RegisterNativesImpl(env); |
1652 } | 1654 } |
1653 | 1655 |
1654 } // namespace content | 1656 } // namespace content |
OLD | NEW |