| 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/common/aw_content_client.h" | 8 #include "android_webview/common/aw_content_client.h" |
| 9 #include "android_webview/native/aw_contents.h" | 9 #include "android_webview/native/aw_contents.h" |
| 10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 using base::android::ConvertJavaStringToUTF16; | 23 using base::android::ConvertJavaStringToUTF16; |
| 24 using base::android::ConvertUTF8ToJavaString; | 24 using base::android::ConvertUTF8ToJavaString; |
| 25 using base::android::ScopedJavaLocalRef; | 25 using base::android::ScopedJavaLocalRef; |
| 26 using content::RendererPreferences; | 26 using content::RendererPreferences; |
| 27 using content::WebPreferences; | 27 using content::WebPreferences; |
| 28 | 28 |
| 29 namespace android_webview { | 29 namespace android_webview { |
| 30 | 30 |
| 31 namespace { | 31 namespace { |
| 32 | 32 |
| 33 // TODO(boliu): Deduplicate with chrome/ code. | |
| 34 content::RendererPreferencesHintingEnum GetRendererPreferencesHintingEnum( | |
| 35 gfx::FontRenderParams::Hinting hinting) { | |
| 36 switch (hinting) { | |
| 37 case gfx::FontRenderParams::HINTING_NONE: | |
| 38 return content::RENDERER_PREFERENCES_HINTING_NONE; | |
| 39 case gfx::FontRenderParams::HINTING_SLIGHT: | |
| 40 return content::RENDERER_PREFERENCES_HINTING_SLIGHT; | |
| 41 case gfx::FontRenderParams::HINTING_MEDIUM: | |
| 42 return content::RENDERER_PREFERENCES_HINTING_MEDIUM; | |
| 43 case gfx::FontRenderParams::HINTING_FULL: | |
| 44 return content::RENDERER_PREFERENCES_HINTING_FULL; | |
| 45 default: | |
| 46 NOTREACHED() << "Unhandled hinting style " << hinting; | |
| 47 return content::RENDERER_PREFERENCES_HINTING_SYSTEM_DEFAULT; | |
| 48 } | |
| 49 } | |
| 50 | |
| 51 // TODO(boliu): Deduplicate with chrome/ code. | |
| 52 content::RendererPreferencesSubpixelRenderingEnum | |
| 53 GetRendererPreferencesSubpixelRenderingEnum( | |
| 54 gfx::FontRenderParams::SubpixelRendering subpixel_rendering) { | |
| 55 switch (subpixel_rendering) { | |
| 56 case gfx::FontRenderParams::SUBPIXEL_RENDERING_NONE: | |
| 57 return content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_NONE; | |
| 58 case gfx::FontRenderParams::SUBPIXEL_RENDERING_RGB: | |
| 59 return content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_RGB; | |
| 60 case gfx::FontRenderParams::SUBPIXEL_RENDERING_BGR: | |
| 61 return content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_BGR; | |
| 62 case gfx::FontRenderParams::SUBPIXEL_RENDERING_VRGB: | |
| 63 return content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_VRGB; | |
| 64 case gfx::FontRenderParams::SUBPIXEL_RENDERING_VBGR: | |
| 65 return content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_VBGR; | |
| 66 default: | |
| 67 NOTREACHED() << "Unhandled subpixel rendering style " | |
| 68 << subpixel_rendering; | |
| 69 return content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_SYSTEM_DEFAULT; | |
| 70 } | |
| 71 } | |
| 72 | |
| 73 void PopulateFixedRendererPreferences(RendererPreferences* prefs) { | 33 void PopulateFixedRendererPreferences(RendererPreferences* prefs) { |
| 74 prefs->tap_multiple_targets_strategy = | 34 prefs->tap_multiple_targets_strategy = |
| 75 content::TAP_MULTIPLE_TARGETS_STRATEGY_NONE; | 35 content::TAP_MULTIPLE_TARGETS_STRATEGY_NONE; |
| 76 | 36 |
| 77 // TODO(boliu): Deduplicate with chrome/ code. | 37 // TODO(boliu): Deduplicate with chrome/ code. |
| 78 CR_DEFINE_STATIC_LOCAL(const gfx::FontRenderParams, params, | 38 CR_DEFINE_STATIC_LOCAL(const gfx::FontRenderParams, params, |
| 79 (gfx::GetFontRenderParams(gfx::FontRenderParamsQuery(true), NULL))); | 39 (gfx::GetFontRenderParams(gfx::FontRenderParamsQuery(true), NULL))); |
| 80 prefs->should_antialias_text = params.antialiasing; | 40 prefs->should_antialias_text = params.antialiasing; |
| 81 prefs->use_subpixel_positioning = params.subpixel_positioning; | 41 prefs->use_subpixel_positioning = params.subpixel_positioning; |
| 82 prefs->hinting = GetRendererPreferencesHintingEnum(params.hinting); | 42 prefs->hinting = params.hinting; |
| 83 prefs->use_autohinter = params.autohinter; | 43 prefs->use_autohinter = params.autohinter; |
| 84 prefs->use_bitmaps = params.use_bitmaps; | 44 prefs->use_bitmaps = params.use_bitmaps; |
| 85 prefs->subpixel_rendering = | 45 prefs->subpixel_rendering = params.subpixel_rendering; |
| 86 GetRendererPreferencesSubpixelRenderingEnum(params.subpixel_rendering); | |
| 87 } | 46 } |
| 88 | 47 |
| 89 void PopulateFixedWebPreferences(WebPreferences* web_prefs) { | 48 void PopulateFixedWebPreferences(WebPreferences* web_prefs) { |
| 90 web_prefs->shrinks_standalone_images_to_fit = false; | 49 web_prefs->shrinks_standalone_images_to_fit = false; |
| 91 web_prefs->should_clear_document_background = false; | 50 web_prefs->should_clear_document_background = false; |
| 92 } | 51 } |
| 93 | 52 |
| 94 }; // namespace | 53 }; // namespace |
| 95 | 54 |
| 96 const void* kAwSettingsUserDataKey = &kAwSettingsUserDataKey; | 55 const void* kAwSettingsUserDataKey = &kAwSettingsUserDataKey; |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 | 405 |
| 447 static jstring GetDefaultUserAgent(JNIEnv* env, jclass clazz) { | 406 static jstring GetDefaultUserAgent(JNIEnv* env, jclass clazz) { |
| 448 return base::android::ConvertUTF8ToJavaString(env, GetUserAgent()).Release(); | 407 return base::android::ConvertUTF8ToJavaString(env, GetUserAgent()).Release(); |
| 449 } | 408 } |
| 450 | 409 |
| 451 bool RegisterAwSettings(JNIEnv* env) { | 410 bool RegisterAwSettings(JNIEnv* env) { |
| 452 return RegisterNativesImpl(env); | 411 return RegisterNativesImpl(env); |
| 453 } | 412 } |
| 454 | 413 |
| 455 } // namespace android_webview | 414 } // namespace android_webview |
| OLD | NEW |