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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 #include "ui/gfx/screen.h" | 54 #include "ui/gfx/screen.h" |
55 #include "ui/gfx/size_conversions.h" | 55 #include "ui/gfx/size_conversions.h" |
56 #include "ui/gfx/size_f.h" | 56 #include "ui/gfx/size_f.h" |
57 #include "webkit/common/user_agent/user_agent_util.h" | 57 #include "webkit/common/user_agent/user_agent_util.h" |
58 | 58 |
59 using base::android::AttachCurrentThread; | 59 using base::android::AttachCurrentThread; |
60 using base::android::ConvertJavaStringToUTF16; | 60 using base::android::ConvertJavaStringToUTF16; |
61 using base::android::ConvertJavaStringToUTF8; | 61 using base::android::ConvertJavaStringToUTF8; |
62 using base::android::ConvertUTF16ToJavaString; | 62 using base::android::ConvertUTF16ToJavaString; |
63 using base::android::ConvertUTF8ToJavaString; | 63 using base::android::ConvertUTF8ToJavaString; |
| 64 using base::android::JavaByteArrayToByteVector; |
64 using base::android::ScopedJavaGlobalRef; | 65 using base::android::ScopedJavaGlobalRef; |
65 using base::android::ScopedJavaLocalRef; | 66 using base::android::ScopedJavaLocalRef; |
| 67 using base::android::HasException; |
66 using WebKit::WebGestureEvent; | 68 using WebKit::WebGestureEvent; |
67 using WebKit::WebInputEvent; | 69 using WebKit::WebInputEvent; |
68 | 70 |
69 // Describes the type and enabled state of a select popup item. | 71 // Describes the type and enabled state of a select popup item. |
70 // Keep in sync with the value defined in SelectPopupDialog.java | 72 // Keep in sync with the value defined in SelectPopupDialog.java |
71 enum PopupItemType { | 73 enum PopupItemType { |
72 POPUP_ITEM_TYPE_GROUP = 0, | 74 POPUP_ITEM_TYPE_GROUP = 0, |
73 POPUP_ITEM_TYPE_DISABLED, | 75 POPUP_ITEM_TYPE_DISABLED, |
74 POPUP_ITEM_TYPE_ENABLED | 76 POPUP_ITEM_TYPE_ENABLED |
75 }; | 77 }; |
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 } | 694 } |
693 | 695 |
694 void ContentViewCoreImpl::SetNeedsAnimate() { | 696 void ContentViewCoreImpl::SetNeedsAnimate() { |
695 JNIEnv* env = AttachCurrentThread(); | 697 JNIEnv* env = AttachCurrentThread(); |
696 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 698 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
697 if (obj.is_null()) | 699 if (obj.is_null()) |
698 return; | 700 return; |
699 Java_ContentViewCore_setNeedsAnimate(env, obj.obj()); | 701 Java_ContentViewCore_setNeedsAnimate(env, obj.obj()); |
700 } | 702 } |
701 | 703 |
| 704 bool ContentViewCoreImpl::GrabSnapshot(std::vector<unsigned uint8>* png) { |
| 705 JNIEnv* env = AttachCurrentThread(); |
| 706 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 707 if (obj.is_null()) |
| 708 return false; |
| 709 ScopedJavaLocalRef<jbyteArray> data_ref = |
| 710 Java_ContentViewCore_grabSnapshot(env, obj.obj()); |
| 711 if (HasException(env) || data_ref.is_null()) |
| 712 return false; |
| 713 JavaByteArrayToByteVector(env, data_ref.obj(), png); |
| 714 return true; |
| 715 } |
| 716 |
702 ui::ViewAndroid* ContentViewCoreImpl::GetViewAndroid() const { | 717 ui::ViewAndroid* ContentViewCoreImpl::GetViewAndroid() const { |
703 // view_android_ should never be null for Chrome. | 718 // view_android_ should never be null for Chrome. |
704 DCHECK(view_android_); | 719 DCHECK(view_android_); |
705 return view_android_; | 720 return view_android_; |
706 } | 721 } |
707 | 722 |
708 ui::WindowAndroid* ContentViewCoreImpl::GetWindowAndroid() const { | 723 ui::WindowAndroid* ContentViewCoreImpl::GetWindowAndroid() const { |
709 // This should never be NULL for Chrome, but will be NULL for WebView. | 724 // This should never be NULL for Chrome, but will be NULL for WebView. |
710 DCHECK(window_android_); | 725 DCHECK(window_android_); |
711 return window_android_; | 726 return window_android_; |
(...skipping 874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1586 reinterpret_cast<ui::ViewAndroid*>(view_android), | 1601 reinterpret_cast<ui::ViewAndroid*>(view_android), |
1587 reinterpret_cast<ui::WindowAndroid*>(window_android)); | 1602 reinterpret_cast<ui::WindowAndroid*>(window_android)); |
1588 return reinterpret_cast<jint>(view); | 1603 return reinterpret_cast<jint>(view); |
1589 } | 1604 } |
1590 | 1605 |
1591 bool RegisterContentViewCore(JNIEnv* env) { | 1606 bool RegisterContentViewCore(JNIEnv* env) { |
1592 return RegisterNativesImpl(env); | 1607 return RegisterNativesImpl(env); |
1593 } | 1608 } |
1594 | 1609 |
1595 } // namespace content | 1610 } // namespace content |
OLD | NEW |