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); |
77 } | 76 } |
78 | 77 |
79 void AwSettings::UpdateUserAgentLocked(JNIEnv* env, jobject obj) { | 78 void AwSettings::UpdateUserAgentLocked(JNIEnv* env, jobject obj) { |
80 if (!web_contents()) return; | 79 if (!web_contents()) return; |
81 | 80 |
82 ScopedJavaLocalRef<jstring> str = | 81 ScopedJavaLocalRef<jstring> str = |
83 Java_AwSettings_getUserAgentLocked(env, obj); | 82 Java_AwSettings_getUserAgentLocked(env, obj); |
84 bool ua_overidden = str.obj() != NULL; | 83 bool ua_overidden = str.obj() != NULL; |
85 | 84 |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 Java_AwSettings_getInitialPageScalePercentLocked(env, obj); | 223 Java_AwSettings_getInitialPageScalePercentLocked(env, obj); |
225 if (initial_page_scale_percent == 0) { | 224 if (initial_page_scale_percent == 0) { |
226 rvhe->SetInitialPageScale(-1); | 225 rvhe->SetInitialPageScale(-1); |
227 } else { | 226 } else { |
228 float dip_scale = static_cast<float>( | 227 float dip_scale = static_cast<float>( |
229 Java_AwSettings_getDIPScaleLocked(env, obj)); | 228 Java_AwSettings_getDIPScaleLocked(env, obj)); |
230 rvhe->SetInitialPageScale(initial_page_scale_percent / dip_scale / 100.0f); | 229 rvhe->SetInitialPageScale(initial_page_scale_percent / dip_scale / 100.0f); |
231 } | 230 } |
232 } | 231 } |
233 | 232 |
234 void AwSettings::UpdatePreferredSizeMode() { | |
235 if (web_contents()->GetRenderViewHost()) { | |
236 web_contents()->GetRenderViewHost()->EnablePreferredSizeMode(); | |
237 } | |
238 } | |
239 | |
240 void AwSettings::UpdateFormDataPreferencesLocked(JNIEnv* env, jobject obj) { | 233 void AwSettings::UpdateFormDataPreferencesLocked(JNIEnv* env, jobject obj) { |
241 if (!web_contents()) return; | 234 if (!web_contents()) return; |
242 AwContents* contents = AwContents::FromWebContents(web_contents()); | 235 AwContents* contents = AwContents::FromWebContents(web_contents()); |
243 if (!contents) return; | 236 if (!contents) return; |
244 | 237 |
245 contents->SetSaveFormData(Java_AwSettings_getSaveFormDataLocked(env, obj)); | 238 contents->SetSaveFormData(Java_AwSettings_getSaveFormDataLocked(env, obj)); |
246 } | 239 } |
247 | 240 |
248 void AwSettings::RenderViewCreated(content::RenderViewHost* render_view_host) { | 241 void AwSettings::RenderViewCreated(content::RenderViewHost* render_view_host) { |
249 // A single WebContents can normally have 0 to many RenderViewHost instances | 242 // A single WebContents can normally have 0 to many RenderViewHost instances |
(...skipping 24 matching lines...) Expand all Loading... |
274 static jstring GetDefaultUserAgent(JNIEnv* env, jclass clazz) { | 267 static jstring GetDefaultUserAgent(JNIEnv* env, jclass clazz) { |
275 return base::android::ConvertUTF8ToJavaString( | 268 return base::android::ConvertUTF8ToJavaString( |
276 env, content::GetUserAgent(GURL())).Release(); | 269 env, content::GetUserAgent(GURL())).Release(); |
277 } | 270 } |
278 | 271 |
279 bool RegisterAwSettings(JNIEnv* env) { | 272 bool RegisterAwSettings(JNIEnv* env) { |
280 return RegisterNativesImpl(env) >= 0; | 273 return RegisterNativesImpl(env) >= 0; |
281 } | 274 } |
282 | 275 |
283 } // namespace android_webview | 276 } // namespace android_webview |
OLD | NEW |