| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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_contents.h" | 5 #include "android_webview/native/aw_contents.h" |
| 6 | 6 |
| 7 #include "android_webview/browser/aw_browser_context.h" | 7 #include "android_webview/browser/aw_browser_context.h" |
| 8 #include "android_webview/browser/aw_browser_main_parts.h" | 8 #include "android_webview/browser/aw_browser_main_parts.h" |
| 9 #include "android_webview/browser/gpu_memory_buffer_factory_impl.h" | 9 #include "android_webview/browser/gpu_memory_buffer_factory_impl.h" |
| 10 #include "android_webview/browser/in_process_view_renderer.h" | 10 #include "android_webview/browser/in_process_view_renderer.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 #include "content/public/browser/render_process_host.h" | 44 #include "content/public/browser/render_process_host.h" |
| 45 #include "content/public/browser/render_view_host.h" | 45 #include "content/public/browser/render_view_host.h" |
| 46 #include "content/public/browser/web_contents.h" | 46 #include "content/public/browser/web_contents.h" |
| 47 #include "content/public/common/renderer_preferences.h" | 47 #include "content/public/common/renderer_preferences.h" |
| 48 #include "content/public/common/ssl_status.h" | 48 #include "content/public/common/ssl_status.h" |
| 49 #include "jni/AwContents_jni.h" | 49 #include "jni/AwContents_jni.h" |
| 50 #include "net/cert/x509_certificate.h" | 50 #include "net/cert/x509_certificate.h" |
| 51 #include "third_party/skia/include/core/SkPicture.h" | 51 #include "third_party/skia/include/core/SkPicture.h" |
| 52 #include "ui/base/l10n/l10n_util_android.h" | 52 #include "ui/base/l10n/l10n_util_android.h" |
| 53 #include "ui/gfx/android/java_bitmap.h" | 53 #include "ui/gfx/android/java_bitmap.h" |
| 54 #include "ui/gfx/font_render_params_linux.h" |
| 54 #include "ui/gfx/image/image.h" | 55 #include "ui/gfx/image/image.h" |
| 55 | 56 |
| 56 struct AwDrawSWFunctionTable; | 57 struct AwDrawSWFunctionTable; |
| 57 struct AwDrawGLFunctionTable; | 58 struct AwDrawGLFunctionTable; |
| 58 | 59 |
| 59 using autofill::AutofillDriverImpl; | 60 using autofill::AutofillDriverImpl; |
| 60 using autofill::AutofillManager; | 61 using autofill::AutofillManager; |
| 61 using base::android::AttachCurrentThread; | 62 using base::android::AttachCurrentThread; |
| 62 using base::android::ConvertJavaStringToUTF16; | 63 using base::android::ConvertJavaStringToUTF16; |
| 63 using base::android::ConvertJavaStringToUTF8; | 64 using base::android::ConvertJavaStringToUTF8; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 web_contents->GetUserData(kAwContentsUserDataKey)); | 105 web_contents->GetUserData(kAwContentsUserDataKey)); |
| 105 return data ? data->contents_ : NULL; | 106 return data ? data->contents_ : NULL; |
| 106 } | 107 } |
| 107 | 108 |
| 108 private: | 109 private: |
| 109 AwContents* contents_; | 110 AwContents* contents_; |
| 110 }; | 111 }; |
| 111 | 112 |
| 112 base::subtle::Atomic32 g_instance_count = 0; | 113 base::subtle::Atomic32 g_instance_count = 0; |
| 113 | 114 |
| 115 // TODO(boliu): Deduplicate with chrome/ code. |
| 116 content::RendererPreferencesHintingEnum GetRendererPreferencesHintingEnum( |
| 117 gfx::FontRenderParams::Hinting hinting) { |
| 118 switch (hinting) { |
| 119 case gfx::FontRenderParams::HINTING_NONE: |
| 120 return content::RENDERER_PREFERENCES_HINTING_NONE; |
| 121 case gfx::FontRenderParams::HINTING_SLIGHT: |
| 122 return content::RENDERER_PREFERENCES_HINTING_SLIGHT; |
| 123 case gfx::FontRenderParams::HINTING_MEDIUM: |
| 124 return content::RENDERER_PREFERENCES_HINTING_MEDIUM; |
| 125 case gfx::FontRenderParams::HINTING_FULL: |
| 126 return content::RENDERER_PREFERENCES_HINTING_FULL; |
| 127 default: |
| 128 NOTREACHED() << "Unhandled hinting style " << hinting; |
| 129 return content::RENDERER_PREFERENCES_HINTING_SYSTEM_DEFAULT; |
| 130 } |
| 131 } |
| 132 |
| 133 // TODO(boliu): Deduplicate with chrome/ code. |
| 134 content::RendererPreferencesSubpixelRenderingEnum |
| 135 GetRendererPreferencesSubpixelRenderingEnum( |
| 136 gfx::FontRenderParams::SubpixelRendering subpixel_rendering) { |
| 137 switch (subpixel_rendering) { |
| 138 case gfx::FontRenderParams::SUBPIXEL_RENDERING_NONE: |
| 139 return content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_NONE; |
| 140 case gfx::FontRenderParams::SUBPIXEL_RENDERING_RGB: |
| 141 return content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_RGB; |
| 142 case gfx::FontRenderParams::SUBPIXEL_RENDERING_BGR: |
| 143 return content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_BGR; |
| 144 case gfx::FontRenderParams::SUBPIXEL_RENDERING_VRGB: |
| 145 return content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_VRGB; |
| 146 case gfx::FontRenderParams::SUBPIXEL_RENDERING_VBGR: |
| 147 return content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_VBGR; |
| 148 default: |
| 149 NOTREACHED() << "Unhandled subpixel rendering style " |
| 150 << subpixel_rendering; |
| 151 return content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_SYSTEM_DEFAULT; |
| 152 } |
| 153 } |
| 154 |
| 114 } // namespace | 155 } // namespace |
| 115 | 156 |
| 116 // static | 157 // static |
| 117 AwContents* AwContents::FromWebContents(WebContents* web_contents) { | 158 AwContents* AwContents::FromWebContents(WebContents* web_contents) { |
| 118 return AwContentsUserData::GetContents(web_contents); | 159 return AwContentsUserData::GetContents(web_contents); |
| 119 } | 160 } |
| 120 | 161 |
| 121 // static | 162 // static |
| 122 AwContents* AwContents::FromID(int render_process_id, int render_view_id) { | 163 AwContents* AwContents::FromID(int render_process_id, int render_view_id) { |
| 123 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 164 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 AutofillDriverImpl::CreateForWebContentsAndDelegate( | 252 AutofillDriverImpl::CreateForWebContentsAndDelegate( |
| 212 web_contents, | 253 web_contents, |
| 213 AwAutofillManagerDelegate::FromWebContents(web_contents), | 254 AwAutofillManagerDelegate::FromWebContents(web_contents), |
| 214 l10n_util::GetDefaultLocale(), | 255 l10n_util::GetDefaultLocale(), |
| 215 AutofillManager::DISABLE_AUTOFILL_DOWNLOAD_MANAGER); | 256 AutofillManager::DISABLE_AUTOFILL_DOWNLOAD_MANAGER); |
| 216 } | 257 } |
| 217 | 258 |
| 218 void AwContents::SetAndroidWebViewRendererPrefs() { | 259 void AwContents::SetAndroidWebViewRendererPrefs() { |
| 219 content::RendererPreferences* prefs = | 260 content::RendererPreferences* prefs = |
| 220 web_contents_->GetMutableRendererPrefs(); | 261 web_contents_->GetMutableRendererPrefs(); |
| 221 prefs->hinting = content::RENDERER_PREFERENCES_HINTING_SLIGHT; | |
| 222 prefs->tap_multiple_targets_strategy = | 262 prefs->tap_multiple_targets_strategy = |
| 223 content::TAP_MULTIPLE_TARGETS_STRATEGY_NONE; | 263 content::TAP_MULTIPLE_TARGETS_STRATEGY_NONE; |
| 224 prefs->use_subpixel_positioning = true; | 264 |
| 265 // TODO(boliu): Deduplicate with chrome/ code. |
| 266 const gfx::FontRenderParams& params = gfx::GetDefaultWebKitFontRenderParams(); |
| 267 prefs->should_antialias_text = params.antialiasing; |
| 268 prefs->use_subpixel_positioning = params.subpixel_positioning; |
| 269 prefs->hinting = GetRendererPreferencesHintingEnum(params.hinting); |
| 270 prefs->use_autohinter = params.autohinter; |
| 271 prefs->use_bitmaps = params.use_bitmaps; |
| 272 prefs->subpixel_rendering = |
| 273 GetRendererPreferencesSubpixelRenderingEnum(params.subpixel_rendering); |
| 274 |
| 225 content::RenderViewHost* host = web_contents_->GetRenderViewHost(); | 275 content::RenderViewHost* host = web_contents_->GetRenderViewHost(); |
| 226 if (host) | 276 if (host) |
| 227 host->SyncRendererPrefs(); | 277 host->SyncRendererPrefs(); |
| 228 } | 278 } |
| 229 | 279 |
| 230 void AwContents::SetAwAutofillManagerDelegate(jobject delegate) { | 280 void AwContents::SetAwAutofillManagerDelegate(jobject delegate) { |
| 231 JNIEnv* env = AttachCurrentThread(); | 281 JNIEnv* env = AttachCurrentThread(); |
| 232 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 282 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 233 if (obj.is_null()) | 283 if (obj.is_null()) |
| 234 return; | 284 return; |
| (...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 797 browser_view_renderer_->EnableOnNewPicture(enabled); | 847 browser_view_renderer_->EnableOnNewPicture(enabled); |
| 798 } | 848 } |
| 799 | 849 |
| 800 void AwContents::SetJsOnlineProperty(JNIEnv* env, | 850 void AwContents::SetJsOnlineProperty(JNIEnv* env, |
| 801 jobject obj, | 851 jobject obj, |
| 802 jboolean network_up) { | 852 jboolean network_up) { |
| 803 render_view_host_ext_->SetJsOnlineProperty(network_up); | 853 render_view_host_ext_->SetJsOnlineProperty(network_up); |
| 804 } | 854 } |
| 805 | 855 |
| 806 } // namespace android_webview | 856 } // namespace android_webview |
| OLD | NEW |