[M120 Migration][VD] Support EWK Scroll API for TV WebBrowser
[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 prefers_reduced_motion;
124   bool prefers_reduced_transparency;
125   bool inverted_colors;
126   bool touch_event_feature_detection_enabled;
127   int pointer_events_max_touch_points;
128   int available_pointer_types;
129   blink::mojom::PointerType primary_pointer_type;
130   int available_hover_types;
131   blink::mojom::HoverType primary_hover_type;
132   blink::mojom::OutputDeviceUpdateAbilityType output_device_update_ability_type;
133   bool dont_send_key_events_to_javascript;
134   bool barrel_button_for_drag_enabled = false;
135   bool sync_xhr_in_documents_enabled;
136   // TODO(https://crbug.com/1163644): Remove once Chrome Apps are deprecated.
137   bool target_blank_implies_no_opener_enabled_will_be_removed = true;
138   // TODO(https://crbug.com/1172495): Remove once Chrome Apps are deprecated.
139   bool allow_non_empty_navigator_plugins = false;
140   int number_of_cpu_cores;
141   blink::mojom::EditingBehavior editing_behavior;
142   bool supports_multiple_windows;
143   bool viewport_enabled;
144   bool viewport_meta_enabled;
145   bool auto_zoom_focused_editable_to_legible_scale;
146
147   // If true - Blink will clamp the minimum scale factor to the content width,
148   // preventing zoom beyond the visible content. This is really only needed if
149   // viewport_enabled is on.
150   bool shrinks_viewport_contents_to_fit;
151
152   blink::mojom::ViewportStyle viewport_style;
153   bool always_show_context_menu_on_touch;
154   bool smooth_scroll_for_find_enabled;
155   bool main_frame_resizes_are_orientation_changes;
156   bool initialize_at_minimum_page_scale;
157   bool smart_insert_delete_enabled;
158   bool spatial_navigation_enabled;
159   bool fake_no_alloc_direct_call_for_testing_enabled;
160   blink::mojom::V8CacheOptions v8_cache_options;
161   bool record_whole_document;
162
163   // If true, stylus handwriting recognition to text input will be available in
164   // editable input fields which are non-password type.
165   bool stylus_handwriting_enabled;
166
167 #if defined(ENABLE_WRT_JS)
168   // Begin Electron-specific WebPreferences.
169   bool context_isolation;
170   bool is_webview;
171   bool hidden_page;
172   bool offscreen;
173   bool node_integration;
174   bool node_integration_in_worker;
175   bool node_integration_in_sub_frames;
176   bool enable_spellcheck;
177   bool enable_plugins;
178   bool enable_websql;
179   bool webview_tag;
180   // End Electron-specific WebPreferences.
181 #endif
182
183   // This flags corresponds to a Page's Settings' setCookieEnabled state. It
184   // only controls whether or not the "document.cookie" field is properly
185   // connected to the backing store, for instance if you wanted to be able to
186   // define custom getters and setters from within a unique security content
187   // without raising a DOM security exception.
188   bool cookie_enabled;
189
190   // This flag indicates whether H/W accelerated video decode is enabled.
191   // Defaults to false.
192   bool accelerated_video_decode_enabled;
193
194 #if defined(TIZEN_VIDEO_HOLE)
195   bool video_hole_enabled = false;
196 #endif
197
198   blink::mojom::ImageAnimationPolicy animation_policy =
199       blink::mojom::ImageAnimationPolicy::kImageAnimationPolicyAllowed;
200
201   bool user_gesture_required_for_presentation;
202
203   bool text_tracks_enabled;
204
205   // These fields specify the foreground and background color for WebVTT text
206   // tracks. Their values can be any legal CSS color descriptor.
207   std::string text_track_background_color;
208   std::string text_track_text_color;
209
210   // These fields specify values for CSS properties used to style WebVTT text
211   // tracks.
212   // Specifies CSS font-size property in percentage.
213   std::string text_track_text_size;
214   std::string text_track_text_shadow;
215   std::string text_track_font_family;
216   std::string text_track_font_style;
217   // Specifies the value for CSS font-variant property.
218   std::string text_track_font_variant;
219
220   // These fields specify values for CSS properties used to style the window
221   // around WebVTT text tracks.
222   // Window color can be any legal CSS color descriptor.
223   std::string text_track_window_color;
224   // Window radius is in pixels.
225   std::string text_track_window_radius;
226
227   // Specifies the margin for WebVTT text tracks as a percentage of media
228   // element height/width (for horizontal/vertical text respectively).
229   // Cues will not be placed in this margin area.
230   float text_track_margin_percentage;
231
232   bool immersive_mode_enabled;
233
234 #if BUILDFLAG(IS_EFL)
235   float font_scale_factor;
236   bool link_effect_enabled = false;
237   bool atk_enabled;
238   bool force_enable_zoom = false;
239   bool text_zoom_enabled = false;
240   bool selection_magnifier_enabled = false;
241   bool long_press_enabled = false;
242   bool uses_encoding_detector = true;
243 #endif
244
245   bool double_tap_to_zoom_enabled;
246
247   bool fullscreen_supported;
248
249   bool text_autosizing_enabled;
250
251   // Representation of the Web App Manifest scope if any.
252   GURL web_app_scope;
253
254 #if BUILDFLAG(IS_ANDROID)
255   float font_scale_factor;
256   int font_weight_adjustment;
257   int text_size_contrast_factor;
258   float device_scale_adjustment;
259   bool force_enable_zoom;
260   GURL default_video_poster_url;
261   bool support_deprecated_target_density_dpi;
262   bool use_legacy_background_size_shorthand_behavior;
263   bool wide_viewport_quirk;
264   bool use_wide_viewport;
265   bool force_zero_layout_height;
266   bool viewport_meta_merge_content_quirk;
267   bool viewport_meta_non_user_scalable_quirk;
268   bool viewport_meta_zero_values_quirk;
269   bool clobber_user_agent_initial_scale_quirk;
270   bool ignore_main_frame_overflow_hidden_quirk;
271   bool report_screen_size_in_physical_pixels_quirk;
272   // Used by Android_WebView only to support legacy apps that inject script into
273   // a top-level initial empty document and expect it to persist on navigation.
274   bool reuse_global_for_unowned_main_frame;
275   // Specifies default setting for spellcheck when the spellcheck attribute is
276   // not explicitly specified.
277   bool spellcheck_enabled_by_default;
278   // If enabled, when a video goes fullscreen, the orientation should be locked.
279   bool video_fullscreen_orientation_lock_enabled;
280   // If enabled, fullscreen should be entered/exited when the device is rotated
281   // to/from the orientation of the video.
282   bool video_rotate_to_fullscreen_enabled;
283   bool embedded_media_experience_enabled;
284   // Enable 8 (#RRGGBBAA) and 4 (#RGBA) value hex colors in CSS Android
285   // WebView quirk (http://crbug.com/618472).
286   bool css_hex_alpha_color_enabled;
287   // Enable support for document.scrollingElement
288   // WebView sets this to false to retain old documentElement behaviour
289   // (http://crbug.com/761016).
290   bool scroll_top_left_interop_enabled;
291
292   // Don't accelerate small canvases to avoid crashes TODO(crbug.com/1004304)
293   bool disable_accelerated_small_canvases;
294 #endif  // BUILDFLAG(IS_ANDROID)
295
296 // TODO(crbug.com/1284805): Remove IS_ANDROID once WebView supports WebAuthn.
297 // TODO(crbug.com/1382970): Remove IS_FUCHSIA and merge with the block above
298 // once all Content embedders on Fuchsia support WebAuthn.
299 #if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA)
300   // Disable the Web Authentication API.
301   bool disable_webauthn = false;
302 #endif  // BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA)
303
304   // Enable forcibly modifying content rendering to result in a light on dark
305   // color scheme.
306   bool force_dark_mode_enabled = false;
307
308   // Default (used if the page or UA doesn't override these) values for page
309   // scale limits. These are set directly on the WebView so there's no analogue
310   // in WebSettings.
311   float default_minimum_page_scale_factor;
312   float default_maximum_page_scale_factor;
313
314 #if BUILDFLAG(IS_EFL)
315   bool TizenCompatibilityModeEnabled() const {
316     return (tizen_version_major && tizen_version_major < 3);
317   }
318   unsigned tizen_version_major = 7;
319   unsigned tizen_version_minor = 5;
320   unsigned tizen_version_release = 0;
321 #endif
322
323 #if BUILDFLAG(IS_TIZEN_TV)
324   bool media_playback_notification_enabled = false;
325   bool media_subtitle_notification_enabled = false;
326 #endif
327
328   // Whether download UI should be hidden on this page.
329   bool hide_download_ui;
330
331   // Whether it is a presentation receiver.
332   bool presentation_receiver;
333
334   // If disabled, media controls should never be used.
335   bool media_controls_enabled;
336
337   // Whether we want to disable updating selection on mutating selection range.
338   // This is to work around Samsung's email app issue. See
339   // https://crbug.com/699943 for details.
340   // TODO(changwan): remove this once we no longer support Android N.
341   bool do_not_update_selection_on_mutating_selection_range;
342
343 #if BUILDFLAG(IS_TIZEN)
344   int max_refresh_rate;
345 #endif
346
347   // Defines the current autoplay policy.
348   blink::mojom::AutoplayPolicy autoplay_policy =
349       blink::mojom::AutoplayPolicy::kNoUserGestureRequired;
350
351   // `getDisplayMedia()`'s transient activation requirement can be bypassed via
352   // `ScreenCaptureWithoutGestureAllowedForOrigins` policy.
353   bool require_transient_activation_for_get_display_media;
354
355   // `show{OpenFile|SaveFile|Directory}Picker()`'s transient activation
356   // requirement can be bypassed via
357   // `FileOrDirectoryPickerWithoutGestureAllowedForOrigins` policy.
358   bool require_transient_activation_for_show_file_or_directory_picker;
359
360   // The preferred color scheme for the web content. The scheme is used to
361   // evaluate the prefers-color-scheme media query and resolve UA color scheme
362   // to be used based on the supported-color-schemes META tag and CSS property.
363   blink::mojom::PreferredColorScheme preferred_color_scheme =
364       blink::mojom::PreferredColorScheme::kLight;
365
366   // The preferred contrast for the web content. The contrast is used to
367   // evaluate the prefers-contrast media query.
368   blink::mojom::PreferredContrast preferred_contrast =
369       blink::mojom::PreferredContrast::kNoPreference;
370
371   // Network quality threshold below which resources from iframes are assigned
372   // either kVeryLow or kVeryLow Blink priority.
373   EffectiveConnectionType low_priority_iframes_threshold;
374
375   // Whether Picture-in-Picture is enabled.
376   bool picture_in_picture_enabled;
377
378   // Whether a translate service is available.
379   // blink's hrefTranslate attribute existence relies on the result.
380   // See https://github.com/dtapuska/html-translate
381   bool translate_service_available;
382
383   // A value other than
384   // mojom::EffectiveConnectionType::kEffectiveConnectionUnknownType implies
385   // that the network quality estimate related Web APIs are in the holdback
386   // mode. When the holdback is enabled, the related Web APIs return network
387   // quality estimate corresponding to |network_quality_estimator_web_holdback|
388   // regardless of the actual quality.
389   EffectiveConnectionType network_quality_estimator_web_holdback;
390
391   // Whether lazy loading of frames and images is enabled.
392   bool lazy_load_enabled = true;
393
394   // Setting to false disables upgrades to HTTPS for HTTP resources in HTTPS
395   // sites.
396   bool allow_mixed_content_upgrades;
397
398   // Whether the focused element should always be indicated (for example, by
399   // forcing :focus-visible to match regardless of focus method).
400   bool always_show_focus;
401
402   // Whether touch input can trigger HTML drag-and-drop operations. The
403   // default value depends on the platform.
404   bool touch_drag_drop_enabled;
405
406   // Whether the end of a drag fires a contextmenu event and possibly shows a
407   // context-menu (depends on how the event is handled).  Currently touch-drags
408   // cannot show context menus, see crbug.com/1096189.
409   bool touch_dragend_context_menu = false;
410
411   // By default, WebXR's immersive-ar session creation is allowed, but this can
412   // change depending on the enterprise policy if the platform supports it.
413   bool webxr_immersive_ar_allowed = true;
414
415   // Whether lookup of frames in the associated WebView (e.g. lookup via
416   // window.open or via <a target=...>) should be renderer-wide (i.e. going
417   // beyond the usual opener-relationship-based BrowsingInstance boundaries).
418   bool renderer_wide_named_frame_lookup = false;
419
420   // Whether MIME type checking for worker scripts is strict (true) or lax
421   // (false). Used by StrictMimetypeCheckForWorkerScriptsEnabled policy.
422   bool strict_mime_type_check_for_worker_scripts_enabled = true;
423
424 #if BUILDFLAG(IS_TIZEN_TV)
425   // Hosted app need to get local access privilege when they use tv device api
426   // located in local path(file://usr/apps/pepper/webapis/webapis.js)
427   bool allow_file_access_from_external_urls = false;
428
429   // Schemes on which SharedArrayBuffer is enabled unconditionally.
430   // Used in WRT for file:// scheme.
431   std::vector<std::string> additional_shared_array_buffer_schemes;
432
433   bool use_arrow_scroll = false;
434   bool use_scrollbar_thumb_focus_notifications = false;
435 #endif
436
437   // Whether modal context menu is used. A modal context menu meaning it is
438   // blocking user's access to the background web content.
439   bool modal_context_menu = true;
440
441   // We try to keep the default values the same as the default values in
442   // chrome, except for the cases where it would require lots of extra work for
443   // the embedder to use the same default value.
444   WebPreferences();
445   WebPreferences(const WebPreferences& other);
446   WebPreferences(WebPreferences&& other);
447   ~WebPreferences();
448   WebPreferences& operator=(const WebPreferences& other);
449   WebPreferences& operator=(WebPreferences&& other);
450 };
451
452 }  // namespace web_pref
453
454 }  // namespace blink
455
456 #endif  // THIRD_PARTY_BLINK_PUBLIC_COMMON_WEB_PREFERENCES_WEB_PREFERENCES_H_