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