OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_settings.h" | 5 #include "android_webview/native/aw_settings.h" |
6 | 6 |
7 #include "android_webview/browser/renderer_host/aw_render_view_host_ext.h" | 7 #include "android_webview/browser/renderer_host/aw_render_view_host_ext.h" |
8 #include "android_webview/native/aw_contents.h" | 8 #include "android_webview/native/aw_contents.h" |
9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 if (!obj) return; | 65 if (!obj) return; |
66 // Grab the lock and call UpdateEverythingLocked. | 66 // Grab the lock and call UpdateEverythingLocked. |
67 Java_AwSettings_updateEverything(env, obj); | 67 Java_AwSettings_updateEverything(env, obj); |
68 } | 68 } |
69 | 69 |
70 void AwSettings::UpdateEverythingLocked(JNIEnv* env, jobject obj) { | 70 void AwSettings::UpdateEverythingLocked(JNIEnv* env, jobject obj) { |
71 UpdateInitialPageScaleLocked(env, obj); | 71 UpdateInitialPageScaleLocked(env, obj); |
72 UpdateWebkitPreferencesLocked(env, obj); | 72 UpdateWebkitPreferencesLocked(env, obj); |
73 UpdateUserAgentLocked(env, obj); | 73 UpdateUserAgentLocked(env, obj); |
74 ResetScrollAndScaleState(env, obj); | 74 ResetScrollAndScaleState(env, obj); |
75 UpdatePreferredSizeMode(); | |
76 UpdateFormDataPreferencesLocked(env, obj); | 75 UpdateFormDataPreferencesLocked(env, obj); |
| 76 UpdateContentSizeNotificationMode(env, obj); |
77 } | 77 } |
78 | 78 |
79 void AwSettings::UpdateUserAgentLocked(JNIEnv* env, jobject obj) { | 79 void AwSettings::UpdateUserAgentLocked(JNIEnv* env, jobject obj) { |
80 if (!web_contents()) return; | 80 if (!web_contents()) return; |
81 | 81 |
82 ScopedJavaLocalRef<jstring> str = | 82 ScopedJavaLocalRef<jstring> str = |
83 Java_AwSettings_getUserAgentLocked(env, obj); | 83 Java_AwSettings_getUserAgentLocked(env, obj); |
84 bool ua_overidden = str.obj() != NULL; | 84 bool ua_overidden = str.obj() != NULL; |
85 | 85 |
86 if (ua_overidden) { | 86 if (ua_overidden) { |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 Java_AwSettings_getInitialPageScalePercentLocked(env, obj); | 223 Java_AwSettings_getInitialPageScalePercentLocked(env, obj); |
224 if (initial_page_scale_percent == 0) { | 224 if (initial_page_scale_percent == 0) { |
225 rvhe->SetInitialPageScale(-1); | 225 rvhe->SetInitialPageScale(-1); |
226 } else { | 226 } else { |
227 float dip_scale = static_cast<float>( | 227 float dip_scale = static_cast<float>( |
228 Java_AwSettings_getDIPScaleLocked(env, obj)); | 228 Java_AwSettings_getDIPScaleLocked(env, obj)); |
229 rvhe->SetInitialPageScale(initial_page_scale_percent / dip_scale / 100.0f); | 229 rvhe->SetInitialPageScale(initial_page_scale_percent / dip_scale / 100.0f); |
230 } | 230 } |
231 } | 231 } |
232 | 232 |
233 void AwSettings::UpdatePreferredSizeMode() { | 233 void AwSettings::UpdateContentSizeNotificationMode(JNIEnv* env, jobject obj) { |
234 if (web_contents()->GetRenderViewHost()) { | 234 GetAwRenderViewHostExt()->EnableContentsSizeNotifications(); |
235 web_contents()->GetRenderViewHost()->EnablePreferredSizeMode(); | |
236 } | |
237 } | 235 } |
238 | 236 |
239 void AwSettings::UpdateFormDataPreferencesLocked(JNIEnv* env, jobject obj) { | 237 void AwSettings::UpdateFormDataPreferencesLocked(JNIEnv* env, jobject obj) { |
240 if (!web_contents()) return; | 238 if (!web_contents()) return; |
241 AwContents* contents = AwContents::FromWebContents(web_contents()); | 239 AwContents* contents = AwContents::FromWebContents(web_contents()); |
242 if (!contents) return; | 240 if (!contents) return; |
243 | 241 |
244 contents->SetSaveFormData(Java_AwSettings_getSaveFormDataLocked(env, obj)); | 242 contents->SetSaveFormData(Java_AwSettings_getSaveFormDataLocked(env, obj)); |
245 } | 243 } |
246 | 244 |
(...skipping 26 matching lines...) Expand all Loading... |
273 static jstring GetDefaultUserAgent(JNIEnv* env, jclass clazz) { | 271 static jstring GetDefaultUserAgent(JNIEnv* env, jclass clazz) { |
274 return base::android::ConvertUTF8ToJavaString( | 272 return base::android::ConvertUTF8ToJavaString( |
275 env, content::GetUserAgent(GURL())).Release(); | 273 env, content::GetUserAgent(GURL())).Release(); |
276 } | 274 } |
277 | 275 |
278 bool RegisterAwSettings(JNIEnv* env) { | 276 bool RegisterAwSettings(JNIEnv* env) { |
279 return RegisterNativesImpl(env) >= 0; | 277 return RegisterNativesImpl(env) >= 0; |
280 } | 278 } |
281 | 279 |
282 } // namespace android_webview | 280 } // namespace android_webview |
OLD | NEW |