| 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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 | 181 |
| 182 // static | 182 // static |
| 183 void AwSettings::PopulateFixedPreferences(WebPreferences* web_prefs) { | 183 void AwSettings::PopulateFixedPreferences(WebPreferences* web_prefs) { |
| 184 web_prefs->shrinks_standalone_images_to_fit = false; | 184 web_prefs->shrinks_standalone_images_to_fit = false; |
| 185 web_prefs->should_clear_document_background = false; | 185 web_prefs->should_clear_document_background = false; |
| 186 } | 186 } |
| 187 | 187 |
| 188 void AwSettings::PopulateWebPreferences(WebPreferences* web_prefs) { | 188 void AwSettings::PopulateWebPreferences(WebPreferences* web_prefs) { |
| 189 JNIEnv* env = base::android::AttachCurrentThread(); | 189 JNIEnv* env = base::android::AttachCurrentThread(); |
| 190 CHECK(env); | 190 CHECK(env); |
| 191 ScopedJavaLocalRef<jobject> scoped_obj = aw_settings_.get(env); |
| 192 jobject obj = scoped_obj.obj(); |
| 193 if (!obj) return; |
| 194 // Grab the lock and call PopulateWebPreferencesLocked. |
| 195 Java_AwSettings_populateWebPreferences( |
| 196 env, obj, reinterpret_cast<jlong>(web_prefs)); |
| 197 } |
| 191 | 198 |
| 199 void AwSettings::PopulateWebPreferencesLocked( |
| 200 JNIEnv* env, jobject obj, jlong web_prefs_ptr) { |
| 192 AwRenderViewHostExt* render_view_host_ext = GetAwRenderViewHostExt(); | 201 AwRenderViewHostExt* render_view_host_ext = GetAwRenderViewHostExt(); |
| 193 if (!render_view_host_ext) return; | 202 if (!render_view_host_ext) return; |
| 194 | 203 |
| 195 ScopedJavaLocalRef<jobject> scoped_obj = aw_settings_.get(env); | 204 WebPreferences* web_prefs = reinterpret_cast<WebPreferences*>(web_prefs_ptr); |
| 196 jobject obj = scoped_obj.obj(); | |
| 197 if (!obj) return; | |
| 198 | |
| 199 PopulateFixedPreferences(web_prefs); | 205 PopulateFixedPreferences(web_prefs); |
| 200 | 206 |
| 201 web_prefs->text_autosizing_enabled = | 207 web_prefs->text_autosizing_enabled = |
| 202 Java_AwSettings_getTextAutosizingEnabledLocked(env, obj); | 208 Java_AwSettings_getTextAutosizingEnabledLocked(env, obj); |
| 203 | 209 |
| 204 int text_size_percent = Java_AwSettings_getTextSizePercentLocked(env, obj); | 210 int text_size_percent = Java_AwSettings_getTextSizePercentLocked(env, obj); |
| 205 if (web_prefs->text_autosizing_enabled) { | 211 if (web_prefs->text_autosizing_enabled) { |
| 206 web_prefs->font_scale_factor = text_size_percent / 100.0f; | 212 web_prefs->font_scale_factor = text_size_percent / 100.0f; |
| 207 web_prefs->force_enable_zoom = text_size_percent >= 130; | 213 web_prefs->force_enable_zoom = text_size_percent >= 130; |
| 208 // Use the default zoom factor value when Text Autosizer is turned on. | 214 // Use the default zoom factor value when Text Autosizer is turned on. |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 static jstring GetDefaultUserAgent(JNIEnv* env, jclass clazz) { | 343 static jstring GetDefaultUserAgent(JNIEnv* env, jclass clazz) { |
| 338 return base::android::ConvertUTF8ToJavaString( | 344 return base::android::ConvertUTF8ToJavaString( |
| 339 env, content::GetUserAgent(GURL())).Release(); | 345 env, content::GetUserAgent(GURL())).Release(); |
| 340 } | 346 } |
| 341 | 347 |
| 342 bool RegisterAwSettings(JNIEnv* env) { | 348 bool RegisterAwSettings(JNIEnv* env) { |
| 343 return RegisterNativesImpl(env) >= 0; | 349 return RegisterNativesImpl(env) >= 0; |
| 344 } | 350 } |
| 345 | 351 |
| 346 } // namespace android_webview | 352 } // namespace android_webview |
| OLD | NEW |