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 1622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1633 GetWebContents()->Send(new ViewMsg_ExtractSmartClipData( | 1633 GetWebContents()->Send(new ViewMsg_ExtractSmartClipData( |
1634 GetWebContents()->GetRoutingID(), rect)); | 1634 GetWebContents()->GetRoutingID(), rect)); |
1635 } | 1635 } |
1636 | 1636 |
1637 jint ContentViewCoreImpl::GetCurrentRenderProcessId(JNIEnv* env, jobject obj) { | 1637 jint ContentViewCoreImpl::GetCurrentRenderProcessId(JNIEnv* env, jobject obj) { |
1638 return GetRenderProcessIdFromRenderViewHost( | 1638 return GetRenderProcessIdFromRenderViewHost( |
1639 web_contents_->GetRenderViewHost()); | 1639 web_contents_->GetRenderViewHost()); |
1640 } | 1640 } |
1641 | 1641 |
1642 void ContentViewCoreImpl::OnSmartClipDataExtracted( | 1642 void ContentViewCoreImpl::OnSmartClipDataExtracted( |
| 1643 const gfx::Rect& clip_rect, |
1643 const base::string16& result) { | 1644 const base::string16& result) { |
1644 JNIEnv* env = AttachCurrentThread(); | 1645 JNIEnv* env = AttachCurrentThread(); |
1645 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 1646 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
1646 if (obj.is_null()) | 1647 if (obj.is_null()) |
1647 return; | 1648 return; |
| 1649 ScopedJavaLocalRef<jobject> clip_rect_object(CreateJavaRect(env, clip_rect)); |
1648 ScopedJavaLocalRef<jstring> jresult = ConvertUTF16ToJavaString(env, result); | 1650 ScopedJavaLocalRef<jstring> jresult = ConvertUTF16ToJavaString(env, result); |
1649 Java_ContentViewCore_onSmartClipDataExtracted( | 1651 Java_ContentViewCore_onSmartClipDataExtracted( |
1650 env, obj.obj(), jresult.obj()); | 1652 env, obj.obj(), jresult.obj(), clip_rect_object.obj()); |
1651 } | 1653 } |
1652 | 1654 |
1653 void ContentViewCoreImpl::WebContentsDestroyed(WebContents* web_contents) { | 1655 void ContentViewCoreImpl::WebContentsDestroyed(WebContents* web_contents) { |
1654 WebContentsViewAndroid* wcva = | 1656 WebContentsViewAndroid* wcva = |
1655 static_cast<WebContentsViewAndroid*>(web_contents->GetView()); | 1657 static_cast<WebContentsViewAndroid*>(web_contents->GetView()); |
1656 DCHECK(wcva); | 1658 DCHECK(wcva); |
1657 wcva->SetContentViewCore(NULL); | 1659 wcva->SetContentViewCore(NULL); |
1658 } | 1660 } |
1659 | 1661 |
1660 // This is called for each ContentView. | 1662 // This is called for each ContentView. |
1661 jlong Init(JNIEnv* env, | 1663 jlong Init(JNIEnv* env, |
1662 jobject obj, | 1664 jobject obj, |
1663 jlong native_web_contents, | 1665 jlong native_web_contents, |
1664 jlong view_android, | 1666 jlong view_android, |
1665 jlong window_android) { | 1667 jlong window_android) { |
1666 ContentViewCoreImpl* view = new ContentViewCoreImpl( | 1668 ContentViewCoreImpl* view = new ContentViewCoreImpl( |
1667 env, obj, | 1669 env, obj, |
1668 reinterpret_cast<WebContents*>(native_web_contents), | 1670 reinterpret_cast<WebContents*>(native_web_contents), |
1669 reinterpret_cast<ui::ViewAndroid*>(view_android), | 1671 reinterpret_cast<ui::ViewAndroid*>(view_android), |
1670 reinterpret_cast<ui::WindowAndroid*>(window_android)); | 1672 reinterpret_cast<ui::WindowAndroid*>(window_android)); |
1671 return reinterpret_cast<intptr_t>(view); | 1673 return reinterpret_cast<intptr_t>(view); |
1672 } | 1674 } |
1673 | 1675 |
1674 bool RegisterContentViewCore(JNIEnv* env) { | 1676 bool RegisterContentViewCore(JNIEnv* env) { |
1675 return RegisterNativesImpl(env); | 1677 return RegisterNativesImpl(env); |
1676 } | 1678 } |
1677 | 1679 |
1678 } // namespace content | 1680 } // namespace content |
OLD | NEW |