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.
5 #include "webkit/common/webpreferences.h"
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"
13 using WebKit::WebSettings
;
15 WebPreferences::WebPreferences()
16 : default_font_size(16),
17 default_fixed_font_size(13),
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),
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),
33 allow_scripts_to_close_windows(false),
34 remote_fonts_enabled(true),
35 javascript_can_access_clipboard(false),
36 xss_auditor_enabled(true),
37 dns_prefetching_enabled(true),
38 local_storage_enabled(false),
39 databases_enabled(false),
40 application_cache_enabled(false),
42 caret_browsing_enabled(false),
43 hyperlink_auditing_enabled(true),
45 user_style_sheet_enabled(false),
46 author_and_user_styles_enabled(true),
47 allow_universal_access_from_file_urls(false),
48 allow_file_access_from_file_urls(false),
49 webaudio_enabled(false),
50 experimental_webgl_enabled(false),
51 flash_3d_enabled(true),
52 flash_stage3d_enabled(false),
53 flash_stage3d_baseline_enabled(false),
54 gl_multisampling_enabled(true),
55 privileged_webgl_extensions_enabled(false),
56 webgl_errors_to_console_enabled(true),
57 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 threaded_html_parser(true),
62 show_paint_rects(false),
63 asynchronous_spell_checking_enabled(true),
64 unified_textchecker_enabled(false),
65 accelerated_compositing_enabled(false),
66 force_compositing_mode(false),
67 accelerated_compositing_for_3d_transforms_enabled(false),
68 accelerated_compositing_for_animation_enabled(false),
69 accelerated_compositing_for_video_enabled(false),
70 accelerated_2d_canvas_enabled(false),
71 minimum_accelerated_2d_canvas_size(257 * 256),
72 antialiased_2d_canvas_disabled(false),
73 accelerated_filters_enabled(false),
74 gesture_tap_highlight_enabled(false),
75 accelerated_compositing_for_plugins_enabled(false),
76 memory_info_enabled(false),
77 fullscreen_enabled(false),
78 allow_displaying_insecure_content(true),
79 allow_running_insecure_content(false),
80 password_echo_enabled(false),
81 should_print_backgrounds(false),
82 enable_scroll_animator(false),
83 visual_word_movement_enabled(false),
84 css_sticky_position_enabled(false),
85 css_shaders_enabled(false),
86 lazy_layout_enabled(false),
87 region_based_columns_enabled(false),
89 device_supports_touch(false),
90 device_supports_mouse(true),
91 touch_adjustment_enabled(true),
92 fixed_position_creates_stacking_context(false),
93 sync_xhr_in_documents_enabled(true),
94 deferred_image_decoding_enabled(false),
95 should_respect_image_orientation(false),
96 number_of_cpu_cores(1),
97 #if defined(OS_MACOSX)
98 editing_behavior(webkit_glue::EDITING_BEHAVIOR_MAC
),
100 editing_behavior(webkit_glue::EDITING_BEHAVIOR_WIN
),
101 #elif defined(OS_ANDROID)
102 editing_behavior(webkit_glue::EDITING_BEHAVIOR_ANDROID
),
103 #elif defined(OS_POSIX)
104 editing_behavior(webkit_glue::EDITING_BEHAVIOR_UNIX
),
106 editing_behavior(webkit_glue::EDITING_BEHAVIOR_MAC
),
108 supports_multiple_windows(true),
109 viewport_enabled(false),
110 initialize_at_minimum_page_scale(true),
111 #if defined(OS_MACOSX)
112 smart_insert_delete_enabled(true),
114 smart_insert_delete_enabled(false),
116 spatial_navigation_enabled(false),
117 experimental_websocket_enabled(false),
118 pinch_virtual_viewport_enabled(false),
119 pinch_overlay_scrollbar_thickness(0),
120 use_solid_color_scrollbars(false),
122 #if defined(OS_ANDROID)
124 text_autosizing_enabled(true),
125 font_scale_factor(1.0f
),
126 force_enable_zoom(false),
127 double_tap_to_zoom_enabled(true),
128 user_gesture_required_for_media_playback(true),
129 support_deprecated_target_density_dpi(false),
130 use_legacy_background_size_shorthand_behavior(false),
131 use_wide_viewport(true),
132 viewport_meta_layout_size_quirk(false),
133 viewport_meta_zero_values_quirk(false)
136 standard_font_family_map
[webkit_glue::kCommonScript
] =
137 ASCIIToUTF16("Times New Roman");
138 fixed_font_family_map
[webkit_glue::kCommonScript
] =
139 ASCIIToUTF16("Courier New");
140 serif_font_family_map
[webkit_glue::kCommonScript
] =
141 ASCIIToUTF16("Times New Roman");
142 sans_serif_font_family_map
[webkit_glue::kCommonScript
] =
143 ASCIIToUTF16("Arial");
144 cursive_font_family_map
[webkit_glue::kCommonScript
] =
145 ASCIIToUTF16("Script");
146 fantasy_font_family_map
[webkit_glue::kCommonScript
] =
147 ASCIIToUTF16("Impact");
148 pictograph_font_family_map
[webkit_glue::kCommonScript
] =
149 ASCIIToUTF16("Times New Roman");
152 WebPreferences::~WebPreferences() {
155 namespace webkit_glue
{
157 // "Zyyy" is the ISO 15924 script code for undetermined script aka Common.
158 const char kCommonScript
[] = "Zyyy";
160 #define COMPILE_ASSERT_MATCHING_ENUMS(webkit_glue_name, webkit_name) \
162 static_cast<int>(webkit_glue_name) == static_cast<int>(webkit_name), \
165 COMPILE_ASSERT_MATCHING_ENUMS(
166 webkit_glue::EDITING_BEHAVIOR_MAC
, WebSettings::EditingBehaviorMac
);
167 COMPILE_ASSERT_MATCHING_ENUMS(
168 webkit_glue::EDITING_BEHAVIOR_WIN
, WebSettings::EditingBehaviorWin
);
169 COMPILE_ASSERT_MATCHING_ENUMS(
170 webkit_glue::EDITING_BEHAVIOR_UNIX
, WebSettings::EditingBehaviorUnix
);
171 COMPILE_ASSERT_MATCHING_ENUMS(
172 webkit_glue::EDITING_BEHAVIOR_ANDROID
, WebSettings::EditingBehaviorAndroid
);
174 } // namespace webkit_glue