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
13using base::ASCIIToWide;
14using blink::WebSettings;
15
16WebPreferences::WebPreferences()
17    : default_font_size(16),
18      default_fixed_font_size(13),
19      minimum_font_size(0),
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),
26      images_enabled(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),
33      java_enabled(true),
34      allow_scripts_to_close_windows(false),
35      remote_fonts_enabled(true),
36      javascript_can_access_clipboard(false),
37      xslt_enabled(true),
38      xss_auditor_enabled(true),
39      dns_prefetching_enabled(true),
40      local_storage_enabled(false),
41      databases_enabled(false),
42      application_cache_enabled(false),
43      tabs_to_links(true),
44      caret_browsing_enabled(false),
45      hyperlink_auditing_enabled(true),
46      is_online(true),
47      connection_type(net::NetworkChangeNotifier::CONNECTION_NONE),
48      allow_universal_access_from_file_urls(false),
49      allow_file_access_from_file_urls(false),
50      webaudio_enabled(false),
51      experimental_webgl_enabled(false),
52      pepper_3d_enabled(false),
53      flash_3d_enabled(true),
54      flash_stage3d_enabled(false),
55      flash_stage3d_baseline_enabled(false),
56      gl_multisampling_enabled(true),
57      privileged_webgl_extensions_enabled(false),
58      webgl_errors_to_console_enabled(true),
59      mock_scrollbars_enabled(false),
60      layer_squashing_enabled(true),
61      asynchronous_spell_checking_enabled(true),
62      unified_textchecker_enabled(false),
63      accelerated_compositing_for_video_enabled(true),
64      accelerated_2d_canvas_enabled(false),
65      minimum_accelerated_2d_canvas_size(257 * 256),
66      antialiased_2d_canvas_disabled(false),
67      accelerated_2d_canvas_msaa_sample_count(0),
68      accelerated_filters_enabled(false),
69      deferred_filters_enabled(false),
70      container_culling_enabled(false),
71      gesture_tap_highlight_enabled(false),
72      allow_displaying_insecure_content(true),
73      allow_running_insecure_content(false),
74      password_echo_enabled(false),
75      should_print_backgrounds(false),
76      should_clear_document_background(true),
77      enable_scroll_animator(false),
78      region_based_columns_enabled(false),
79      touch_enabled(false),
80      device_supports_touch(false),
81      device_supports_mouse(true),
82      touch_adjustment_enabled(true),
83      pointer_events_max_touch_points(0),
84      sync_xhr_in_documents_enabled(true),
85      deferred_image_decoding_enabled(false),
86      should_respect_image_orientation(false),
87      number_of_cpu_cores(1),
88#if defined(OS_MACOSX)
89      editing_behavior(webkit_glue::EDITING_BEHAVIOR_MAC),
90#elif defined(OS_WIN)
91      editing_behavior(webkit_glue::EDITING_BEHAVIOR_WIN),
92#elif defined(OS_ANDROID)
93      editing_behavior(webkit_glue::EDITING_BEHAVIOR_ANDROID),
94#elif defined(OS_POSIX)
95      editing_behavior(webkit_glue::EDITING_BEHAVIOR_UNIX),
96#else
97      editing_behavior(webkit_glue::EDITING_BEHAVIOR_MAC),
98#endif
99      supports_multiple_windows(true),
100      viewport_enabled(false),
101      viewport_meta_enabled(false),
102      main_frame_resizes_are_orientation_changes(false),
103      initialize_at_minimum_page_scale(true),
104#if defined(OS_MACOSX)
105      smart_insert_delete_enabled(true),
106#else
107      smart_insert_delete_enabled(false),
108#endif
109      spatial_navigation_enabled(false),
110      pinch_virtual_viewport_enabled(false),
111      pinch_overlay_scrollbar_thickness(0),
112      use_solid_color_scrollbars(false),
113      compositor_touch_hit_testing(true),
114      navigate_on_drag_drop(true),
115      cookie_enabled(true),
116      pepper_accelerated_video_decode_enabled(false)
117#if defined(OS_ANDROID)
118      ,
119      text_autosizing_enabled(true),
120      font_scale_factor(1.0f),
121      device_scale_adjustment(1.0f),
122      force_enable_zoom(false),
123      disallow_fullscreen_for_non_media_elements(false),
124      fullscreen_supported(true),
125      double_tap_to_zoom_enabled(true),
126      user_gesture_required_for_media_playback(true),
127      support_deprecated_target_density_dpi(false),
128      use_legacy_background_size_shorthand_behavior(false),
129      wide_viewport_quirk(false),
130      use_wide_viewport(true),
131      force_zero_layout_height(false),
132      viewport_meta_layout_size_quirk(false),
133      viewport_meta_merge_content_quirk(false),
134      viewport_meta_non_user_scalable_quirk(false),
135      viewport_meta_zero_values_quirk(false),
136      clobber_user_agent_initial_scale_quirk(false),
137      ignore_main_frame_overflow_hidden_quirk(false),
138      report_screen_size_in_physical_pixels_quirk(false)
139#endif
140{
141  standard_font_family_map[webkit_glue::kCommonScript] =
142      base::ASCIIToUTF16("Times New Roman");
143  fixed_font_family_map[webkit_glue::kCommonScript] =
144      base::ASCIIToUTF16("Courier New");
145  serif_font_family_map[webkit_glue::kCommonScript] =
146      base::ASCIIToUTF16("Times New Roman");
147  sans_serif_font_family_map[webkit_glue::kCommonScript] =
148      base::ASCIIToUTF16("Arial");
149  cursive_font_family_map[webkit_glue::kCommonScript] =
150      base::ASCIIToUTF16("Script");
151  fantasy_font_family_map[webkit_glue::kCommonScript] =
152      base::ASCIIToUTF16("Impact");
153  pictograph_font_family_map[webkit_glue::kCommonScript] =
154      base::ASCIIToUTF16("Times New Roman");
155}
156
157WebPreferences::~WebPreferences() {
158}
159
160namespace webkit_glue {
161
162// "Zyyy" is the ISO 15924 script code for undetermined script aka Common.
163const char kCommonScript[] = "Zyyy";
164
165#define COMPILE_ASSERT_MATCHING_ENUMS(webkit_glue_name, webkit_name)         \
166    COMPILE_ASSERT(                                                          \
167        static_cast<int>(webkit_glue_name) == static_cast<int>(webkit_name), \
168        mismatching_enums)
169
170COMPILE_ASSERT_MATCHING_ENUMS(
171    webkit_glue::EDITING_BEHAVIOR_MAC, WebSettings::EditingBehaviorMac);
172COMPILE_ASSERT_MATCHING_ENUMS(
173    webkit_glue::EDITING_BEHAVIOR_WIN, WebSettings::EditingBehaviorWin);
174COMPILE_ASSERT_MATCHING_ENUMS(
175    webkit_glue::EDITING_BEHAVIOR_UNIX, WebSettings::EditingBehaviorUnix);
176COMPILE_ASSERT_MATCHING_ENUMS(
177    webkit_glue::EDITING_BEHAVIOR_ANDROID, WebSettings::EditingBehaviorAndroid);
178
179}  // namespace webkit_glue
180