| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "webkit/glue/webpreferences.h" | |
| 6 | |
| 7 #include "base/basictypes.h" | |
| 8 #include "base/string_util.h" | |
| 9 #include "base/utf_string_conversions.h" | |
| 10 #include "third_party/WebKit/public/platform/WebSize.h" | |
| 11 #include "third_party/WebKit/public/platform/WebString.h" | |
| 12 #include "third_party/WebKit/public/platform/WebURL.h" | |
| 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNetworkStateNotifi
er.h" | |
| 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h" | |
| 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" | |
| 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSettings.h" | |
| 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | |
| 18 #include "third_party/icu/public/common/unicode/uchar.h" | |
| 19 #include "webkit/glue/webkit_glue.h" | |
| 20 | |
| 21 using WebKit::WebNetworkStateNotifier; | |
| 22 using WebKit::WebRuntimeFeatures; | |
| 23 using WebKit::WebSettings; | |
| 24 using WebKit::WebSize; | |
| 25 using WebKit::WebString; | |
| 26 using WebKit::WebURL; | |
| 27 using WebKit::WebView; | |
| 28 | |
| 29 WebPreferences::WebPreferences() | |
| 30 : default_font_size(16), | |
| 31 default_fixed_font_size(13), | |
| 32 minimum_font_size(0), | |
| 33 minimum_logical_font_size(6), | |
| 34 default_encoding("ISO-8859-1"), | |
| 35 javascript_enabled(true), | |
| 36 web_security_enabled(true), | |
| 37 javascript_can_open_windows_automatically(true), | |
| 38 loads_images_automatically(true), | |
| 39 images_enabled(true), | |
| 40 plugins_enabled(true), | |
| 41 dom_paste_enabled(false), // enables execCommand("paste") | |
| 42 site_specific_quirks_enabled(false), | |
| 43 shrinks_standalone_images_to_fit(true), | |
| 44 uses_universal_detector(false), // Disabled: page cycler regression | |
| 45 text_areas_are_resizable(true), | |
| 46 java_enabled(true), | |
| 47 allow_scripts_to_close_windows(false), | |
| 48 remote_fonts_enabled(true), | |
| 49 javascript_can_access_clipboard(false), | |
| 50 xss_auditor_enabled(true), | |
| 51 dns_prefetching_enabled(true), | |
| 52 local_storage_enabled(false), | |
| 53 databases_enabled(false), | |
| 54 application_cache_enabled(false), | |
| 55 tabs_to_links(true), | |
| 56 caret_browsing_enabled(false), | |
| 57 hyperlink_auditing_enabled(true), | |
| 58 is_online(true), | |
| 59 user_style_sheet_enabled(false), | |
| 60 author_and_user_styles_enabled(true), | |
| 61 allow_universal_access_from_file_urls(false), | |
| 62 allow_file_access_from_file_urls(false), | |
| 63 webaudio_enabled(false), | |
| 64 experimental_webgl_enabled(false), | |
| 65 flash_3d_enabled(true), | |
| 66 flash_stage3d_enabled(false), | |
| 67 flash_stage3d_baseline_enabled(false), | |
| 68 gl_multisampling_enabled(true), | |
| 69 privileged_webgl_extensions_enabled(false), | |
| 70 webgl_errors_to_console_enabled(true), | |
| 71 accelerated_compositing_for_overflow_scroll_enabled(false), | |
| 72 accelerated_compositing_for_scrollable_frames_enabled(false), | |
| 73 composited_scrolling_for_frames_enabled(false), | |
| 74 mock_scrollbars_enabled(false), | |
| 75 threaded_html_parser(true), | |
| 76 show_paint_rects(false), | |
| 77 asynchronous_spell_checking_enabled(true), | |
| 78 unified_textchecker_enabled(false), | |
| 79 accelerated_compositing_enabled(false), | |
| 80 force_compositing_mode(false), | |
| 81 accelerated_compositing_for_3d_transforms_enabled(false), | |
| 82 accelerated_compositing_for_animation_enabled(false), | |
| 83 accelerated_compositing_for_video_enabled(false), | |
| 84 accelerated_2d_canvas_enabled(false), | |
| 85 minimum_accelerated_2d_canvas_size(257 * 256), | |
| 86 antialiased_2d_canvas_disabled(false), | |
| 87 accelerated_filters_enabled(false), | |
| 88 gesture_tap_highlight_enabled(false), | |
| 89 accelerated_compositing_for_plugins_enabled(false), | |
| 90 memory_info_enabled(false), | |
| 91 fullscreen_enabled(false), | |
| 92 allow_displaying_insecure_content(true), | |
| 93 allow_running_insecure_content(false), | |
| 94 password_echo_enabled(false), | |
| 95 should_print_backgrounds(false), | |
| 96 enable_scroll_animator(false), | |
| 97 visual_word_movement_enabled(false), | |
| 98 css_sticky_position_enabled(false), | |
| 99 css_shaders_enabled(false), | |
| 100 css_grid_layout_enabled(false), | |
| 101 lazy_layout_enabled(false), | |
| 102 touch_enabled(false), | |
| 103 device_supports_touch(false), | |
| 104 device_supports_mouse(true), | |
| 105 touch_adjustment_enabled(true), | |
| 106 fixed_position_creates_stacking_context(false), | |
| 107 sync_xhr_in_documents_enabled(true), | |
| 108 deferred_image_decoding_enabled(false), | |
| 109 should_respect_image_orientation(false), | |
| 110 number_of_cpu_cores(1), | |
| 111 #if defined(OS_MACOSX) | |
| 112 editing_behavior(webkit_glue::EDITING_BEHAVIOR_MAC), | |
| 113 #elif defined(OS_WIN) | |
| 114 editing_behavior(webkit_glue::EDITING_BEHAVIOR_WIN), | |
| 115 #elif defined(OS_ANDROID) | |
| 116 editing_behavior(webkit_glue::EDITING_BEHAVIOR_ANDROID), | |
| 117 #elif defined(OS_POSIX) | |
| 118 editing_behavior(webkit_glue::EDITING_BEHAVIOR_UNIX), | |
| 119 #else | |
| 120 editing_behavior(webkit_glue::EDITING_BEHAVIOR_MAC), | |
| 121 #endif | |
| 122 supports_multiple_windows(true), | |
| 123 viewport_enabled(false), | |
| 124 initialize_at_minimum_page_scale(true), | |
| 125 #if defined(OS_MACOSX) | |
| 126 smart_insert_delete_enabled(true), | |
| 127 #else | |
| 128 smart_insert_delete_enabled(false), | |
| 129 #endif | |
| 130 spatial_navigation_enabled(false), | |
| 131 experimental_websocket_enabled(false), | |
| 132 pinch_virtual_viewport_enabled(false), | |
| 133 cookie_enabled(true) | |
| 134 #if defined(OS_ANDROID) | |
| 135 , | |
| 136 text_autosizing_enabled(true), | |
| 137 font_scale_factor(1.0f), | |
| 138 force_enable_zoom(false), | |
| 139 double_tap_to_zoom_enabled(true), | |
| 140 user_gesture_required_for_media_playback(true), | |
| 141 support_deprecated_target_density_dpi(false), | |
| 142 use_wide_viewport(true) | |
| 143 #endif | |
| 144 { | |
| 145 standard_font_family_map[webkit_glue::kCommonScript] = | |
| 146 ASCIIToUTF16("Times New Roman"); | |
| 147 fixed_font_family_map[webkit_glue::kCommonScript] = | |
| 148 ASCIIToUTF16("Courier New"); | |
| 149 serif_font_family_map[webkit_glue::kCommonScript] = | |
| 150 ASCIIToUTF16("Times New Roman"); | |
| 151 sans_serif_font_family_map[webkit_glue::kCommonScript] = | |
| 152 ASCIIToUTF16("Arial"); | |
| 153 cursive_font_family_map[webkit_glue::kCommonScript] = | |
| 154 ASCIIToUTF16("Script"); | |
| 155 fantasy_font_family_map[webkit_glue::kCommonScript] = | |
| 156 ASCIIToUTF16("Impact"); | |
| 157 pictograph_font_family_map[webkit_glue::kCommonScript] = | |
| 158 ASCIIToUTF16("Times New Roman"); | |
| 159 } | |
| 160 | |
| 161 WebPreferences::~WebPreferences() { | |
| 162 } | |
| 163 | |
| 164 namespace { | |
| 165 | |
| 166 void setStandardFontFamilyWrapper(WebSettings* settings, | |
| 167 const base::string16& font, | |
| 168 UScriptCode script) { | |
| 169 settings->setStandardFontFamily(font, script); | |
| 170 } | |
| 171 | |
| 172 void setFixedFontFamilyWrapper(WebSettings* settings, | |
| 173 const base::string16& font, | |
| 174 UScriptCode script) { | |
| 175 settings->setFixedFontFamily(font, script); | |
| 176 } | |
| 177 | |
| 178 void setSerifFontFamilyWrapper(WebSettings* settings, | |
| 179 const base::string16& font, | |
| 180 UScriptCode script) { | |
| 181 settings->setSerifFontFamily(font, script); | |
| 182 } | |
| 183 | |
| 184 void setSansSerifFontFamilyWrapper(WebSettings* settings, | |
| 185 const base::string16& font, | |
| 186 UScriptCode script) { | |
| 187 settings->setSansSerifFontFamily(font, script); | |
| 188 } | |
| 189 | |
| 190 void setCursiveFontFamilyWrapper(WebSettings* settings, | |
| 191 const base::string16& font, | |
| 192 UScriptCode script) { | |
| 193 settings->setCursiveFontFamily(font, script); | |
| 194 } | |
| 195 | |
| 196 void setFantasyFontFamilyWrapper(WebSettings* settings, | |
| 197 const base::string16& font, | |
| 198 UScriptCode script) { | |
| 199 settings->setFantasyFontFamily(font, script); | |
| 200 } | |
| 201 | |
| 202 void setPictographFontFamilyWrapper(WebSettings* settings, | |
| 203 const base::string16& font, | |
| 204 UScriptCode script) { | |
| 205 settings->setPictographFontFamily(font, script); | |
| 206 } | |
| 207 | |
| 208 typedef void (*SetFontFamilyWrapper)( | |
| 209 WebKit::WebSettings*, const base::string16&, UScriptCode); | |
| 210 | |
| 211 // If |scriptCode| is a member of a family of "similar" script codes, returns | |
| 212 // the script code in that family that is used by WebKit for font selection | |
| 213 // purposes. For example, USCRIPT_KATAKANA_OR_HIRAGANA and USCRIPT_JAPANESE are | |
| 214 // considered equivalent for the purposes of font selection. WebKit uses the | |
| 215 // script code USCRIPT_KATAKANA_OR_HIRAGANA. So, if |scriptCode| is | |
| 216 // USCRIPT_JAPANESE, the function returns USCRIPT_KATAKANA_OR_HIRAGANA. WebKit | |
| 217 // uses different scripts than the ones in Chrome pref names because the version | |
| 218 // of ICU included on certain ports does not have some of the newer scripts. If | |
| 219 // |scriptCode| is not a member of such a family, returns |scriptCode|. | |
| 220 UScriptCode GetScriptForWebSettings(UScriptCode scriptCode) { | |
| 221 switch (scriptCode) { | |
| 222 case USCRIPT_HIRAGANA: | |
| 223 case USCRIPT_KATAKANA: | |
| 224 case USCRIPT_JAPANESE: | |
| 225 return USCRIPT_KATAKANA_OR_HIRAGANA; | |
| 226 case USCRIPT_KOREAN: | |
| 227 return USCRIPT_HANGUL; | |
| 228 default: | |
| 229 return scriptCode; | |
| 230 } | |
| 231 } | |
| 232 | |
| 233 void ApplyFontsFromMap(const webkit_glue::ScriptFontFamilyMap& map, | |
| 234 SetFontFamilyWrapper setter, | |
| 235 WebSettings* settings) { | |
| 236 for (webkit_glue::ScriptFontFamilyMap::const_iterator it = map.begin(); | |
| 237 it != map.end(); ++it) { | |
| 238 int32 script = u_getPropertyValueEnum(UCHAR_SCRIPT, (it->first).c_str()); | |
| 239 if (script >= 0 && script < USCRIPT_CODE_LIMIT) { | |
| 240 UScriptCode code = static_cast<UScriptCode>(script); | |
| 241 (*setter)(settings, it->second, GetScriptForWebSettings(code)); | |
| 242 } | |
| 243 } | |
| 244 } | |
| 245 | |
| 246 } // namespace | |
| 247 | |
| 248 namespace webkit_glue { | |
| 249 | |
| 250 // "Zyyy" is the ISO 15924 script code for undetermined script aka Common. | |
| 251 const char kCommonScript[] = "Zyyy"; | |
| 252 | |
| 253 void ApplyWebPreferences(const WebPreferences& prefs, WebView* web_view) { | |
| 254 WebSettings* settings = web_view->settings(); | |
| 255 ApplyFontsFromMap(prefs.standard_font_family_map, | |
| 256 setStandardFontFamilyWrapper, settings); | |
| 257 ApplyFontsFromMap(prefs.fixed_font_family_map, | |
| 258 setFixedFontFamilyWrapper, settings); | |
| 259 ApplyFontsFromMap(prefs.serif_font_family_map, | |
| 260 setSerifFontFamilyWrapper, settings); | |
| 261 ApplyFontsFromMap(prefs.sans_serif_font_family_map, | |
| 262 setSansSerifFontFamilyWrapper, settings); | |
| 263 ApplyFontsFromMap(prefs.cursive_font_family_map, | |
| 264 setCursiveFontFamilyWrapper, settings); | |
| 265 ApplyFontsFromMap(prefs.fantasy_font_family_map, | |
| 266 setFantasyFontFamilyWrapper, settings); | |
| 267 ApplyFontsFromMap(prefs.pictograph_font_family_map, | |
| 268 setPictographFontFamilyWrapper, settings); | |
| 269 settings->setDefaultFontSize(prefs.default_font_size); | |
| 270 settings->setDefaultFixedFontSize(prefs.default_fixed_font_size); | |
| 271 settings->setMinimumFontSize(prefs.minimum_font_size); | |
| 272 settings->setMinimumLogicalFontSize(prefs.minimum_logical_font_size); | |
| 273 settings->setDefaultTextEncodingName(ASCIIToUTF16(prefs.default_encoding)); | |
| 274 settings->setJavaScriptEnabled(prefs.javascript_enabled); | |
| 275 settings->setWebSecurityEnabled(prefs.web_security_enabled); | |
| 276 settings->setJavaScriptCanOpenWindowsAutomatically( | |
| 277 prefs.javascript_can_open_windows_automatically); | |
| 278 settings->setLoadsImagesAutomatically(prefs.loads_images_automatically); | |
| 279 settings->setImagesEnabled(prefs.images_enabled); | |
| 280 settings->setPluginsEnabled(prefs.plugins_enabled); | |
| 281 settings->setDOMPasteAllowed(prefs.dom_paste_enabled); | |
| 282 settings->setNeedsSiteSpecificQuirks(prefs.site_specific_quirks_enabled); | |
| 283 settings->setShrinksStandaloneImagesToFit( | |
| 284 prefs.shrinks_standalone_images_to_fit); | |
| 285 settings->setUsesEncodingDetector(prefs.uses_universal_detector); | |
| 286 settings->setTextAreasAreResizable(prefs.text_areas_are_resizable); | |
| 287 settings->setAllowScriptsToCloseWindows(prefs.allow_scripts_to_close_windows); | |
| 288 if (prefs.user_style_sheet_enabled) | |
| 289 settings->setUserStyleSheetLocation(prefs.user_style_sheet_location); | |
| 290 else | |
| 291 settings->setUserStyleSheetLocation(WebURL()); | |
| 292 settings->setAuthorAndUserStylesEnabled(prefs.author_and_user_styles_enabled); | |
| 293 settings->setDownloadableBinaryFontsEnabled(prefs.remote_fonts_enabled); | |
| 294 settings->setJavaScriptCanAccessClipboard( | |
| 295 prefs.javascript_can_access_clipboard); | |
| 296 settings->setXSSAuditorEnabled(prefs.xss_auditor_enabled); | |
| 297 settings->setDNSPrefetchingEnabled(prefs.dns_prefetching_enabled); | |
| 298 settings->setLocalStorageEnabled(prefs.local_storage_enabled); | |
| 299 settings->setSyncXHRInDocumentsEnabled(prefs.sync_xhr_in_documents_enabled); | |
| 300 WebRuntimeFeatures::enableDatabase(prefs.databases_enabled); | |
| 301 settings->setOfflineWebApplicationCacheEnabled( | |
| 302 prefs.application_cache_enabled); | |
| 303 settings->setCaretBrowsingEnabled(prefs.caret_browsing_enabled); | |
| 304 settings->setHyperlinkAuditingEnabled(prefs.hyperlink_auditing_enabled); | |
| 305 settings->setCookieEnabled(prefs.cookie_enabled); | |
| 306 | |
| 307 // This setting affects the behavior of links in an editable region: | |
| 308 // clicking the link should select it rather than navigate to it. | |
| 309 // Safari uses the same default. It is unlikley an embedder would want to | |
| 310 // change this, since it would break existing rich text editors. | |
| 311 settings->setEditableLinkBehaviorNeverLive(); | |
| 312 | |
| 313 settings->setFontRenderingModeNormal(); | |
| 314 settings->setJavaEnabled(prefs.java_enabled); | |
| 315 | |
| 316 // By default, allow_universal_access_from_file_urls is set to false and thus | |
| 317 // we mitigate attacks from local HTML files by not granting file:// URLs | |
| 318 // universal access. Only test shell will enable this. | |
| 319 settings->setAllowUniversalAccessFromFileURLs( | |
| 320 prefs.allow_universal_access_from_file_urls); | |
| 321 settings->setAllowFileAccessFromFileURLs( | |
| 322 prefs.allow_file_access_from_file_urls); | |
| 323 | |
| 324 // Enable the web audio API if requested on the command line. | |
| 325 settings->setWebAudioEnabled(prefs.webaudio_enabled); | |
| 326 | |
| 327 // Enable experimental WebGL support if requested on command line | |
| 328 // and support is compiled in. | |
| 329 settings->setExperimentalWebGLEnabled(prefs.experimental_webgl_enabled); | |
| 330 | |
| 331 // Disable GL multisampling if requested on command line. | |
| 332 settings->setOpenGLMultisamplingEnabled(prefs.gl_multisampling_enabled); | |
| 333 | |
| 334 // Enable privileged WebGL extensions for Chrome extensions or if requested | |
| 335 // on command line. | |
| 336 settings->setPrivilegedWebGLExtensionsEnabled( | |
| 337 prefs.privileged_webgl_extensions_enabled); | |
| 338 | |
| 339 // Enable WebGL errors to the JS console if requested. | |
| 340 settings->setWebGLErrorsToConsoleEnabled( | |
| 341 prefs.webgl_errors_to_console_enabled); | |
| 342 | |
| 343 // Enables accelerated compositing for overflow scroll. | |
| 344 settings->setAcceleratedCompositingForOverflowScrollEnabled( | |
| 345 prefs.accelerated_compositing_for_overflow_scroll_enabled); | |
| 346 | |
| 347 // Enables accelerated compositing for scrollable frames if requested on | |
| 348 // command line. | |
| 349 settings->setAcceleratedCompositingForScrollableFramesEnabled( | |
| 350 prefs.accelerated_compositing_for_scrollable_frames_enabled); | |
| 351 | |
| 352 // Enables composited scrolling for frames if requested on command line. | |
| 353 settings->setCompositedScrollingForFramesEnabled( | |
| 354 prefs.composited_scrolling_for_frames_enabled); | |
| 355 | |
| 356 // Uses the mock theme engine for scrollbars. | |
| 357 settings->setMockScrollbarsEnabled(prefs.mock_scrollbars_enabled); | |
| 358 | |
| 359 settings->setThreadedHTMLParser(prefs.threaded_html_parser); | |
| 360 | |
| 361 // Display visualization of what has changed on the screen using an | |
| 362 // overlay of rects, if requested on the command line. | |
| 363 settings->setShowPaintRects(prefs.show_paint_rects); | |
| 364 | |
| 365 // Enable gpu-accelerated compositing if requested on the command line. | |
| 366 settings->setAcceleratedCompositingEnabled( | |
| 367 prefs.accelerated_compositing_enabled); | |
| 368 | |
| 369 // Enable gpu-accelerated 2d canvas if requested on the command line. | |
| 370 settings->setAccelerated2dCanvasEnabled(prefs.accelerated_2d_canvas_enabled); | |
| 371 | |
| 372 settings->setMinimumAccelerated2dCanvasSize( | |
| 373 prefs.minimum_accelerated_2d_canvas_size); | |
| 374 | |
| 375 // Disable antialiasing for 2d canvas if requested on the command line. | |
| 376 settings->setAntialiased2dCanvasEnabled( | |
| 377 !prefs.antialiased_2d_canvas_disabled); | |
| 378 | |
| 379 // Enable gpu-accelerated filters if requested on the command line. | |
| 380 settings->setAcceleratedFiltersEnabled(prefs.accelerated_filters_enabled); | |
| 381 | |
| 382 // Enable gesture tap highlight if requested on the command line. | |
| 383 settings->setGestureTapHighlightEnabled(prefs.gesture_tap_highlight_enabled); | |
| 384 | |
| 385 // Enabling accelerated layers from the command line enabled accelerated | |
| 386 // 3D CSS, Video, and Animations. | |
| 387 settings->setAcceleratedCompositingFor3DTransformsEnabled( | |
| 388 prefs.accelerated_compositing_for_3d_transforms_enabled); | |
| 389 settings->setAcceleratedCompositingForVideoEnabled( | |
| 390 prefs.accelerated_compositing_for_video_enabled); | |
| 391 settings->setAcceleratedCompositingForAnimationEnabled( | |
| 392 prefs.accelerated_compositing_for_animation_enabled); | |
| 393 | |
| 394 // Enabling accelerated plugins if specified from the command line. | |
| 395 settings->setAcceleratedCompositingForPluginsEnabled( | |
| 396 prefs.accelerated_compositing_for_plugins_enabled); | |
| 397 | |
| 398 // WebGL and accelerated 2D canvas are always gpu composited. | |
| 399 settings->setAcceleratedCompositingForCanvasEnabled( | |
| 400 prefs.experimental_webgl_enabled || prefs.accelerated_2d_canvas_enabled); | |
| 401 | |
| 402 // Enable memory info reporting to page if requested on the command line. | |
| 403 settings->setMemoryInfoEnabled(prefs.memory_info_enabled); | |
| 404 | |
| 405 settings->setAsynchronousSpellCheckingEnabled( | |
| 406 prefs.asynchronous_spell_checking_enabled); | |
| 407 settings->setUnifiedTextCheckerEnabled(prefs.unified_textchecker_enabled); | |
| 408 | |
| 409 for (webkit_glue::WebInspectorPreferences::const_iterator it = | |
| 410 prefs.inspector_settings.begin(); | |
| 411 it != prefs.inspector_settings.end(); ++it) | |
| 412 web_view->setInspectorSetting(WebString::fromUTF8(it->first), | |
| 413 WebString::fromUTF8(it->second)); | |
| 414 | |
| 415 // Tabs to link is not part of the settings. WebCore calls | |
| 416 // ChromeClient::tabsToLinks which is part of the glue code. | |
| 417 web_view->setTabsToLinks(prefs.tabs_to_links); | |
| 418 | |
| 419 settings->setFullScreenEnabled(prefs.fullscreen_enabled); | |
| 420 settings->setAllowDisplayOfInsecureContent( | |
| 421 prefs.allow_displaying_insecure_content); | |
| 422 settings->setAllowRunningOfInsecureContent( | |
| 423 prefs.allow_running_insecure_content); | |
| 424 settings->setPasswordEchoEnabled(prefs.password_echo_enabled); | |
| 425 settings->setShouldPrintBackgrounds(prefs.should_print_backgrounds); | |
| 426 settings->setEnableScrollAnimator(prefs.enable_scroll_animator); | |
| 427 settings->setVisualWordMovementEnabled(prefs.visual_word_movement_enabled); | |
| 428 | |
| 429 settings->setCSSStickyPositionEnabled(prefs.css_sticky_position_enabled); | |
| 430 settings->setExperimentalCSSCustomFilterEnabled(prefs.css_shaders_enabled); | |
| 431 settings->setExperimentalCSSGridLayoutEnabled(prefs.css_grid_layout_enabled); | |
| 432 | |
| 433 WebRuntimeFeatures::enableLazyLayout(prefs.lazy_layout_enabled); | |
| 434 WebRuntimeFeatures::enableTouch(prefs.touch_enabled); | |
| 435 settings->setDeviceSupportsTouch(prefs.device_supports_touch); | |
| 436 settings->setDeviceSupportsMouse(prefs.device_supports_mouse); | |
| 437 settings->setEnableTouchAdjustment(prefs.touch_adjustment_enabled); | |
| 438 | |
| 439 settings->setFixedPositionCreatesStackingContext( | |
| 440 prefs.fixed_position_creates_stacking_context); | |
| 441 | |
| 442 settings->setDeferredImageDecodingEnabled( | |
| 443 prefs.deferred_image_decoding_enabled); | |
| 444 settings->setShouldRespectImageOrientation( | |
| 445 prefs.should_respect_image_orientation); | |
| 446 | |
| 447 settings->setUnsafePluginPastingEnabled(false); | |
| 448 settings->setEditingBehavior( | |
| 449 static_cast<WebSettings::EditingBehavior>(prefs.editing_behavior)); | |
| 450 | |
| 451 settings->setSupportsMultipleWindows(prefs.supports_multiple_windows); | |
| 452 | |
| 453 settings->setViewportEnabled(prefs.viewport_enabled); | |
| 454 settings->setInitializeAtMinimumPageScale( | |
| 455 prefs.initialize_at_minimum_page_scale); | |
| 456 | |
| 457 settings->setSmartInsertDeleteEnabled(prefs.smart_insert_delete_enabled); | |
| 458 | |
| 459 settings->setSpatialNavigationEnabled(prefs.spatial_navigation_enabled); | |
| 460 | |
| 461 settings->setSelectionIncludesAltImageText(true); | |
| 462 | |
| 463 #if defined(OS_ANDROID) | |
| 464 settings->setAllowCustomScrollbarInMainFrame(false); | |
| 465 settings->setTextAutosizingEnabled(prefs.text_autosizing_enabled); | |
| 466 settings->setTextAutosizingFontScaleFactor(prefs.font_scale_factor); | |
| 467 web_view->setIgnoreViewportTagMaximumScale(prefs.force_enable_zoom); | |
| 468 settings->setAutoZoomFocusedNodeToLegibleScale(true); | |
| 469 settings->setDoubleTapToZoomEnabled(prefs.double_tap_to_zoom_enabled); | |
| 470 settings->setMediaPlaybackRequiresUserGesture( | |
| 471 prefs.user_gesture_required_for_media_playback); | |
| 472 settings->setDefaultVideoPosterURL( | |
| 473 ASCIIToUTF16(prefs.default_video_poster_url.spec())); | |
| 474 settings->setSupportDeprecatedTargetDensityDPI( | |
| 475 prefs.support_deprecated_target_density_dpi); | |
| 476 settings->setUseWideViewport(prefs.use_wide_viewport); | |
| 477 #endif | |
| 478 | |
| 479 WebNetworkStateNotifier::setOnLine(prefs.is_online); | |
| 480 settings->setExperimentalWebSocketEnabled( | |
| 481 prefs.experimental_websocket_enabled); | |
| 482 settings->setPinchVirtualViewportEnabled( | |
| 483 prefs.pinch_virtual_viewport_enabled); | |
| 484 } | |
| 485 | |
| 486 #define COMPILE_ASSERT_MATCHING_ENUMS(webkit_glue_name, webkit_name) \ | |
| 487 COMPILE_ASSERT( \ | |
| 488 static_cast<int>(webkit_glue_name) == static_cast<int>(webkit_name), \ | |
| 489 mismatching_enums) | |
| 490 | |
| 491 COMPILE_ASSERT_MATCHING_ENUMS( | |
| 492 webkit_glue::EDITING_BEHAVIOR_MAC, WebSettings::EditingBehaviorMac); | |
| 493 COMPILE_ASSERT_MATCHING_ENUMS( | |
| 494 webkit_glue::EDITING_BEHAVIOR_WIN, WebSettings::EditingBehaviorWin); | |
| 495 COMPILE_ASSERT_MATCHING_ENUMS( | |
| 496 webkit_glue::EDITING_BEHAVIOR_UNIX, WebSettings::EditingBehaviorUnix); | |
| 497 COMPILE_ASSERT_MATCHING_ENUMS( | |
| 498 webkit_glue::EDITING_BEHAVIOR_ANDROID, WebSettings::EditingBehaviorAndroid); | |
| 499 | |
| 500 } // namespace webkit_glue | |
| OLD | NEW |