1 // Copyright 2013 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/common/webpreferences.h" 6 7 #include "base/basictypes.h" 8 #include "base/strings/string_util.h" 9 #include "base/strings/utf_string_conversions.h" 10 #include "third_party/WebKit/public/web/WebSettings.h" 11 #include "third_party/icu/source/common/unicode/uchar.h" 12 13 using blink::WebSettings; 14 15 WebPreferences::WebPreferences() 16 : default_font_size(16), 17 default_fixed_font_size(13), 18 minimum_font_size(0), 19 minimum_logical_font_size(6), 20 default_encoding("ISO-8859-1"), 21 javascript_enabled(true), 22 web_security_enabled(true), 23 javascript_can_open_windows_automatically(true), 24 loads_images_automatically(true), 25 images_enabled(true), 26 plugins_enabled(true), 27 dom_paste_enabled(false), // enables execCommand("paste") 28 site_specific_quirks_enabled(false), 29 shrinks_standalone_images_to_fit(true), 30 uses_universal_detector(false), // Disabled: page cycler regression 31 text_areas_are_resizable(true), 32 java_enabled(true), 33 allow_scripts_to_close_windows(false), 34 remote_fonts_enabled(true), 35 javascript_can_access_clipboard(false), 36 xslt_enabled(true), 37 xss_auditor_enabled(true), 38 dns_prefetching_enabled(true), 39 local_storage_enabled(false), 40 databases_enabled(false), 41 application_cache_enabled(false), 42 tabs_to_links(true), 43 caret_browsing_enabled(false), 44 hyperlink_auditing_enabled(true), 45 is_online(true), 46 allow_universal_access_from_file_urls(false), 47 allow_file_access_from_file_urls(false), 48 webaudio_enabled(false), 49 experimental_webgl_enabled(false), 50 flash_3d_enabled(true), 51 flash_stage3d_enabled(false), 52 flash_stage3d_baseline_enabled(false), 53 gl_multisampling_enabled(true), 54 privileged_webgl_extensions_enabled(false), 55 webgl_errors_to_console_enabled(true), 56 accelerated_compositing_for_overflow_scroll_enabled(false), 57 universal_accelerated_compositing_for_overflow_scroll_enabled(false), 58 accelerated_compositing_for_scrollable_frames_enabled(false), 59 composited_scrolling_for_frames_enabled(false), 60 mock_scrollbars_enabled(false), 61 layer_squashing_enabled(false), 62 threaded_html_parser(true), 63 show_paint_rects(false), 64 asynchronous_spell_checking_enabled(true), 65 unified_textchecker_enabled(false), 66 accelerated_compositing_enabled(false), 67 force_compositing_mode(false), 68 accelerated_compositing_for_3d_transforms_enabled(false), 69 accelerated_compositing_for_animation_enabled(false), 70 accelerated_compositing_for_video_enabled(false), 71 accelerated_2d_canvas_enabled(false), 72 minimum_accelerated_2d_canvas_size(257 * 256), 73 antialiased_2d_canvas_disabled(false), 74 accelerated_2d_canvas_msaa_sample_count(0), 75 accelerated_filters_enabled(false), 76 gesture_tap_highlight_enabled(false), 77 accelerated_compositing_for_plugins_enabled(false), 78 memory_info_enabled(false), 79 fullscreen_enabled(false), 80 allow_displaying_insecure_content(true), 81 allow_running_insecure_content(false), 82 password_echo_enabled(false), 83 should_print_backgrounds(false), 84 should_clear_document_background(true), 85 enable_scroll_animator(false), 86 visual_word_movement_enabled(false), 87 lazy_layout_enabled(false), 88 region_based_columns_enabled(false), 89 touch_enabled(false), 90 device_supports_touch(false), 91 device_supports_mouse(true), 92 touch_adjustment_enabled(true), 93 pointer_events_max_touch_points(0), 94 fixed_position_creates_stacking_context(false), 95 sync_xhr_in_documents_enabled(true), 96 deferred_image_decoding_enabled(false), 97 should_respect_image_orientation(false), 98 number_of_cpu_cores(1), 99 #if defined(OS_MACOSX) 100 editing_behavior(webkit_glue::EDITING_BEHAVIOR_MAC), 101 #elif defined(OS_WIN) 102 editing_behavior(webkit_glue::EDITING_BEHAVIOR_WIN), 103 #elif defined(OS_ANDROID) 104 editing_behavior(webkit_glue::EDITING_BEHAVIOR_ANDROID), 105 #elif defined(OS_POSIX) 106 editing_behavior(webkit_glue::EDITING_BEHAVIOR_UNIX), 107 #else 108 editing_behavior(webkit_glue::EDITING_BEHAVIOR_MAC), 109 #endif 110 supports_multiple_windows(true), 111 viewport_enabled(false), 112 viewport_meta_enabled(false), 113 main_frame_resizes_are_orientation_changes(false), 114 initialize_at_minimum_page_scale(true), 115 #if defined(OS_MACOSX) 116 smart_insert_delete_enabled(true), 117 #else 118 smart_insert_delete_enabled(false), 119 #endif 120 spatial_navigation_enabled(false), 121 experimental_websocket_enabled(false), 122 pinch_virtual_viewport_enabled(false), 123 pinch_overlay_scrollbar_thickness(0), 124 use_solid_color_scrollbars(false), 125 compositor_touch_hit_testing(true), 126 cookie_enabled(true) 127 #if defined(OS_ANDROID) 128 , 129 text_autosizing_enabled(true), 130 font_scale_factor(1.0f), 131 device_scale_adjustment(1.0f), 132 force_enable_zoom(false), 133 double_tap_to_zoom_enabled(true), 134 user_gesture_required_for_media_playback(true), 135 user_gesture_required_for_media_fullscreen(true), 136 support_deprecated_target_density_dpi(false), 137 use_legacy_background_size_shorthand_behavior(false), 138 wide_viewport_quirk(false), 139 use_wide_viewport(true), 140 viewport_meta_layout_size_quirk(false), 141 viewport_meta_merge_content_quirk(false), 142 viewport_meta_non_user_scalable_quirk(false), 143 viewport_meta_zero_values_quirk(false), 144 clobber_user_agent_initial_scale_quirk(false), 145 ignore_main_frame_overflow_hidden_quirk(false), 146 report_screen_size_in_physical_pixels_quirk(false) 147 #endif 148 { 149 standard_font_family_map[webkit_glue::kCommonScript] = 150 ASCIIToUTF16("Times New Roman"); 151 fixed_font_family_map[webkit_glue::kCommonScript] = 152 ASCIIToUTF16("Courier New"); 153 serif_font_family_map[webkit_glue::kCommonScript] = 154 ASCIIToUTF16("Times New Roman"); 155 sans_serif_font_family_map[webkit_glue::kCommonScript] = 156 ASCIIToUTF16("Arial"); 157 cursive_font_family_map[webkit_glue::kCommonScript] = 158 ASCIIToUTF16("Script"); 159 fantasy_font_family_map[webkit_glue::kCommonScript] = 160 ASCIIToUTF16("Impact"); 161 pictograph_font_family_map[webkit_glue::kCommonScript] = 162 ASCIIToUTF16("Times New Roman"); 163 } 164 165 WebPreferences::~WebPreferences() { 166 } 167 168 namespace webkit_glue { 169 170 // "Zyyy" is the ISO 15924 script code for undetermined script aka Common. 171 const char kCommonScript[] = "Zyyy"; 172 173 #define COMPILE_ASSERT_MATCHING_ENUMS(webkit_glue_name, webkit_name) \ 174 COMPILE_ASSERT( \ 175 static_cast<int>(webkit_glue_name) == static_cast<int>(webkit_name), \ 176 mismatching_enums) 177 178 COMPILE_ASSERT_MATCHING_ENUMS( 179 webkit_glue::EDITING_BEHAVIOR_MAC, WebSettings::EditingBehaviorMac); 180 COMPILE_ASSERT_MATCHING_ENUMS( 181 webkit_glue::EDITING_BEHAVIOR_WIN, WebSettings::EditingBehaviorWin); 182 COMPILE_ASSERT_MATCHING_ENUMS( 183 webkit_glue::EDITING_BEHAVIOR_UNIX, WebSettings::EditingBehaviorUnix); 184 COMPILE_ASSERT_MATCHING_ENUMS( 185 webkit_glue::EDITING_BEHAVIOR_ANDROID, WebSettings::EditingBehaviorAndroid); 186 187 } // namespace webkit_glue 188