[Android] Implement 3-way sensor fallback for Device Orientation.
[chromium-blink-merge.git] / content / public / common / web_preferences.cc
blob11803fa050ef2a0701e533bab3eec2c9219d2314
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;
15 namespace content {
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) \
21 static_assert( \
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),
69 minimum_font_size(0),
70 minimum_logical_font_size(6),
71 default_encoding("ISO-8859-1"),
72 #if defined(OS_WIN)
73 context_menu_on_mouse_up(true),
74 #else
75 context_menu_on_mouse_up(false),
76 #endif
77 javascript_enabled(true),
78 web_security_enabled(true),
79 javascript_can_open_windows_automatically(true),
80 loads_images_automatically(true),
81 images_enabled(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 java_enabled(true),
88 allow_scripts_to_close_windows(false),
89 remote_fonts_enabled(true),
90 javascript_can_access_clipboard(false),
91 xslt_enabled(true),
92 xss_auditor_enabled(true),
93 dns_prefetching_enabled(true),
94 local_storage_enabled(false),
95 databases_enabled(false),
96 application_cache_enabled(false),
97 tabs_to_links(true),
98 caret_browsing_enabled(false),
99 hyperlink_auditing_enabled(true),
100 is_online(true),
101 connection_type(net::NetworkChangeNotifier::CONNECTION_NONE),
102 allow_universal_access_from_file_urls(false),
103 allow_file_access_from_file_urls(false),
104 webaudio_enabled(false),
105 experimental_webgl_enabled(false),
106 pepper_3d_enabled(false),
107 flash_3d_enabled(true),
108 flash_stage3d_enabled(false),
109 flash_stage3d_baseline_enabled(false),
110 gl_multisampling_enabled(true),
111 privileged_webgl_extensions_enabled(false),
112 webgl_errors_to_console_enabled(true),
113 mock_scrollbars_enabled(false),
114 asynchronous_spell_checking_enabled(true),
115 unified_textchecker_enabled(false),
116 accelerated_2d_canvas_enabled(false),
117 minimum_accelerated_2d_canvas_size(257 * 256),
118 antialiased_2d_canvas_disabled(false),
119 antialiased_clips_2d_canvas_enabled(false),
120 accelerated_2d_canvas_msaa_sample_count(0),
121 accelerated_filters_enabled(false),
122 deferred_filters_enabled(false),
123 container_culling_enabled(false),
124 allow_displaying_insecure_content(true),
125 allow_running_insecure_content(false),
126 disable_reading_from_canvas(false),
127 strict_mixed_content_checking(false),
128 strict_powerful_feature_restrictions(false),
129 strictly_block_blockable_mixed_content(false),
130 block_mixed_plugin_content(false),
131 password_echo_enabled(false),
132 should_print_backgrounds(false),
133 should_clear_document_background(true),
134 enable_scroll_animator(false),
135 touch_enabled(false),
136 device_supports_touch(false),
137 device_supports_mouse(true),
138 touch_adjustment_enabled(true),
139 pointer_events_max_touch_points(0),
140 available_pointer_types(0),
141 primary_pointer_type(ui::POINTER_TYPE_NONE),
142 available_hover_types(0),
143 primary_hover_type(ui::HOVER_TYPE_NONE),
144 sync_xhr_in_documents_enabled(true),
145 image_color_profiles_enabled(false),
146 should_respect_image_orientation(false),
147 number_of_cpu_cores(1),
148 #if defined(OS_MACOSX)
149 editing_behavior(EDITING_BEHAVIOR_MAC),
150 #elif defined(OS_WIN)
151 editing_behavior(EDITING_BEHAVIOR_WIN),
152 #elif defined(OS_ANDROID)
153 editing_behavior(EDITING_BEHAVIOR_ANDROID),
154 #elif defined(OS_POSIX)
155 editing_behavior(EDITING_BEHAVIOR_UNIX),
156 #else
157 editing_behavior(EDITING_BEHAVIOR_MAC),
158 #endif
159 supports_multiple_windows(true),
160 viewport_enabled(false),
161 viewport_meta_enabled(false),
162 main_frame_resizes_are_orientation_changes(false),
163 initialize_at_minimum_page_scale(true),
164 #if defined(OS_MACOSX)
165 smart_insert_delete_enabled(true),
166 #else
167 smart_insert_delete_enabled(false),
168 #endif
169 spatial_navigation_enabled(false),
170 invert_viewport_scroll_order(false),
171 pinch_overlay_scrollbar_thickness(0),
172 use_solid_color_scrollbars(false),
173 navigate_on_drag_drop(true),
174 v8_cache_options(V8_CACHE_OPTIONS_DEFAULT),
175 slimming_paint_enabled(false),
176 slimming_paint_v2_enabled(false),
177 cookie_enabled(true),
178 pepper_accelerated_video_decode_enabled(false),
179 animation_policy(IMAGE_ANIMATION_POLICY_ALLOWED),
180 #if defined(OS_ANDROID)
181 text_autosizing_enabled(true),
182 font_scale_factor(1.0f),
183 device_scale_adjustment(1.0f),
184 force_enable_zoom(false),
185 fullscreen_supported(true),
186 double_tap_to_zoom_enabled(true),
187 user_gesture_required_for_media_playback(true),
188 support_deprecated_target_density_dpi(false),
189 use_legacy_background_size_shorthand_behavior(false),
190 wide_viewport_quirk(false),
191 use_wide_viewport(true),
192 force_zero_layout_height(false),
193 viewport_meta_layout_size_quirk(false),
194 viewport_meta_merge_content_quirk(false),
195 viewport_meta_non_user_scalable_quirk(false),
196 viewport_meta_zero_values_quirk(false),
197 clobber_user_agent_initial_scale_quirk(false),
198 ignore_main_frame_overflow_hidden_quirk(false),
199 report_screen_size_in_physical_pixels_quirk(false),
200 #endif
201 #if defined(OS_ANDROID)
202 default_minimum_page_scale_factor(0.25f),
203 default_maximum_page_scale_factor(5.f)
204 #elif defined(OS_MACOSX)
205 default_minimum_page_scale_factor(1.f),
206 default_maximum_page_scale_factor(3.f)
207 #else
208 default_minimum_page_scale_factor(1.f),
209 default_maximum_page_scale_factor(4.f)
210 #endif
212 standard_font_family_map[kCommonScript] =
213 base::ASCIIToUTF16("Times New Roman");
214 fixed_font_family_map[kCommonScript] = base::ASCIIToUTF16("Courier New");
215 serif_font_family_map[kCommonScript] = base::ASCIIToUTF16("Times New Roman");
216 sans_serif_font_family_map[kCommonScript] = base::ASCIIToUTF16("Arial");
217 cursive_font_family_map[kCommonScript] = base::ASCIIToUTF16("Script");
218 fantasy_font_family_map[kCommonScript] = base::ASCIIToUTF16("Impact");
219 pictograph_font_family_map[kCommonScript] =
220 base::ASCIIToUTF16("Times New Roman");
223 WebPreferences::~WebPreferences() {
226 } // namespace content