chromium/third_party/blink/public/mojom/renderer_preferences.mojom

// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

module blink.mojom;

import "mojo/public/mojom/base/string16.mojom";
import "mojo/public/mojom/base/time.mojom";
import "ui/gfx/mojom/font_render_params.mojom";
import "third_party/blink/public/mojom/user_agent/user_agent_metadata.mojom";

const int64 kDefaultCaretBlinkIntervalInMilliseconds = 500;

// User preferences needed to be passed to the renderer process.
struct RendererPreferences {
  // Whether the renderer's current browser context accept drops from the OS
  // that result in navigations away from the current page.
  bool can_accept_load_drops = true;

  // Whether text should be antialiased.
  // Currently only used by Linux.
  bool should_antialias_text = true;

  // The level of hinting to use when rendering text.
  // Currently only used by Linux.
  gfx.mojom.Hinting hinting = gfx.mojom.Hinting.kMedium;

  // Whether auto hinter should be used. Currently only used by Linux.
  bool use_autohinter = false;

  // Whether embedded bitmap strikes in fonts should be used.
  // Currently only used by Linux.
  bool use_bitmaps = false;

  // The type of subpixel rendering to use for text.
  // Currently only used by Linux and Windows.
  gfx.mojom.SubpixelRendering subpixel_rendering =
    gfx.mojom.SubpixelRendering.kNone;

  // Whether subpixel positioning should be used, permitting fractional X
  // positions for glyphs.  Currently only used by Linux.
  bool use_subpixel_positioning = false;

  // Gamma correction and contrast values for glyph rendering. Currently
  // only used by Windows.
  [EnableIf=is_win]
  float text_contrast = 0.5;
  [EnableIf=is_win]
  float text_gamma = 0.0;

  // The color of the focus ring.
  uint32 focus_ring_color = 0xFFE59700;

  // The colors used in selection text. Currently only used on Linux and Ash.
  // Note: these must match the values in renderer_preferences.h.
  uint32 active_selection_bg_color = 0xFF1967D2;
  [EnableIf=is_android]
  uint32 active_selection_fg_color = 0xFF000000;
  [EnableIfNot=is_android]
  uint32 active_selection_fg_color = 0xFFFFFFFF;
  uint32 inactive_selection_bg_color = 0xFFC8C8C8;
  uint32 inactive_selection_fg_color = 0xFF323232;

  // Browser wants a look at all top-level navigation requests.
  bool browser_handles_all_top_level_requests = false;

  // Cursor blink rate.
  // On Linux, uses |gtk-cursor-blink| from GtkSettings.
  // On platforms with views toolkit, uses the system value from ui::NativeTheme.
  // Note: Null |caret_blink_interval| should be interpreted as the default
  // value kDefaultCaretBlinkIntervalInMilliseconds.
  mojo_base.mojom.TimeDelta? caret_blink_interval;

  // Whether or not to set custom colors at all.
  bool use_custom_colors = true;

  // Set to false to not send referrers.
  bool enable_referrers = true;

  // Set to true to allow third-party sub-content to pop-up HTTP basic auth
  // dialog boxes.
  bool allow_cross_origin_auth_prompt = false;

  // Set to true to indicate that the preference to set DNT to 1 is enabled.
  bool enable_do_not_track = false;

  // Whether to allow the use of Encrypted Media Extensions (EME), except for
  // the use of Clear Key key system which is always allowed as required by the
  // spec.
  bool enable_encrypted_media = true;

  // This is the IP handling policy override for WebRTC. The value must be one
  // of the strings defined in privacy.json. The allowed values are specified
  // in webrtc_ip_handling_policy.h.
  string webrtc_ip_handling_policy;

  // This is the range of UDP ports allowed to be used by WebRTC. A value of
  // zero in both fields means all ports are allowed.
  uint16 webrtc_udp_min_port = 0;
  uint16 webrtc_udp_max_port = 0;

  array<string> webrtc_local_ips_allowed_urls;

  // The user agent given to WebKit when it requests one and the user agent is
  // being overridden for the current navigation.
  UserAgentOverride user_agent_override;

  // The accept-languages of the browser, comma-separated.
  string accept_languages;

  // Whether renderers need to send SubresourceResponseStarted IPC to
  // the browser. Renderers send the IPC if user has allowed any certificate or HTTP
  // exceptions and we keep sending subresource notifications to the browser
  // until all HTTPS-related warning exceptions have been revoked and the
  // browser is restarted.
  bool send_subresource_notification = false;

  // Determines whether plugins are allowed to enter fullscreen mode.
  bool plugin_fullscreen_allowed = true;

  // Whether or not caret browsing is enabled.
  bool caret_browsing_enabled = false;

  [EnableIf=renderer_pref_system_font_family_name]
  string system_font_family_name;

  // The default system font settings for caption, small caption, menu and
  // status messages. Used only by Windows.
  // TODO(https://crbug.com/869748): Consolidate all fields below into a new
  // Win-only mojom struct to avoid using a [EnableIf=is_win] for each of them.
  [EnableIf=is_win]
  mojo_base.mojom.String16 caption_font_family_name;
  [EnableIf=is_win]
  int32 caption_font_height = 0;

  [EnableIf=is_win]
  mojo_base.mojom.String16 small_caption_font_family_name;
  [EnableIf=is_win]
  int32 small_caption_font_height = 0;

  [EnableIf=is_win]
  mojo_base.mojom.String16 menu_font_family_name;
  [EnableIf=is_win]
  int32 menu_font_height = 0;

  [EnableIf=is_win]
  mojo_base.mojom.String16 status_font_family_name;
  [EnableIf=is_win]
  int32 status_font_height = 0;

  [EnableIf=is_win]
  mojo_base.mojom.String16 message_font_family_name;
  [EnableIf=is_win]
  int32 message_font_height = 0;

  // The width of a vertical scroll bar in dips.
  [EnableIf=is_win]
  int32 vertical_scroll_bar_width_in_dips = 0;

  // The height of a horizontal scroll bar in dips.
  [EnableIf=is_win]
  int32 horizontal_scroll_bar_height_in_dips = 0;

  // The height of the arrow bitmap on a vertical scroll bar in dips.
  [EnableIf=is_win]
  int32 arrow_bitmap_height_vertical_scroll_bar_in_dips = 0;

  // The width of the arrow bitmap on a horizontal scroll bar in dips.
  [EnableIf=is_win]
  int32 arrow_bitmap_width_horizontal_scroll_bar_in_dips = 0;

  // Whether the selection clipboard buffer is available.  Linux environments
  // may support this.
  [EnableIf=is_selection_clipboard_buffer_possible]
  bool selection_clipboard_buffer_available = false;

  array<uint16> explicitly_allowed_network_ports;

  // Whether the prefixed video-specific fullscreen APIs (e.g.
  // video.webkitEnterFullscreen() and others) are available or not.
  // - If not set, the availability of the APIs is determined by the
  //   PrefixedVideoFullscreen RuntimeEnabled feature.
  // - If set, enables/disables the APIs by overriding the
  //   PrefixedVideoFullscreen RuntimeEnabled feature.
  // TODO(crbug.com/40352864): Remove this when the APIs are removed for good.
  bool? prefixed_fullscreen_video_api_availability;
};