1 // Copyright 2014 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 "content/public/common/web_preferences.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 blink::WebSettings
;
17 // "Zyyy" is the ISO 15924 script code for undetermined script aka Common.
18 const char kCommonScript
[] = "Zyyy";
20 #define STATIC_ASSERT_MATCHING_ENUMS(content_name, blink_name) \
22 static_cast<int>(content_name) == static_cast<int>(blink_name), \
23 "mismatching enums: " #content_name)
25 STATIC_ASSERT_MATCHING_ENUMS(EDITING_BEHAVIOR_MAC
,
26 WebSettings::EditingBehaviorMac
);
27 STATIC_ASSERT_MATCHING_ENUMS(EDITING_BEHAVIOR_WIN
,
28 WebSettings::EditingBehaviorWin
);
29 STATIC_ASSERT_MATCHING_ENUMS(EDITING_BEHAVIOR_UNIX
,
30 WebSettings::EditingBehaviorUnix
);
31 STATIC_ASSERT_MATCHING_ENUMS(EDITING_BEHAVIOR_ANDROID
,
32 WebSettings::EditingBehaviorAndroid
);
34 STATIC_ASSERT_MATCHING_ENUMS(V8_CACHE_OPTIONS_DEFAULT
,
35 WebSettings::V8CacheOptionsDefault
);
36 STATIC_ASSERT_MATCHING_ENUMS(V8_CACHE_OPTIONS_NONE
,
37 WebSettings::V8CacheOptionsNone
);
38 STATIC_ASSERT_MATCHING_ENUMS(V8_CACHE_OPTIONS_PARSE
,
39 WebSettings::V8CacheOptionsParse
);
40 STATIC_ASSERT_MATCHING_ENUMS(V8_CACHE_OPTIONS_CODE
,
41 WebSettings::V8CacheOptionsCode
);
42 STATIC_ASSERT_MATCHING_ENUMS(V8_CACHE_OPTIONS_LAST
,
43 WebSettings::V8CacheOptionsCode
);
45 STATIC_ASSERT_MATCHING_ENUMS(IMAGE_ANIMATION_POLICY_ALLOWED
,
46 WebSettings::ImageAnimationPolicyAllowed
);
47 STATIC_ASSERT_MATCHING_ENUMS(IMAGE_ANIMATION_POLICY_ANIMATION_ONCE
,
48 WebSettings::ImageAnimationPolicyAnimateOnce
);
49 STATIC_ASSERT_MATCHING_ENUMS(IMAGE_ANIMATION_POLICY_NO_ANIMATION
,
50 WebSettings::ImageAnimationPolicyNoAnimation
);
52 STATIC_ASSERT_MATCHING_ENUMS(ui::POINTER_TYPE_NONE
,
53 WebSettings::PointerTypeNone
);
54 STATIC_ASSERT_MATCHING_ENUMS(ui::POINTER_TYPE_COARSE
,
55 WebSettings::PointerTypeCoarse
);
56 STATIC_ASSERT_MATCHING_ENUMS(ui::POINTER_TYPE_FINE
,
57 WebSettings::PointerTypeFine
);
59 STATIC_ASSERT_MATCHING_ENUMS(ui::HOVER_TYPE_NONE
,
60 WebSettings::HoverTypeNone
);
61 STATIC_ASSERT_MATCHING_ENUMS(ui::HOVER_TYPE_ON_DEMAND
,
62 WebSettings::HoverTypeOnDemand
);
63 STATIC_ASSERT_MATCHING_ENUMS(ui::HOVER_TYPE_HOVER
,
64 WebSettings::HoverTypeHover
);
66 WebPreferences::WebPreferences()
67 : default_font_size(16),
68 default_fixed_font_size(13),
70 minimum_logical_font_size(6),
71 default_encoding("ISO-8859-1"),
73 context_menu_on_mouse_up(true),
75 context_menu_on_mouse_up(false),
77 javascript_enabled(true),
78 web_security_enabled(true),
79 javascript_can_open_windows_automatically(true),
80 loads_images_automatically(true),
82 plugins_enabled(true),
83 dom_paste_enabled(false), // enables execCommand("paste")
84 shrinks_standalone_images_to_fit(true),
85 uses_universal_detector(false), // Disabled: page cycler regression
86 text_areas_are_resizable(true),
87 allow_scripts_to_close_windows(false),
88 remote_fonts_enabled(true),
89 javascript_can_access_clipboard(false),
91 xss_auditor_enabled(true),
92 dns_prefetching_enabled(true),
93 local_storage_enabled(false),
94 databases_enabled(false),
95 application_cache_enabled(false),
97 caret_browsing_enabled(false),
98 hyperlink_auditing_enabled(true),
100 connection_type(net::NetworkChangeNotifier::CONNECTION_NONE
),
101 allow_universal_access_from_file_urls(false),
102 allow_file_access_from_file_urls(false),
103 webaudio_enabled(false),
104 experimental_webgl_enabled(false),
105 pepper_3d_enabled(false),
106 flash_3d_enabled(true),
107 flash_stage3d_enabled(false),
108 flash_stage3d_baseline_enabled(false),
109 gl_multisampling_enabled(true),
110 privileged_webgl_extensions_enabled(false),
111 webgl_errors_to_console_enabled(true),
112 mock_scrollbars_enabled(false),
113 asynchronous_spell_checking_enabled(true),
114 unified_textchecker_enabled(false),
115 accelerated_2d_canvas_enabled(false),
116 minimum_accelerated_2d_canvas_size(257 * 256),
117 antialiased_2d_canvas_disabled(false),
118 antialiased_clips_2d_canvas_enabled(false),
119 accelerated_2d_canvas_msaa_sample_count(0),
120 accelerated_filters_enabled(false),
121 deferred_filters_enabled(false),
122 container_culling_enabled(false),
123 allow_displaying_insecure_content(true),
124 allow_running_insecure_content(false),
125 disable_reading_from_canvas(false),
126 strict_mixed_content_checking(false),
127 strict_powerful_feature_restrictions(false),
128 strictly_block_blockable_mixed_content(false),
129 block_mixed_plugin_content(false),
130 password_echo_enabled(false),
131 should_print_backgrounds(false),
132 should_clear_document_background(true),
133 enable_scroll_animator(false),
134 touch_enabled(false),
135 device_supports_touch(false),
136 device_supports_mouse(true),
137 touch_adjustment_enabled(true),
138 pointer_events_max_touch_points(0),
139 available_pointer_types(0),
140 primary_pointer_type(ui::POINTER_TYPE_NONE
),
141 available_hover_types(0),
142 primary_hover_type(ui::HOVER_TYPE_NONE
),
143 sync_xhr_in_documents_enabled(true),
144 image_color_profiles_enabled(false),
145 should_respect_image_orientation(false),
146 number_of_cpu_cores(1),
147 #if defined(OS_MACOSX)
148 editing_behavior(EDITING_BEHAVIOR_MAC
),
149 #elif defined(OS_WIN)
150 editing_behavior(EDITING_BEHAVIOR_WIN
),
151 #elif defined(OS_ANDROID)
152 editing_behavior(EDITING_BEHAVIOR_ANDROID
),
153 #elif defined(OS_POSIX)
154 editing_behavior(EDITING_BEHAVIOR_UNIX
),
156 editing_behavior(EDITING_BEHAVIOR_MAC
),
158 supports_multiple_windows(true),
159 viewport_enabled(false),
160 #if defined(OS_ANDROID)
161 viewport_meta_enabled(true),
163 viewport_meta_enabled(false),
165 main_frame_resizes_are_orientation_changes(false),
166 initialize_at_minimum_page_scale(true),
167 #if defined(OS_MACOSX)
168 smart_insert_delete_enabled(true),
170 smart_insert_delete_enabled(false),
172 spatial_navigation_enabled(false),
173 invert_viewport_scroll_order(false),
174 pinch_overlay_scrollbar_thickness(0),
175 use_solid_color_scrollbars(false),
176 navigate_on_drag_drop(true),
177 v8_cache_options(V8_CACHE_OPTIONS_DEFAULT
),
178 slimming_paint_enabled(false),
179 slimming_paint_v2_enabled(false),
180 cookie_enabled(true),
181 pepper_accelerated_video_decode_enabled(false),
182 animation_policy(IMAGE_ANIMATION_POLICY_ALLOWED
),
183 #if defined(OS_ANDROID)
184 text_autosizing_enabled(true),
185 font_scale_factor(1.0f
),
186 device_scale_adjustment(1.0f
),
187 force_enable_zoom(false),
188 fullscreen_supported(true),
189 double_tap_to_zoom_enabled(true),
190 user_gesture_required_for_media_playback(true),
191 support_deprecated_target_density_dpi(false),
192 use_legacy_background_size_shorthand_behavior(false),
193 wide_viewport_quirk(false),
194 use_wide_viewport(true),
195 force_zero_layout_height(false),
196 viewport_meta_layout_size_quirk(false),
197 viewport_meta_merge_content_quirk(false),
198 viewport_meta_non_user_scalable_quirk(false),
199 viewport_meta_zero_values_quirk(false),
200 clobber_user_agent_initial_scale_quirk(false),
201 ignore_main_frame_overflow_hidden_quirk(false),
202 report_screen_size_in_physical_pixels_quirk(false),
203 record_whole_document(false),
205 #if defined(OS_ANDROID)
206 default_minimum_page_scale_factor(0.25f
),
207 default_maximum_page_scale_factor(5.f
)
208 #elif defined(OS_MACOSX)
209 default_minimum_page_scale_factor(1.f
),
210 default_maximum_page_scale_factor(3.f
)
212 default_minimum_page_scale_factor(1.f
),
213 default_maximum_page_scale_factor(4.f
)
216 standard_font_family_map
[kCommonScript
] =
217 base::ASCIIToUTF16("Times New Roman");
218 fixed_font_family_map
[kCommonScript
] = base::ASCIIToUTF16("Courier New");
219 serif_font_family_map
[kCommonScript
] = base::ASCIIToUTF16("Times New Roman");
220 sans_serif_font_family_map
[kCommonScript
] = base::ASCIIToUTF16("Arial");
221 cursive_font_family_map
[kCommonScript
] = base::ASCIIToUTF16("Script");
222 fantasy_font_family_map
[kCommonScript
] = base::ASCIIToUTF16("Impact");
223 pictograph_font_family_map
[kCommonScript
] =
224 base::ASCIIToUTF16("Times New Roman");
227 WebPreferences::~WebPreferences() {
230 } // namespace content