| 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 1633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1644 static_cast<int>(x / GetDpiScale()), | 1644 static_cast<int>(x / GetDpiScale()), |
| 1645 static_cast<int>(y / GetDpiScale()), | 1645 static_cast<int>(y / GetDpiScale()), |
| 1646 static_cast<int>((width > 0 && width < GetDpiScale()) ? | 1646 static_cast<int>((width > 0 && width < GetDpiScale()) ? |
| 1647 1 : (int)(width / GetDpiScale())), | 1647 1 : (int)(width / GetDpiScale())), |
| 1648 static_cast<int>((height > 0 && height < GetDpiScale()) ? | 1648 static_cast<int>((height > 0 && height < GetDpiScale()) ? |
| 1649 1 : (int)(height / GetDpiScale()))); | 1649 1 : (int)(height / GetDpiScale()))); |
| 1650 GetWebContents()->Send(new ViewMsg_ExtractSmartClipData( | 1650 GetWebContents()->Send(new ViewMsg_ExtractSmartClipData( |
| 1651 GetWebContents()->GetRoutingID(), rect)); | 1651 GetWebContents()->GetRoutingID(), rect)); |
| 1652 } | 1652 } |
| 1653 | 1653 |
| 1654 void ContentViewCoreImpl::OnSmartClipDataExtracted(const string16& result) { | 1654 void ContentViewCoreImpl::OnSmartClipDataExtracted( |
| 1655 const base::string16& result) { |
| 1655 JNIEnv* env = AttachCurrentThread(); | 1656 JNIEnv* env = AttachCurrentThread(); |
| 1656 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 1657 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 1657 if (obj.is_null()) | 1658 if (obj.is_null()) |
| 1658 return; | 1659 return; |
| 1659 ScopedJavaLocalRef<jstring> jresult = ConvertUTF16ToJavaString(env, result); | 1660 ScopedJavaLocalRef<jstring> jresult = ConvertUTF16ToJavaString(env, result); |
| 1660 Java_ContentViewCore_onSmartClipDataExtracted( | 1661 Java_ContentViewCore_onSmartClipDataExtracted( |
| 1661 env, obj.obj(), jresult.obj()); | 1662 env, obj.obj(), jresult.obj()); |
| 1662 } | 1663 } |
| 1663 | 1664 |
| 1664 // This is called for each ContentView. | 1665 // This is called for each ContentView. |
| 1665 jlong Init(JNIEnv* env, jobject obj, | 1666 jlong Init(JNIEnv* env, jobject obj, |
| 1666 jboolean hardware_accelerated, | 1667 jboolean hardware_accelerated, |
| 1667 jlong native_web_contents, | 1668 jlong native_web_contents, |
| 1668 jlong view_android, | 1669 jlong view_android, |
| 1669 jlong window_android) { | 1670 jlong window_android) { |
| 1670 ContentViewCoreImpl* view = new ContentViewCoreImpl( | 1671 ContentViewCoreImpl* view = new ContentViewCoreImpl( |
| 1671 env, obj, hardware_accelerated, | 1672 env, obj, hardware_accelerated, |
| 1672 reinterpret_cast<WebContents*>(native_web_contents), | 1673 reinterpret_cast<WebContents*>(native_web_contents), |
| 1673 reinterpret_cast<ui::ViewAndroid*>(view_android), | 1674 reinterpret_cast<ui::ViewAndroid*>(view_android), |
| 1674 reinterpret_cast<ui::WindowAndroid*>(window_android)); | 1675 reinterpret_cast<ui::WindowAndroid*>(window_android)); |
| 1675 return reinterpret_cast<intptr_t>(view); | 1676 return reinterpret_cast<intptr_t>(view); |
| 1676 } | 1677 } |
| 1677 | 1678 |
| 1678 bool RegisterContentViewCore(JNIEnv* env) { | 1679 bool RegisterContentViewCore(JNIEnv* env) { |
| 1679 return RegisterNativesImpl(env); | 1680 return RegisterNativesImpl(env); |
| 1680 } | 1681 } |
| 1681 | 1682 |
| 1682 } // namespace content | 1683 } // namespace content |
| OLD | NEW |