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