[M108 Migration] Support encoding property for WRT config.xml
[platform/framework/web/chromium-efl.git] / third_party / blink / public / common / web_preferences / web_preferences.h
1 // Copyright 2014 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef THIRD_PARTY_BLINK_PUBLIC_COMMON_WEB_PREFERENCES_WEB_PREFERENCES_H_
6 #define THIRD_PARTY_BLINK_PUBLIC_COMMON_WEB_PREFERENCES_WEB_PREFERENCES_H_
7
8 #include <map>
9 #include <string>
10 #include <vector>
11
12 #include "build/build_config.h"
13 #include "net/nqe/effective_connection_type.h"
14 #include "third_party/blink/public/common/common_export.h"
15 #include "third_party/blink/public/mojom/css/preferred_color_scheme.mojom-shared.h"
16 #include "third_party/blink/public/mojom/css/preferred_contrast.mojom-shared.h"
17 #include "third_party/blink/public/mojom/v8_cache_options.mojom-forward.h"
18 #include "third_party/blink/public/mojom/webpreferences/web_preferences.mojom-shared.h"
19 #include "url/gurl.h"
20 #include "url/origin.h"
21
22 #if defined(ENABLE_WRT_JS)
23 #include "base/files/file_path.h"
24 #endif
25
26 namespace blink {
27
28 class WebView;
29
30 namespace web_pref {
31
32 using blink::mojom::EffectiveConnectionType;
33
34 // Map of ISO 15924 four-letter script code to font family.  For example,
35 // "Arab" to "My Arabic Font".
36 typedef std::map<std::string, std::u16string> ScriptFontFamilyMap;
37
38 // The ISO 15924 script code for undetermined script aka Common. It's the
39 // default used on WebKit's side to get/set a font setting when no script is
40 // specified.
41 BLINK_COMMON_EXPORT extern const char kCommonScript[];
42
43 // A struct for managing blink's settings.
44 //
45 // Adding new values to this class probably involves updating
46 // blink::WebSettings,
47 // browser/profiles/profile.cc, and
48 // content/public/common/common_param_traits_macros.h
49 struct BLINK_COMMON_EXPORT WebPreferences {
50   ScriptFontFamilyMap standard_font_family_map;
51   ScriptFontFamilyMap fixed_font_family_map;
52   ScriptFontFamilyMap serif_font_family_map;
53   ScriptFontFamilyMap sans_serif_font_family_map;
54   ScriptFontFamilyMap cursive_font_family_map;
55   ScriptFontFamilyMap fantasy_font_family_map;
56   ScriptFontFamilyMap math_font_family_map;
57   int default_font_size;
58   int default_fixed_font_size;
59   int minimum_font_size;
60   int minimum_logical_font_size;
61   std::string default_encoding;
62   bool context_menu_on_mouse_up;
63   bool javascript_enabled;
64   bool web_security_enabled;
65   bool loads_images_automatically;
66   bool images_enabled;
67   bool plugins_enabled;
68   bool dom_paste_enabled;
69   bool shrinks_standalone_images_to_fit;
70   bool text_areas_are_resizable;
71   bool allow_scripts_to_close_windows;
72   bool remote_fonts_enabled;
73   bool javascript_can_access_clipboard;
74   // We don't use dns_prefetching_enabled to disable DNS prefetching.  Instead,
75   // we disable the feature at a lower layer so that we catch non-WebKit uses
76   // of DNS prefetch as well.
77   bool dns_prefetching_enabled;
78   // Preference to save data. When enabled, requests will contain the header
79   // 'Save-Data: on'.
80   bool data_saver_enabled;
81   bool local_storage_enabled;
82   bool databases_enabled;
83   bool tabs_to_links;
84   bool disable_ipc_flooding_protection;
85   bool hyperlink_auditing_enabled;
86   bool allow_universal_access_from_file_urls;
87   bool allow_file_access_from_file_urls;
88   bool webgl1_enabled;
89   bool webgl2_enabled;
90   bool pepper_3d_enabled;
91   bool privileged_webgl_extensions_enabled;
92   bool webgl_errors_to_console_enabled;
93   bool hide_scrollbars;
94   // If false, ignore ::-webkit-scrollbar-* CSS pseudo-elements in stylesheets.
95   bool enable_webkit_scrollbar_styling = true;
96   bool accelerated_2d_canvas_enabled;
97   bool canvas_2d_layers_enabled = false;
98   bool antialiased_2d_canvas_disabled;
99   bool antialiased_clips_2d_canvas_enabled;
100   bool accelerated_filters_enabled;
101   bool deferred_filters_enabled;
102   bool container_culling_enabled;
103   bool allow_running_insecure_content;
104   // If true, taints all <canvas> elements, regardless of origin.
105   bool disable_reading_from_canvas;
106   // Strict mixed content checking disables both displaying and running insecure
107   // mixed content, and disables embedder notifications that such content was
108   // requested (thereby preventing user override).
109   bool strict_mixed_content_checking;
110   // Strict powerful feature restrictions block insecure usage of powerful
111   // features (like device orientation) that we haven't yet disabled for the web
112   // at large.
113   bool strict_powerful_feature_restrictions;
114   // TODO(jww): Remove when WebView no longer needs this exception.
115   bool allow_geolocation_on_insecure_origins;
116   // Disallow user opt-in for blockable mixed content.
117   bool strictly_block_blockable_mixed_content;
118   bool block_mixed_plugin_content;
119   bool password_echo_enabled;
120   bool should_print_backgrounds;
121   bool should_clear_document_background;
122   bool enable_scroll_animator;
123   bool threaded_scrolling_enabled;
124   bool prefers_reduced_motion;
125   bool touch_event_feature_detection_enabled;
126   int pointer_events_max_touch_points;
127   int available_pointer_types;
128   blink::mojom::PointerType primary_pointer_type;
129   int available_hover_types;
130   blink::mojom::HoverType primary_hover_type;
131   bool dont_send_key_events_to_javascript;
132   bool barrel_button_for_drag_enabled = false;
133   bool sync_xhr_in_documents_enabled;
134   // TODO(https://crbug.com/1163644): Remove once Chrome Apps are deprecated.
135   bool target_blank_implies_no_opener_enabled_will_be_removed = true;
136   // TODO(https://crbug.com/1172495): Remove once Chrome Apps are deprecated.
137   bool allow_non_empty_navigator_plugins = false;
138   int number_of_cpu_cores;
139   blink::mojom::EditingBehavior editing_behavior;
140   bool supports_multiple_windows;
141   bool viewport_enabled;
142   bool viewport_meta_enabled;
143   bool auto_zoom_focused_editable_to_legible_scale;
144
145   // If true - Blink will clamp the minimum scale factor to the content width,
146   // preventing zoom beyond the visible content. This is really only needed if
147   // viewport_enabled is on.
148   bool shrinks_viewport_contents_to_fit;
149
150   blink::mojom::ViewportStyle viewport_style;
151   bool always_show_context_menu_on_touch;
152   bool smooth_scroll_for_find_enabled;
153   bool main_frame_resizes_are_orientation_changes;
154   bool initialize_at_minimum_page_scale;
155   bool smart_insert_delete_enabled;
156   bool spatial_navigation_enabled;
157   bool navigate_on_drag_drop;
158   bool fake_no_alloc_direct_call_for_testing_enabled;
159   blink::mojom::V8CacheOptions v8_cache_options;
160   bool record_whole_document;
161
162   // If true, stylus handwriting recognition to text input will be available in
163   // editable input fields which are non-password type.
164   bool stylus_handwriting_enabled;
165
166 #if defined(ENABLE_WRT_JS)
167   // Begin Electron-specific WebPreferences.
168   bool context_isolation;
169   bool is_webview;
170   bool hidden_page;
171   bool offscreen;
172   bool node_integration;
173   bool node_integration_in_worker;
174   bool node_integration_in_sub_frames;
175   bool enable_spellcheck;
176   bool enable_plugins;
177   bool enable_websql;
178   bool webview_tag;
179   // End Electron-specific WebPreferences.
180 #endif
181
182   // This flags corresponds to a Page's Settings' setCookieEnabled state. It
183   // only controls whether or not the "document.cookie" field is properly
184   // connected to the backing store, for instance if you wanted to be able to
185   // define custom getters and setters from within a unique security content
186   // without raising a DOM security exception.
187   bool cookie_enabled;
188
189   // This flag indicates whether H/W accelerated video decode is enabled.
190   // Defaults to false.
191   bool accelerated_video_decode_enabled;
192
193 #if defined(TIZEN_VIDEO_HOLE)
194   bool video_hole_enabled = false;
195 #endif
196
197   blink::mojom::ImageAnimationPolicy animation_policy =
198       blink::mojom::ImageAnimationPolicy::kImageAnimationPolicyAllowed;
199
200   bool user_gesture_required_for_presentation;
201
202   bool text_tracks_enabled;
203
204   // These fields specify the foreground and background color for WebVTT text
205   // tracks. Their values can be any legal CSS color descriptor.
206   std::string text_track_background_color;
207   std::string text_track_text_color;
208
209   // These fields specify values for CSS properties used to style WebVTT text
210   // tracks.
211   // Specifies CSS font-size property in percentage.
212   std::string text_track_text_size;
213   std::string text_track_text_shadow;
214   std::string text_track_font_family;
215   std::string text_track_font_style;
216   // Specifies the value for CSS font-variant property.
217   std::string text_track_font_variant;
218
219   // These fields specify values for CSS properties used to style the window
220   // around WebVTT text tracks.
221   // Window color can be any legal CSS color descriptor.
222   std::string text_track_window_color;
223   // Window radius is in pixels.
224   std::string text_track_window_radius;
225
226   // Specifies the margin for WebVTT text tracks as a percentage of media
227   // element height/width (for horizontal/vertical text respectively).
228   // Cues will not be placed in this margin area.
229   float text_track_margin_percentage;
230
231   bool immersive_mode_enabled;
232
233 #if BUILDFLAG(IS_EFL)
234   float font_scale_factor;
235   bool link_effect_enabled = false;
236   bool atk_enabled;
237   bool force_enable_zoom = false;
238   bool text_zoom_enabled = false;
239   bool selection_magnifier_enabled = false;
240   bool long_press_enabled = false;
241   bool uses_encoding_detector = true;
242 #endif
243
244   bool double_tap_to_zoom_enabled;
245
246   bool fullscreen_supported;
247
248   bool text_autosizing_enabled;
249
250   // Representation of the Web App Manifest scope if any.
251   GURL web_app_scope;
252
253 #if BUILDFLAG(IS_ANDROID)
254   float font_scale_factor;
255   float device_scale_adjustment;
256   bool force_enable_zoom;
257   GURL default_video_poster_url;
258   bool support_deprecated_target_density_dpi;
259   bool use_legacy_background_size_shorthand_behavior;
260   bool wide_viewport_quirk;
261   bool use_wide_viewport;
262   bool force_zero_layout_height;
263   bool viewport_meta_merge_content_quirk;
264   bool viewport_meta_non_user_scalable_quirk;
265   bool viewport_meta_zero_values_quirk;
266   bool clobber_user_agent_initial_scale_quirk;
267   bool ignore_main_frame_overflow_hidden_quirk;
268   bool report_screen_size_in_physical_pixels_quirk;
269   // Used by Android_WebView only to support legacy apps that inject script into
270   // a top-level initial empty document and expect it to persist on navigation.
271   bool reuse_global_for_unowned_main_frame;
272   // Specifies default setting for spellcheck when the spellcheck attribute is
273   // not explicitly specified.
274   bool spellcheck_enabled_by_default;
275   // If enabled, when a video goes fullscreen, the orientation should be locked.
276   bool video_fullscreen_orientation_lock_enabled;
277   // If enabled, fullscreen should be entered/exited when the device is rotated
278   // to/from the orientation of the video.
279   bool video_rotate_to_fullscreen_enabled;
280   bool embedded_media_experience_enabled;
281   // Enable 8 (#RRGGBBAA) and 4 (#RGBA) value hex colors in CSS Android
282   // WebView quirk (http://crbug.com/618472).
283   bool css_hex_alpha_color_enabled;
284   // Enable support for document.scrollingElement
285   // WebView sets this to false to retain old documentElement behaviour
286   // (http://crbug.com/761016).
287   bool scroll_top_left_interop_enabled;
288
289   // Don't accelerate small canvases to avoid crashes TODO(crbug.com/1004304)
290   bool disable_accelerated_small_canvases;
291   // Disable the Web Authentication API.
292   bool disable_webauthn = false;
293 #endif  // BUILDFLAG(IS_ANDROID)
294
295   // Enable forcibly modifying content rendering to result in a light on dark
296   // color scheme.
297   bool force_dark_mode_enabled = false;
298
299   // Default (used if the page or UA doesn't override these) values for page
300   // scale limits. These are set directly on the WebView so there's no analogue
301   // in WebSettings.
302   float default_minimum_page_scale_factor;
303   float default_maximum_page_scale_factor;
304
305 #if BUILDFLAG(IS_EFL)
306   bool TizenCompatibilityModeEnabled() const {
307     return (tizen_version_major && tizen_version_major < 3);
308   }
309   unsigned tizen_version_major = 7;
310   unsigned tizen_version_minor = 5;
311   unsigned tizen_version_release = 0;
312 #endif
313
314   // Whether download UI should be hidden on this page.
315   bool hide_download_ui;
316
317   // Whether it is a presentation receiver.
318   bool presentation_receiver;
319
320   // If disabled, media controls should never be used.
321   bool media_controls_enabled;
322
323   // Whether we want to disable updating selection on mutating selection range.
324   // This is to work around Samsung's email app issue. See
325   // https://crbug.com/699943 for details.
326   // TODO(changwan): remove this once we no longer support Android N.
327   bool do_not_update_selection_on_mutating_selection_range;
328
329 #if BUILDFLAG(IS_TIZEN)
330   int max_refresh_rate;
331 #endif
332
333   // Defines the current autoplay policy.
334   blink::mojom::AutoplayPolicy autoplay_policy =
335       blink::mojom::AutoplayPolicy::kNoUserGestureRequired;
336
337   // The preferred color scheme for the web content. The scheme is used to
338   // evaluate the prefers-color-scheme media query and resolve UA color scheme
339   // to be used based on the supported-color-schemes META tag and CSS property.
340   blink::mojom::PreferredColorScheme preferred_color_scheme =
341       blink::mojom::PreferredColorScheme::kLight;
342
343   // The preferred contrast for the web content. The contrast is used to
344   // evaluate the prefers-contrast media query.
345   blink::mojom::PreferredContrast preferred_contrast =
346       blink::mojom::PreferredContrast::kNoPreference;
347
348   // Network quality threshold below which resources from iframes are assigned
349   // either kVeryLow or kVeryLow Blink priority.
350   EffectiveConnectionType low_priority_iframes_threshold;
351
352   // Whether Picture-in-Picture is enabled.
353   bool picture_in_picture_enabled;
354
355   // Whether a translate service is available.
356   // blink's hrefTranslate attribute existence relies on the result.
357   // See https://github.com/dtapuska/html-translate
358   bool translate_service_available;
359
360   // A value other than
361   // mojom::EffectiveConnectionType::kEffectiveConnectionUnknownType implies
362   // that the network quality estimate related Web APIs are in the holdback
363   // mode. When the holdback is enabled, the related Web APIs return network
364   // quality estimate corresponding to |network_quality_estimator_web_holdback|
365   // regardless of the actual quality.
366   EffectiveConnectionType network_quality_estimator_web_holdback;
367
368   // Whether lazy loading of frames and images is enabled.
369   bool lazy_load_enabled = true;
370
371   // Specifies how close a lazily loaded iframe or image should be from the
372   // viewport before it should start being loaded in, depending on the effective
373   // connection type of the current network. Blink will use the default distance
374   // threshold for effective connection types that aren't specified here.
375   std::map<EffectiveConnectionType, int>
376       lazy_frame_loading_distance_thresholds_px;
377   std::map<EffectiveConnectionType, int>
378       lazy_image_loading_distance_thresholds_px;
379   std::map<EffectiveConnectionType, int> lazy_image_first_k_fully_load;
380
381   // Setting to false disables upgrades to HTTPS for HTTP resources in HTTPS
382   // sites.
383   bool allow_mixed_content_upgrades;
384
385   // Whether the focused element should always be indicated (for example, by
386   // forcing :focus-visible to match regardless of focus method).
387   bool always_show_focus;
388
389   // Whether touch input can trigger HTML drag-and-drop operations. The
390   // default value depends on the platform.
391   bool touch_drag_drop_enabled;
392
393   // Whether the end of a drag fires a contextmenu event and possibly shows a
394   // context-menu (depends on how the event is handled).  Currently touch-drags
395   // cannot show context menus, see crbug.com/1096189.
396   bool touch_dragend_context_menu = false;
397
398   // By default, WebXR's immersive-ar session creation is allowed, but this can
399   // change depending on the enterprise policy if the platform supports it.
400   bool webxr_immersive_ar_allowed = true;
401
402   // Whether lookup of frames in the associated WebView (e.g. lookup via
403   // window.open or via <a target=...>) should be renderer-wide (i.e. going
404   // beyond the usual opener-relationship-based BrowsingInstance boundaries).
405   bool renderer_wide_named_frame_lookup = false;
406
407   // Whether MIME type checking for worker scripts is strict (true) or lax
408   // (false). Used by StrictMimetypeCheckForWorkerScriptsEnabled policy.
409   bool strict_mime_type_check_for_worker_scripts_enabled = true;
410
411   // We try to keep the default values the same as the default values in
412   // chrome, except for the cases where it would require lots of extra work for
413   // the embedder to use the same default value.
414   WebPreferences();
415   WebPreferences(const WebPreferences& other);
416   WebPreferences(WebPreferences&& other);
417   ~WebPreferences();
418   WebPreferences& operator=(const WebPreferences& other);
419   WebPreferences& operator=(WebPreferences&& other);
420 };
421
422 }  // namespace web_pref
423
424 }  // namespace blink
425
426 #endif  // THIRD_PARTY_BLINK_PUBLIC_COMMON_WEB_PREFERENCES_WEB_PREFERENCES_H_