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 base::ASCIIToWide
;
14 using blink::WebSettings
;
16 WebPreferences::WebPreferences()
17 : default_font_size(16),
18 default_fixed_font_size(13),
20 minimum_logical_font_size(6),
21 default_encoding("ISO-8859-1"),
22 javascript_enabled(true),
23 web_security_enabled(true),
24 javascript_can_open_windows_automatically(true),
25 loads_images_automatically(true),
27 plugins_enabled(true),
28 dom_paste_enabled(false), // enables execCommand("paste")
29 site_specific_quirks_enabled(false),
30 shrinks_standalone_images_to_fit(true),
31 uses_universal_detector(false), // Disabled: page cycler regression
32 text_areas_are_resizable(true),
34 allow_scripts_to_close_windows(false),
35 remote_fonts_enabled(true),
36 javascript_can_access_clipboard(false),
38 xss_auditor_enabled(true),
39 dns_prefetching_enabled(true),
40 local_storage_enabled(false),
41 databases_enabled(false),
42 application_cache_enabled(false),
44 caret_browsing_enabled(false),
45 hyperlink_auditing_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 pepper_3d_enabled(false),
52 flash_3d_enabled(true),
53 flash_stage3d_enabled(false),
54 flash_stage3d_baseline_enabled(false),
55 gl_multisampling_enabled(true),
56 privileged_webgl_extensions_enabled(false),
57 webgl_errors_to_console_enabled(true),
58 mock_scrollbars_enabled(false),
59 layer_squashing_enabled(false),
60 threaded_html_parser(true),
61 show_paint_rects(false),
62 asynchronous_spell_checking_enabled(true),
63 unified_textchecker_enabled(false),
64 accelerated_compositing_enabled(false),
65 force_compositing_mode(false),
66 accelerated_compositing_for_3d_transforms_enabled(false),
67 accelerated_compositing_for_animation_enabled(false),
68 accelerated_compositing_for_video_enabled(false),
69 accelerated_2d_canvas_enabled(false),
70 minimum_accelerated_2d_canvas_size(257 * 256),
71 antialiased_2d_canvas_disabled(false),
72 accelerated_2d_canvas_msaa_sample_count(0),
73 accelerated_filters_enabled(false),
74 deferred_filters_enabled(false),
75 container_culling_enabled(false),
76 gesture_tap_highlight_enabled(false),
77 accelerated_compositing_for_plugins_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 should_clear_document_background(true),
83 enable_scroll_animator(false),
84 visual_word_movement_enabled(false),
85 lazy_layout_enabled(false),
86 region_based_columns_enabled(false),
88 device_supports_touch(false),
89 device_supports_mouse(true),
90 touch_adjustment_enabled(true),
91 pointer_events_max_touch_points(0),
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 viewport_meta_enabled(false),
111 main_frame_resizes_are_orientation_changes(false),
112 initialize_at_minimum_page_scale(true),
113 #if defined(OS_MACOSX)
114 smart_insert_delete_enabled(true),
116 smart_insert_delete_enabled(false),
118 spatial_navigation_enabled(false),
119 pinch_virtual_viewport_enabled(false),
120 pinch_overlay_scrollbar_thickness(0),
121 use_solid_color_scrollbars(false),
122 compositor_touch_hit_testing(true),
123 navigate_on_drag_drop(true),
124 cookie_enabled(true),
125 pepper_accelerated_video_decode_enabled(false)
126 #if defined(OS_ANDROID)
128 text_autosizing_enabled(true),
129 font_scale_factor(1.0f
),
130 device_scale_adjustment(1.0f
),
131 force_enable_zoom(false),
132 double_tap_to_zoom_enabled(true),
133 user_gesture_required_for_media_playback(true),
134 support_deprecated_target_density_dpi(false),
135 use_legacy_background_size_shorthand_behavior(false),
136 wide_viewport_quirk(false),
137 use_wide_viewport(true),
138 viewport_meta_layout_size_quirk(false),
139 viewport_meta_merge_content_quirk(false),
140 viewport_meta_non_user_scalable_quirk(false),
141 viewport_meta_zero_values_quirk(false),
142 clobber_user_agent_initial_scale_quirk(false),
143 ignore_main_frame_overflow_hidden_quirk(false),
144 report_screen_size_in_physical_pixels_quirk(false)
147 standard_font_family_map
[webkit_glue::kCommonScript
] =
148 base::ASCIIToUTF16("Times New Roman");
149 fixed_font_family_map
[webkit_glue::kCommonScript
] =
150 base::ASCIIToUTF16("Courier New");
151 serif_font_family_map
[webkit_glue::kCommonScript
] =
152 base::ASCIIToUTF16("Times New Roman");
153 sans_serif_font_family_map
[webkit_glue::kCommonScript
] =
154 base::ASCIIToUTF16("Arial");
155 cursive_font_family_map
[webkit_glue::kCommonScript
] =
156 base::ASCIIToUTF16("Script");
157 fantasy_font_family_map
[webkit_glue::kCommonScript
] =
158 base::ASCIIToUTF16("Impact");
159 pictograph_font_family_map
[webkit_glue::kCommonScript
] =
160 base::ASCIIToUTF16("Times New Roman");
163 WebPreferences::~WebPreferences() {
166 namespace webkit_glue
{
168 // "Zyyy" is the ISO 15924 script code for undetermined script aka Common.
169 const char kCommonScript
[] = "Zyyy";
171 #define COMPILE_ASSERT_MATCHING_ENUMS(webkit_glue_name, webkit_name) \
173 static_cast<int>(webkit_glue_name) == static_cast<int>(webkit_name), \
176 COMPILE_ASSERT_MATCHING_ENUMS(
177 webkit_glue::EDITING_BEHAVIOR_MAC
, WebSettings::EditingBehaviorMac
);
178 COMPILE_ASSERT_MATCHING_ENUMS(
179 webkit_glue::EDITING_BEHAVIOR_WIN
, WebSettings::EditingBehaviorWin
);
180 COMPILE_ASSERT_MATCHING_ENUMS(
181 webkit_glue::EDITING_BEHAVIOR_UNIX
, WebSettings::EditingBehaviorUnix
);
182 COMPILE_ASSERT_MATCHING_ENUMS(
183 webkit_glue::EDITING_BEHAVIOR_ANDROID
, WebSettings::EditingBehaviorAndroid
);
185 } // namespace webkit_glue