| 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 885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 896 if (obj.is_null()) | 896 if (obj.is_null()) |
| 897 return gfx::Point(); | 897 return gfx::Point(); |
| 898 std::vector<int> location; | 898 std::vector<int> location; |
| 899 base::android::JavaIntArrayToIntVector( | 899 base::android::JavaIntArrayToIntVector( |
| 900 env, | 900 env, |
| 901 Java_AwContents_getLocationOnScreen(env, obj.obj()).obj(), | 901 Java_AwContents_getLocationOnScreen(env, obj.obj()).obj(), |
| 902 &location); | 902 &location); |
| 903 return gfx::Point(location[0], location[1]); | 903 return gfx::Point(location[0], location[1]); |
| 904 } | 904 } |
| 905 | 905 |
| 906 void AwContents::SetMaxContainerViewScrollOffset(gfx::Vector2d new_value) { | |
| 907 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 908 JNIEnv* env = AttachCurrentThread(); | |
| 909 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | |
| 910 if (obj.is_null()) | |
| 911 return; | |
| 912 Java_AwContents_setMaxContainerViewScrollOffset( | |
| 913 env, obj.obj(), new_value.x(), new_value.y()); | |
| 914 } | |
| 915 | |
| 916 void AwContents::ScrollContainerViewTo(gfx::Vector2d new_value) { | 906 void AwContents::ScrollContainerViewTo(gfx::Vector2d new_value) { |
| 917 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 907 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 918 JNIEnv* env = AttachCurrentThread(); | 908 JNIEnv* env = AttachCurrentThread(); |
| 919 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 909 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 920 if (obj.is_null()) | 910 if (obj.is_null()) |
| 921 return; | 911 return; |
| 922 Java_AwContents_scrollContainerViewTo( | 912 Java_AwContents_scrollContainerViewTo( |
| 923 env, obj.obj(), new_value.x(), new_value.y()); | 913 env, obj.obj(), new_value.x(), new_value.y()); |
| 924 } | 914 } |
| 925 | 915 |
| 926 bool AwContents::IsFlingActive() const { | 916 bool AwContents::IsFlingActive() const { |
| 927 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 917 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 928 JNIEnv* env = AttachCurrentThread(); | 918 JNIEnv* env = AttachCurrentThread(); |
| 929 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 919 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 930 if (obj.is_null()) | 920 if (obj.is_null()) |
| 931 return false; | 921 return false; |
| 932 return Java_AwContents_isFlingActive(env, obj.obj()); | 922 return Java_AwContents_isFlingActive(env, obj.obj()); |
| 933 } | 923 } |
| 934 | 924 |
| 935 void AwContents::SetPageScaleFactorAndLimits( | 925 void AwContents::UpdateScrollState(gfx::Vector2d max_scroll_offset, |
| 936 float page_scale_factor, | 926 gfx::SizeF contents_size_dip, |
| 937 float min_page_scale_factor, | 927 float page_scale_factor, |
| 938 float max_page_scale_factor) { | 928 float min_page_scale_factor, |
| 929 float max_page_scale_factor) { |
| 939 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 930 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 940 JNIEnv* env = AttachCurrentThread(); | 931 JNIEnv* env = AttachCurrentThread(); |
| 941 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 932 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 942 if (obj.is_null()) | 933 if (obj.is_null()) |
| 943 return; | 934 return; |
| 944 Java_AwContents_setPageScaleFactorAndLimits(env, | 935 Java_AwContents_updateScrollState(env, |
| 945 obj.obj(), | 936 obj.obj(), |
| 946 page_scale_factor, | 937 max_scroll_offset.x(), |
| 947 min_page_scale_factor, | 938 max_scroll_offset.y(), |
| 948 max_page_scale_factor); | 939 contents_size_dip.width(), |
| 949 } | 940 contents_size_dip.height(), |
| 950 | 941 page_scale_factor, |
| 951 void AwContents::SetContentsSize(gfx::SizeF contents_size_dip) { | 942 min_page_scale_factor, |
| 952 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 943 max_page_scale_factor); |
| 953 JNIEnv* env = AttachCurrentThread(); | |
| 954 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | |
| 955 if (obj.is_null()) | |
| 956 return; | |
| 957 Java_AwContents_setContentsSize( | |
| 958 env, obj.obj(), contents_size_dip.width(), contents_size_dip.height()); | |
| 959 } | 944 } |
| 960 | 945 |
| 961 void AwContents::DidOverscroll(gfx::Vector2d overscroll_delta) { | 946 void AwContents::DidOverscroll(gfx::Vector2d overscroll_delta) { |
| 962 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 947 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 963 JNIEnv* env = AttachCurrentThread(); | 948 JNIEnv* env = AttachCurrentThread(); |
| 964 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 949 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 965 if (obj.is_null()) | 950 if (obj.is_null()) |
| 966 return; | 951 return; |
| 967 Java_AwContents_didOverscroll( | 952 Java_AwContents_didOverscroll( |
| 968 env, obj.obj(), overscroll_delta.x(), overscroll_delta.y()); | 953 env, obj.obj(), overscroll_delta.x(), overscroll_delta.y()); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1061 return; | 1046 return; |
| 1062 | 1047 |
| 1063 browser_view_renderer_.TrimMemory(level, visible); | 1048 browser_view_renderer_.TrimMemory(level, visible); |
| 1064 } | 1049 } |
| 1065 | 1050 |
| 1066 void SetShouldDownloadFavicons(JNIEnv* env, jclass jclazz) { | 1051 void SetShouldDownloadFavicons(JNIEnv* env, jclass jclazz) { |
| 1067 g_should_download_favicons = true; | 1052 g_should_download_favicons = true; |
| 1068 } | 1053 } |
| 1069 | 1054 |
| 1070 } // namespace android_webview | 1055 } // namespace android_webview |
| OLD | NEW |