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 "android_webview/native/aw_contents.h" | 5 #include "android_webview/native/aw_contents.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "android_webview/browser/aw_browser_context.h" | 9 #include "android_webview/browser/aw_browser_context.h" |
10 #include "android_webview/browser/aw_browser_main_parts.h" | 10 #include "android_webview/browser/aw_browser_main_parts.h" |
(...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
932 if (obj.is_null()) | 932 if (obj.is_null()) |
933 return gfx::Point(); | 933 return gfx::Point(); |
934 std::vector<int> location; | 934 std::vector<int> location; |
935 base::android::JavaIntArrayToIntVector( | 935 base::android::JavaIntArrayToIntVector( |
936 env, | 936 env, |
937 Java_AwContents_getLocationOnScreen(env, obj.obj()).obj(), | 937 Java_AwContents_getLocationOnScreen(env, obj.obj()).obj(), |
938 &location); | 938 &location); |
939 return gfx::Point(location[0], location[1]); | 939 return gfx::Point(location[0], location[1]); |
940 } | 940 } |
941 | 941 |
942 void AwContents::SetMaxContainerViewScrollOffset(gfx::Vector2d new_value) { | |
943 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
944 JNIEnv* env = AttachCurrentThread(); | |
945 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | |
946 if (obj.is_null()) | |
947 return; | |
948 Java_AwContents_setMaxContainerViewScrollOffset( | |
949 env, obj.obj(), new_value.x(), new_value.y()); | |
950 } | |
951 | |
952 void AwContents::ScrollContainerViewTo(gfx::Vector2d new_value) { | 942 void AwContents::ScrollContainerViewTo(gfx::Vector2d new_value) { |
953 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 943 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
954 JNIEnv* env = AttachCurrentThread(); | 944 JNIEnv* env = AttachCurrentThread(); |
955 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 945 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
956 if (obj.is_null()) | 946 if (obj.is_null()) |
957 return; | 947 return; |
958 Java_AwContents_scrollContainerViewTo( | 948 Java_AwContents_scrollContainerViewTo( |
959 env, obj.obj(), new_value.x(), new_value.y()); | 949 env, obj.obj(), new_value.x(), new_value.y()); |
960 } | 950 } |
961 | 951 |
962 bool AwContents::IsFlingActive() const { | 952 bool AwContents::IsFlingActive() const { |
963 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 953 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
964 JNIEnv* env = AttachCurrentThread(); | 954 JNIEnv* env = AttachCurrentThread(); |
965 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 955 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
966 if (obj.is_null()) | 956 if (obj.is_null()) |
967 return false; | 957 return false; |
968 return Java_AwContents_isFlingActive(env, obj.obj()); | 958 return Java_AwContents_isFlingActive(env, obj.obj()); |
969 } | 959 } |
970 | 960 |
971 void AwContents::SetPageScaleFactorAndLimits( | 961 void AwContents::UpdateScrollState(gfx::Vector2d max_scroll_offset, |
972 float page_scale_factor, | 962 gfx::SizeF contents_size_dip, |
973 float min_page_scale_factor, | 963 float page_scale_factor, |
974 float max_page_scale_factor) { | 964 float min_page_scale_factor, |
| 965 float max_page_scale_factor) { |
975 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 966 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
976 JNIEnv* env = AttachCurrentThread(); | 967 JNIEnv* env = AttachCurrentThread(); |
977 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 968 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
978 if (obj.is_null()) | 969 if (obj.is_null()) |
979 return; | 970 return; |
980 Java_AwContents_setPageScaleFactorAndLimits(env, | 971 Java_AwContents_updateScrollState(env, |
981 obj.obj(), | 972 obj.obj(), |
982 page_scale_factor, | 973 max_scroll_offset.x(), |
983 min_page_scale_factor, | 974 max_scroll_offset.y(), |
984 max_page_scale_factor); | 975 contents_size_dip.width(), |
985 } | 976 contents_size_dip.height(), |
986 | 977 page_scale_factor, |
987 void AwContents::SetContentsSize(gfx::SizeF contents_size_dip) { | 978 min_page_scale_factor, |
988 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 979 max_page_scale_factor); |
989 JNIEnv* env = AttachCurrentThread(); | |
990 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | |
991 if (obj.is_null()) | |
992 return; | |
993 Java_AwContents_setContentsSize( | |
994 env, obj.obj(), contents_size_dip.width(), contents_size_dip.height()); | |
995 } | 980 } |
996 | 981 |
997 void AwContents::DidOverscroll(gfx::Vector2d overscroll_delta) { | 982 void AwContents::DidOverscroll(gfx::Vector2d overscroll_delta) { |
998 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 983 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
999 JNIEnv* env = AttachCurrentThread(); | 984 JNIEnv* env = AttachCurrentThread(); |
1000 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 985 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
1001 if (obj.is_null()) | 986 if (obj.is_null()) |
1002 return; | 987 return; |
1003 Java_AwContents_didOverscroll( | 988 Java_AwContents_didOverscroll( |
1004 env, obj.obj(), overscroll_delta.x(), overscroll_delta.y()); | 989 env, obj.obj(), overscroll_delta.x(), overscroll_delta.y()); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1097 return; | 1082 return; |
1098 | 1083 |
1099 browser_view_renderer_.TrimMemory(level, visible); | 1084 browser_view_renderer_.TrimMemory(level, visible); |
1100 } | 1085 } |
1101 | 1086 |
1102 void SetShouldDownloadFavicons(JNIEnv* env, jclass jclazz) { | 1087 void SetShouldDownloadFavicons(JNIEnv* env, jclass jclazz) { |
1103 g_should_download_favicons = true; | 1088 g_should_download_favicons = true; |
1104 } | 1089 } |
1105 | 1090 |
1106 } // namespace android_webview | 1091 } // namespace android_webview |
OLD | NEW |