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" |
11 #include "base/android/jni_string.h" | 11 #include "base/android/jni_string.h" |
12 #include "base/command_line.h" | |
13 #include "base/supports_user_data.h" | 12 #include "base/supports_user_data.h" |
14 #include "content/public/browser/navigation_controller.h" | 13 #include "content/public/browser/navigation_controller.h" |
15 #include "content/public/browser/navigation_entry.h" | 14 #include "content/public/browser/navigation_entry.h" |
16 #include "content/public/browser/render_view_host.h" | 15 #include "content/public/browser/render_view_host.h" |
17 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
18 #include "content/public/common/content_switches.h" | |
19 #include "content/public/common/renderer_preferences.h" | 17 #include "content/public/common/renderer_preferences.h" |
20 #include "content/public/common/web_preferences.h" | 18 #include "content/public/common/web_preferences.h" |
21 #include "jni/AwSettings_jni.h" | 19 #include "jni/AwSettings_jni.h" |
22 #include "ui/gfx/font_render_params_linux.h" | 20 #include "ui/gfx/font_render_params_linux.h" |
23 | 21 |
24 using base::android::ConvertJavaStringToUTF16; | 22 using base::android::ConvertJavaStringToUTF16; |
25 using base::android::ConvertUTF8ToJavaString; | 23 using base::android::ConvertUTF8ToJavaString; |
26 using base::android::ScopedJavaLocalRef; | 24 using base::android::ScopedJavaLocalRef; |
27 using content::RendererPreferences; | 25 using content::RendererPreferences; |
28 using content::WebPreferences; | 26 using content::WebPreferences; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
107 return data ? data->settings_ : NULL; | 105 return data ? data->settings_ : NULL; |
108 } | 106 } |
109 | 107 |
110 private: | 108 private: |
111 AwSettings* settings_; | 109 AwSettings* settings_; |
112 }; | 110 }; |
113 | 111 |
114 AwSettings::AwSettings(JNIEnv* env, jobject obj, jlong web_contents) | 112 AwSettings::AwSettings(JNIEnv* env, jobject obj, jlong web_contents) |
115 : WebContentsObserver( | 113 : WebContentsObserver( |
116 reinterpret_cast<content::WebContents*>(web_contents)), | 114 reinterpret_cast<content::WebContents*>(web_contents)), |
117 accelerated_2d_canvas_disabled_by_switch_( | |
118 CommandLine::ForCurrentProcess()->HasSwitch( | |
119 switches::kDisableAccelerated2dCanvas)), | |
120 renderer_prefs_initialized_(false), | 115 renderer_prefs_initialized_(false), |
121 aw_settings_(env, obj) { | 116 aw_settings_(env, obj) { |
122 reinterpret_cast<content::WebContents*>(web_contents)-> | 117 reinterpret_cast<content::WebContents*>(web_contents)-> |
123 SetUserData(kAwSettingsUserDataKey, new AwSettingsUserData(this)); | 118 SetUserData(kAwSettingsUserDataKey, new AwSettingsUserData(this)); |
124 } | 119 } |
125 | 120 |
126 AwSettings::~AwSettings() { | 121 AwSettings::~AwSettings() { |
127 if (web_contents()) { | 122 if (web_contents()) { |
128 web_contents()->SetUserData(kAwSettingsUserDataKey, NULL); | 123 web_contents()->SetUserData(kAwSettingsUserDataKey, NULL); |
129 } | 124 } |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
407 web_prefs->viewport_meta_zero_values_quirk = support_quirks; | 402 web_prefs->viewport_meta_zero_values_quirk = support_quirks; |
408 web_prefs->clobber_user_agent_initial_scale_quirk = support_quirks; | 403 web_prefs->clobber_user_agent_initial_scale_quirk = support_quirks; |
409 web_prefs->ignore_main_frame_overflow_hidden_quirk = support_quirks; | 404 web_prefs->ignore_main_frame_overflow_hidden_quirk = support_quirks; |
410 web_prefs->report_screen_size_in_physical_pixels_quirk = support_quirks; | 405 web_prefs->report_screen_size_in_physical_pixels_quirk = support_quirks; |
411 | 406 |
412 web_prefs->password_echo_enabled = | 407 web_prefs->password_echo_enabled = |
413 Java_AwSettings_getPasswordEchoEnabledLocked(env, obj); | 408 Java_AwSettings_getPasswordEchoEnabledLocked(env, obj); |
414 web_prefs->spatial_navigation_enabled = | 409 web_prefs->spatial_navigation_enabled = |
415 Java_AwSettings_getSpatialNavigationLocked(env, obj); | 410 Java_AwSettings_getSpatialNavigationLocked(env, obj); |
416 | 411 |
412 bool enable_supported_hardware_accelerated_features = | |
413 Java_AwSettings_getEnableSupportedHardwareAcceleratedFeaturesLocked( | |
414 env, obj); | |
415 | |
416 bool accelerated_2d_canvas_enabled_by_switch = | |
417 web_prefs->accelerated_2d_canvas_enabled; | |
no sievers
2014/07/09 22:59:26
So before we specifically looked at the cmdline fo
boliu
2014/07/09 23:03:05
We do still take it into account. This is called f
| |
417 web_prefs->accelerated_2d_canvas_enabled = true; | 418 web_prefs->accelerated_2d_canvas_enabled = true; |
418 if (accelerated_2d_canvas_disabled_by_switch_ || | 419 if (!accelerated_2d_canvas_enabled_by_switch || |
419 !Java_AwSettings_getEnableSupportedHardwareAcceleratedFeaturesLocked( | 420 !enable_supported_hardware_accelerated_features) { |
420 env, obj)) { | |
421 // Any canvas smaller than this will fallback to software. Abusing this | 421 // Any canvas smaller than this will fallback to software. Abusing this |
422 // slightly to turn canvas off without changing | 422 // slightly to turn canvas off without changing |
423 // accelerated_2d_canvas_enabled, which also affects compositing mode. | 423 // accelerated_2d_canvas_enabled, which also affects compositing mode. |
424 // Using 100M instead of max int to avoid overflows. | 424 // Using 100M instead of max int to avoid overflows. |
425 web_prefs->minimum_accelerated_2d_canvas_size = 100 * 1000 * 1000; | 425 web_prefs->minimum_accelerated_2d_canvas_size = 100 * 1000 * 1000; |
426 } | 426 } |
427 web_prefs->experimental_webgl_enabled = | |
428 web_prefs->experimental_webgl_enabled && | |
429 enable_supported_hardware_accelerated_features; | |
427 | 430 |
428 web_prefs->allow_displaying_insecure_content = | 431 web_prefs->allow_displaying_insecure_content = |
429 Java_AwSettings_getAllowDisplayingInsecureContentLocked(env, obj); | 432 Java_AwSettings_getAllowDisplayingInsecureContentLocked(env, obj); |
430 web_prefs->allow_running_insecure_content = | 433 web_prefs->allow_running_insecure_content = |
431 Java_AwSettings_getAllowRunningInsecureContentLocked(env, obj); | 434 Java_AwSettings_getAllowRunningInsecureContentLocked(env, obj); |
432 | 435 |
433 web_prefs->disallow_fullscreen_for_non_media_elements = true; | 436 web_prefs->disallow_fullscreen_for_non_media_elements = true; |
434 } | 437 } |
435 | 438 |
436 static jlong Init(JNIEnv* env, | 439 static jlong Init(JNIEnv* env, |
437 jobject obj, | 440 jobject obj, |
438 jlong web_contents) { | 441 jlong web_contents) { |
439 AwSettings* settings = new AwSettings(env, obj, web_contents); | 442 AwSettings* settings = new AwSettings(env, obj, web_contents); |
440 return reinterpret_cast<intptr_t>(settings); | 443 return reinterpret_cast<intptr_t>(settings); |
441 } | 444 } |
442 | 445 |
443 static jstring GetDefaultUserAgent(JNIEnv* env, jclass clazz) { | 446 static jstring GetDefaultUserAgent(JNIEnv* env, jclass clazz) { |
444 return base::android::ConvertUTF8ToJavaString(env, GetUserAgent()).Release(); | 447 return base::android::ConvertUTF8ToJavaString(env, GetUserAgent()).Release(); |
445 } | 448 } |
446 | 449 |
447 bool RegisterAwSettings(JNIEnv* env) { | 450 bool RegisterAwSettings(JNIEnv* env) { |
448 return RegisterNativesImpl(env); | 451 return RegisterNativesImpl(env); |
449 } | 452 } |
450 | 453 |
451 } // namespace android_webview | 454 } // namespace android_webview |
OLD | NEW |