0

Move ViewMsg_UpdateWebPreferences to Mojo

As the last step to convert ViewMsg_UpdateWebPreferences
IPC message to Mojo, this CL moves ViewMsg_UpdateWebPreferences
to PageBroacast Mojo interface.

  - Introduce web_preferences.mojom which has WebPreferences
    Mojo struct with needed enum types.
  - Add web_preferences_mojom_traits.h/cc files to map Mojo fields
    to the proper native types.
  - Remove IPC legacy stuff regarding the IPC message in //content.

Bug: 1097943
Change-Id: I3a4286b106b7f0a0b38cb7482f1f0f8f7fbf590f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2426070
Reviewed-by: Dave Tapuska <dtapuska@chromium.org>
Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Commit-Queue: Gyuyoung Kim <gyuyoung@igalia.com>
Cr-Commit-Position: refs/heads/master@{#812602}
This commit is contained in:
Gyuyoung Kim
2020-10-01 09:24:39 +00:00
committed by Commit Bot
parent f397d7387b
commit cbe8dae16e
25 changed files with 1840 additions and 249 deletions

@ -857,8 +857,8 @@ void RenderViewHostImpl::RequestSetBounds(const gfx::Rect& bounds) {
}
void RenderViewHostImpl::SendWebPreferencesToRenderer() {
Send(new ViewMsg_UpdateWebPreferences(
GetRoutingID(), delegate_->GetOrCreateWebPreferences()));
if (auto& broadcast = GetAssociatedPageBroadcast())
broadcast->UpdateWebPreferences(delegate_->GetOrCreateWebPreferences());
}
void RenderViewHostImpl::OnHardwareConfigurationChanged() {

@ -664,7 +664,6 @@ mojom("mojo_bindings") {
"//cc/mojom",
"//components/variations:variations_mojom",
"//content/public/common:interfaces",
"//content/public/common:web_preferences_mojom",
"//ipc:mojom",
"//ipc:mojom_constants",
"//media/capture/mojom:video_capture",

@ -6,7 +6,6 @@ module content.mojom;
import "content/common/document_scoped_interface_bundle.mojom";
import "content/common/native_types.mojom";
import "content/public/common/web_preferences.mojom";
import "ipc/constants.mojom";
import "mojo/public/mojom/base/generic_pending_receiver.mojom";
import "mojo/public/mojom/base/unguessable_token.mojom";
@ -14,6 +13,7 @@ import "third_party/blink/public/mojom/frame/frame_owner_properties.mojom";
import "third_party/blink/public/mojom/page/page.mojom";
import "third_party/blink/public/mojom/page/widget.mojom";
import "third_party/blink/public/mojom/renderer_preferences.mojom";
import "third_party/blink/public/mojom/webpreferences/web_preferences.mojom";
import "third_party/blink/public/mojom/widget/visual_properties.mojom";
// A View (i.e. a "main frame") can be created for a few different cases, these
@ -32,7 +32,7 @@ struct CreateViewParams {
blink.mojom.RendererPreferences renderer_preferences;
// Preferences for this view.
WebPreferences web_preferences;
blink.mojom.WebPreferences web_preferences;
// The ID of the view to be created.
int32 view_id = IPC.mojom.kRoutingIdNone;

@ -94,10 +94,6 @@ IPC_STRUCT_TRAITS_END()
// Messages sent from the browser to the renderer.
// This passes a set of webkit preferences down to the renderer.
IPC_MESSAGE_ROUTED1(ViewMsg_UpdateWebPreferences,
blink::web_pref::WebPreferences)
// Notification that a move or resize renderer's containing window has
// started.
IPC_MESSAGE_ROUTED0(ViewMsg_MoveOrResizeStarted)

@ -393,35 +393,6 @@ mojom("renderer_type") {
sources = [ "media_playback_renderer_type.mojom" ]
}
mojom("web_preferences_mojom") {
sources = [ "web_preferences.mojom" ]
public_deps = [
# This dependency is really a dependency for the typemaps, but we need
# it here so that we can override it correctly for the component build.
"//third_party/blink/public/mojom:mojom_platform",
]
overridden_deps = [ "//third_party/blink/public/mojom:mojom_platform" ]
component_deps = [ "//third_party/blink/public/common" ]
cpp_typemaps = [
{
types = [
{
mojom = "content.mojom.WebPreferences"
cpp = "::blink::web_pref::WebPreferences"
},
]
traits_headers = [
"//third_party/blink/public/common/web_preferences/web_preferences.h",
]
traits_private_headers = _common_param_traits_headers
traits_deps = _common_param_traits_deps
},
]
}
mojom("service_names") {
sources = [ "service_names.mojom" ]
}

@ -54,28 +54,8 @@ IPC_ENUM_TRAITS_MAX_VALUE(blink::mojom::ScrollRestorationType,
IPC_ENUM_TRAITS_MAX_VALUE(blink::SecurityStyle, blink::SecurityStyle::kMaxValue)
IPC_ENUM_TRAITS_MAX_VALUE(blink::mojom::PermissionStatus,
blink::mojom::PermissionStatus::LAST)
IPC_ENUM_TRAITS_MAX_VALUE(blink::web_pref::EditingBehaviorType,
blink::web_pref::kEditingLastBehavior)
IPC_ENUM_TRAITS_MAX_VALUE(WindowOpenDisposition,
WindowOpenDisposition::MAX_VALUE)
IPC_ENUM_TRAITS_MAX_VALUE(blink::mojom::V8CacheOptions,
blink::mojom::V8CacheOptions::kMaxValue)
IPC_ENUM_TRAITS_MIN_MAX_VALUE(ui::PointerType,
ui::POINTER_TYPE_FIRST,
ui::POINTER_TYPE_LAST)
IPC_ENUM_TRAITS_MIN_MAX_VALUE(ui::HoverType,
ui::HOVER_TYPE_FIRST,
ui::HOVER_TYPE_LAST)
IPC_ENUM_TRAITS_MIN_MAX_VALUE(blink::web_pref::ImageAnimationPolicy,
blink::web_pref::kImageAnimationPolicyAllowed,
blink::web_pref::kImageAnimationPolicyNoAnimation)
IPC_ENUM_TRAITS_MIN_MAX_VALUE(blink::web_pref::ViewportStyle,
blink::web_pref::ViewportStyle::kDefault,
blink::web_pref::ViewportStyle::kTelevision)
IPC_ENUM_TRAITS_MIN_MAX_VALUE(
blink::web_pref::AutoplayPolicy,
blink::web_pref::AutoplayPolicy::kNoUserGestureRequired,
blink::web_pref::AutoplayPolicy::kDocumentUserActivationRequired)
IPC_ENUM_TRAITS_MIN_MAX_VALUE(blink::PreferredColorScheme,
blink::PreferredColorScheme::kDark,
blink::PreferredColorScheme::kMaxValue)
@ -92,162 +72,6 @@ IPC_STRUCT_TRAITS_BEGIN(content::Referrer)
IPC_STRUCT_TRAITS_MEMBER(policy)
IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(blink::web_pref::WebPreferences)
IPC_STRUCT_TRAITS_MEMBER(standard_font_family_map)
IPC_STRUCT_TRAITS_MEMBER(fixed_font_family_map)
IPC_STRUCT_TRAITS_MEMBER(serif_font_family_map)
IPC_STRUCT_TRAITS_MEMBER(sans_serif_font_family_map)
IPC_STRUCT_TRAITS_MEMBER(cursive_font_family_map)
IPC_STRUCT_TRAITS_MEMBER(fantasy_font_family_map)
IPC_STRUCT_TRAITS_MEMBER(default_font_size)
IPC_STRUCT_TRAITS_MEMBER(default_fixed_font_size)
IPC_STRUCT_TRAITS_MEMBER(minimum_font_size)
IPC_STRUCT_TRAITS_MEMBER(minimum_logical_font_size)
IPC_STRUCT_TRAITS_MEMBER(default_encoding)
IPC_STRUCT_TRAITS_MEMBER(context_menu_on_mouse_up)
IPC_STRUCT_TRAITS_MEMBER(javascript_enabled)
IPC_STRUCT_TRAITS_MEMBER(web_security_enabled)
IPC_STRUCT_TRAITS_MEMBER(loads_images_automatically)
IPC_STRUCT_TRAITS_MEMBER(images_enabled)
IPC_STRUCT_TRAITS_MEMBER(plugins_enabled)
IPC_STRUCT_TRAITS_MEMBER(dom_paste_enabled)
IPC_STRUCT_TRAITS_MEMBER(shrinks_standalone_images_to_fit)
IPC_STRUCT_TRAITS_MEMBER(text_areas_are_resizable)
IPC_STRUCT_TRAITS_MEMBER(allow_scripts_to_close_windows)
IPC_STRUCT_TRAITS_MEMBER(remote_fonts_enabled)
IPC_STRUCT_TRAITS_MEMBER(javascript_can_access_clipboard)
IPC_STRUCT_TRAITS_MEMBER(xslt_enabled)
IPC_STRUCT_TRAITS_MEMBER(dns_prefetching_enabled)
IPC_STRUCT_TRAITS_MEMBER(data_saver_enabled)
IPC_STRUCT_TRAITS_MEMBER(data_saver_holdback_web_api_enabled)
IPC_STRUCT_TRAITS_MEMBER(local_storage_enabled)
IPC_STRUCT_TRAITS_MEMBER(databases_enabled)
IPC_STRUCT_TRAITS_MEMBER(application_cache_enabled)
IPC_STRUCT_TRAITS_MEMBER(tabs_to_links)
IPC_STRUCT_TRAITS_MEMBER(disable_ipc_flooding_protection)
IPC_STRUCT_TRAITS_MEMBER(hyperlink_auditing_enabled)
IPC_STRUCT_TRAITS_MEMBER(allow_universal_access_from_file_urls)
IPC_STRUCT_TRAITS_MEMBER(allow_file_access_from_file_urls)
IPC_STRUCT_TRAITS_MEMBER(webgl1_enabled)
IPC_STRUCT_TRAITS_MEMBER(webgl2_enabled)
IPC_STRUCT_TRAITS_MEMBER(pepper_3d_enabled)
IPC_STRUCT_TRAITS_MEMBER(record_whole_document)
IPC_STRUCT_TRAITS_MEMBER(flash_3d_enabled)
IPC_STRUCT_TRAITS_MEMBER(flash_stage3d_enabled)
IPC_STRUCT_TRAITS_MEMBER(flash_stage3d_baseline_enabled)
IPC_STRUCT_TRAITS_MEMBER(privileged_webgl_extensions_enabled)
IPC_STRUCT_TRAITS_MEMBER(webgl_errors_to_console_enabled)
IPC_STRUCT_TRAITS_MEMBER(hide_scrollbars)
IPC_STRUCT_TRAITS_MEMBER(accelerated_2d_canvas_enabled)
IPC_STRUCT_TRAITS_MEMBER(new_canvas_2d_api_enabled)
IPC_STRUCT_TRAITS_MEMBER(antialiased_2d_canvas_disabled)
IPC_STRUCT_TRAITS_MEMBER(antialiased_clips_2d_canvas_enabled)
IPC_STRUCT_TRAITS_MEMBER(accelerated_filters_enabled)
IPC_STRUCT_TRAITS_MEMBER(deferred_filters_enabled)
IPC_STRUCT_TRAITS_MEMBER(container_culling_enabled)
IPC_STRUCT_TRAITS_MEMBER(allow_running_insecure_content)
IPC_STRUCT_TRAITS_MEMBER(disable_reading_from_canvas)
IPC_STRUCT_TRAITS_MEMBER(strict_mixed_content_checking)
IPC_STRUCT_TRAITS_MEMBER(strict_powerful_feature_restrictions)
IPC_STRUCT_TRAITS_MEMBER(allow_geolocation_on_insecure_origins)
IPC_STRUCT_TRAITS_MEMBER(strictly_block_blockable_mixed_content)
IPC_STRUCT_TRAITS_MEMBER(block_mixed_plugin_content)
IPC_STRUCT_TRAITS_MEMBER(enable_scroll_animator)
IPC_STRUCT_TRAITS_MEMBER(prefers_reduced_motion)
IPC_STRUCT_TRAITS_MEMBER(password_echo_enabled)
IPC_STRUCT_TRAITS_MEMBER(should_clear_document_background)
IPC_STRUCT_TRAITS_MEMBER(touch_event_feature_detection_enabled)
IPC_STRUCT_TRAITS_MEMBER(pointer_events_max_touch_points)
IPC_STRUCT_TRAITS_MEMBER(available_pointer_types)
IPC_STRUCT_TRAITS_MEMBER(primary_pointer_type)
IPC_STRUCT_TRAITS_MEMBER(available_hover_types)
IPC_STRUCT_TRAITS_MEMBER(primary_hover_type)
IPC_STRUCT_TRAITS_MEMBER(barrel_button_for_drag_enabled)
IPC_STRUCT_TRAITS_MEMBER(sync_xhr_in_documents_enabled)
IPC_STRUCT_TRAITS_MEMBER(number_of_cpu_cores)
IPC_STRUCT_TRAITS_MEMBER(editing_behavior)
IPC_STRUCT_TRAITS_MEMBER(supports_multiple_windows)
IPC_STRUCT_TRAITS_MEMBER(viewport_enabled)
IPC_STRUCT_TRAITS_MEMBER(viewport_meta_enabled)
IPC_STRUCT_TRAITS_MEMBER(shrinks_viewport_contents_to_fit)
IPC_STRUCT_TRAITS_MEMBER(viewport_style)
IPC_STRUCT_TRAITS_MEMBER(smooth_scroll_for_find_enabled)
IPC_STRUCT_TRAITS_MEMBER(main_frame_resizes_are_orientation_changes)
IPC_STRUCT_TRAITS_MEMBER(initialize_at_minimum_page_scale)
IPC_STRUCT_TRAITS_MEMBER(smart_insert_delete_enabled)
IPC_STRUCT_TRAITS_MEMBER(cookie_enabled)
IPC_STRUCT_TRAITS_MEMBER(navigate_on_drag_drop)
IPC_STRUCT_TRAITS_MEMBER(spatial_navigation_enabled)
IPC_STRUCT_TRAITS_MEMBER(v8_cache_options)
IPC_STRUCT_TRAITS_MEMBER(accelerated_video_decode_enabled)
IPC_STRUCT_TRAITS_MEMBER(animation_policy)
IPC_STRUCT_TRAITS_MEMBER(user_gesture_required_for_presentation)
IPC_STRUCT_TRAITS_MEMBER(text_tracks_enabled)
IPC_STRUCT_TRAITS_MEMBER(text_track_background_color)
IPC_STRUCT_TRAITS_MEMBER(text_track_margin_percentage)
IPC_STRUCT_TRAITS_MEMBER(text_track_text_color)
IPC_STRUCT_TRAITS_MEMBER(text_track_text_size)
IPC_STRUCT_TRAITS_MEMBER(text_track_text_shadow)
IPC_STRUCT_TRAITS_MEMBER(text_track_font_family)
IPC_STRUCT_TRAITS_MEMBER(text_track_font_style)
IPC_STRUCT_TRAITS_MEMBER(text_track_font_variant)
IPC_STRUCT_TRAITS_MEMBER(text_track_window_color)
IPC_STRUCT_TRAITS_MEMBER(text_track_window_padding)
IPC_STRUCT_TRAITS_MEMBER(text_track_window_radius)
IPC_STRUCT_TRAITS_MEMBER(text_autosizing_enabled)
IPC_STRUCT_TRAITS_MEMBER(double_tap_to_zoom_enabled)
IPC_STRUCT_TRAITS_MEMBER(dont_send_key_events_to_javascript)
IPC_STRUCT_TRAITS_MEMBER(web_app_scope)
IPC_STRUCT_TRAITS_MEMBER(fullscreen_supported)
#if defined(OS_ANDROID)
IPC_STRUCT_TRAITS_MEMBER(font_scale_factor)
IPC_STRUCT_TRAITS_MEMBER(device_scale_adjustment)
IPC_STRUCT_TRAITS_MEMBER(force_enable_zoom)
IPC_STRUCT_TRAITS_MEMBER(default_video_poster_url)
IPC_STRUCT_TRAITS_MEMBER(support_deprecated_target_density_dpi)
IPC_STRUCT_TRAITS_MEMBER(use_legacy_background_size_shorthand_behavior)
IPC_STRUCT_TRAITS_MEMBER(wide_viewport_quirk)
IPC_STRUCT_TRAITS_MEMBER(use_wide_viewport)
IPC_STRUCT_TRAITS_MEMBER(force_zero_layout_height)
IPC_STRUCT_TRAITS_MEMBER(viewport_meta_merge_content_quirk)
IPC_STRUCT_TRAITS_MEMBER(viewport_meta_non_user_scalable_quirk)
IPC_STRUCT_TRAITS_MEMBER(viewport_meta_zero_values_quirk)
IPC_STRUCT_TRAITS_MEMBER(clobber_user_agent_initial_scale_quirk)
IPC_STRUCT_TRAITS_MEMBER(ignore_main_frame_overflow_hidden_quirk)
IPC_STRUCT_TRAITS_MEMBER(report_screen_size_in_physical_pixels_quirk)
IPC_STRUCT_TRAITS_MEMBER(reuse_global_for_unowned_main_frame)
IPC_STRUCT_TRAITS_MEMBER(spellcheck_enabled_by_default)
IPC_STRUCT_TRAITS_MEMBER(video_fullscreen_orientation_lock_enabled)
IPC_STRUCT_TRAITS_MEMBER(video_rotate_to_fullscreen_enabled)
IPC_STRUCT_TRAITS_MEMBER(embedded_media_experience_enabled)
IPC_STRUCT_TRAITS_MEMBER(immersive_mode_enabled)
IPC_STRUCT_TRAITS_MEMBER(css_hex_alpha_color_enabled)
IPC_STRUCT_TRAITS_MEMBER(scroll_top_left_interop_enabled)
IPC_STRUCT_TRAITS_MEMBER(disable_features_depending_on_viz)
IPC_STRUCT_TRAITS_MEMBER(disable_accelerated_small_canvases)
IPC_STRUCT_TRAITS_MEMBER(reenable_web_components_v0)
#endif // defined(OS_ANDROID)
IPC_STRUCT_TRAITS_MEMBER(force_dark_mode_enabled)
IPC_STRUCT_TRAITS_MEMBER(default_minimum_page_scale_factor)
IPC_STRUCT_TRAITS_MEMBER(default_maximum_page_scale_factor)
IPC_STRUCT_TRAITS_MEMBER(hide_download_ui)
IPC_STRUCT_TRAITS_MEMBER(presentation_receiver)
IPC_STRUCT_TRAITS_MEMBER(media_controls_enabled)
IPC_STRUCT_TRAITS_MEMBER(do_not_update_selection_on_mutating_selection_range)
IPC_STRUCT_TRAITS_MEMBER(autoplay_policy)
IPC_STRUCT_TRAITS_MEMBER(preferred_color_scheme)
IPC_STRUCT_TRAITS_MEMBER(low_priority_iframes_threshold)
IPC_STRUCT_TRAITS_MEMBER(picture_in_picture_enabled)
IPC_STRUCT_TRAITS_MEMBER(translate_service_available)
IPC_STRUCT_TRAITS_MEMBER(network_quality_estimator_web_holdback)
IPC_STRUCT_TRAITS_MEMBER(lazy_frame_loading_distance_thresholds_px)
IPC_STRUCT_TRAITS_MEMBER(lazy_image_loading_distance_thresholds_px)
IPC_STRUCT_TRAITS_MEMBER(lazy_image_first_k_fully_load)
IPC_STRUCT_TRAITS_MEMBER(allow_mixed_content_upgrades)
IPC_STRUCT_TRAITS_MEMBER(always_show_focus)
IPC_STRUCT_TRAITS_MEMBER(touch_drag_drop_enabled)
IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(blink::mojom::WindowFeatures)
IPC_STRUCT_TRAITS_MEMBER(x)
IPC_STRUCT_TRAITS_MEMBER(has_x)

@ -1,7 +0,0 @@
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module content.mojom;
[Native]
struct WebPreferences;

@ -87,7 +87,7 @@ TEST_F(RenderViewTest, MacTestCmdUp) {
blink::WebFrameWidget* blink_widget =
static_cast<blink::WebFrameWidget*>(widget->GetWebWidget());
view->OnUpdateWebPreferences(prefs);
view->SetBlinkPreferences(prefs);
const int kMaxOutputCharacters = 1024;
std::string output;

@ -584,7 +584,6 @@ bool RenderViewImpl::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(RenderViewImpl, message)
IPC_MESSAGE_HANDLER(ViewMsg_UpdateWebPreferences, OnUpdateWebPreferences)
IPC_MESSAGE_HANDLER(ViewMsg_MoveOrResizeStarted, OnMoveOrResizeStarted)
// Page messages.
@ -973,7 +972,7 @@ const blink::web_pref::WebPreferences& RenderViewImpl::GetBlinkPreferences() {
void RenderViewImpl::SetBlinkPreferences(
const blink::web_pref::WebPreferences& preferences) {
OnUpdateWebPreferences(preferences);
webview_->SetWebPreferences(preferences);
}
blink::WebView* RenderViewImpl::GetWebView() {
@ -984,11 +983,6 @@ bool RenderViewImpl::GetContentStateImmediately() {
return send_content_state_immediately_;
}
void RenderViewImpl::OnUpdateWebPreferences(
const blink::web_pref::WebPreferences& prefs) {
webview_->SetWebPreferences(prefs);
}
void RenderViewImpl::OnSetRendererPrefs(
const blink::mojom::RendererPreferences& renderer_prefs) {
std::string old_accept_languages = renderer_preferences_.accept_languages;

@ -281,7 +281,7 @@ class CONTENT_EXPORT RenderViewImpl : public blink::WebViewClient,
FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, OnHandleKeyboardEvent);
FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, OnImeTypeChanged);
FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, OnNavStateChanged);
FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, OnUpdateWebPreferences);
FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, SetBlinkPreferences);
FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest,
SetEditableSelectionAndComposition);
FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, StaleNavigationsIgnored);
@ -368,7 +368,6 @@ class CONTENT_EXPORT RenderViewImpl : public blink::WebViewClient,
void OnSetRendererPrefs(
const blink::mojom::RendererPreferences& renderer_prefs);
void OnSuppressDialogsUntilSwapOut();
void OnUpdateWebPreferences(const blink::web_pref::WebPreferences& prefs);
// Page message handlers -----------------------------------------------------
void SetPageFrozen(bool frozen);

@ -33,14 +33,17 @@ mojom("web_test_common_mojom") {
"common/web_test_bluetooth_fake_adapter_setter.mojom",
]
public_deps = [
"//content/public/common:web_preferences_mojom",
"//mojo/public/mojom/base",
"//skia/public/mojom",
"//third_party/blink/public/mojom:mojom_platform",
"//ui/accessibility:ax_enums_mojo",
"//ui/gfx/geometry/mojom",
"//url/mojom:url_mojom_gurl",
"//url/mojom:url_mojom_origin",
]
overridden_deps = [ "//third_party/blink/public/mojom:mojom_platform" ]
component_deps = [ "//third_party/blink/public/common" ]
}
static_library("web_test_common") {

@ -4,12 +4,12 @@
module content.mojom;
import "content/public/common/web_preferences.mojom";
import "mojo/public/mojom/base/file_path.mojom";
import "mojo/public/mojom/base/values.mojom";
import "mojo/public/mojom/base/string16.mojom";
import "skia/public/mojom/bitmap.mojom";
import "third_party/blink/public/mojom/permissions/permission_status.mojom";
import "third_party/blink/public/mojom/webpreferences/web_preferences.mojom";
import "ui/gfx/geometry/mojom/geometry.mojom";
import "url/mojom/url.mojom";
@ -119,7 +119,7 @@ interface WebTestControlHost {
PrintMessage(string message);
// Update changed WebKit preferences.
OverridePreferences(WebPreferences web_preferences);
OverridePreferences(blink.mojom.WebPreferences web_preferences);
// Trigger a reload navigation on the main WebView.
Reload();

@ -156,6 +156,7 @@ source_set("common") {
"web_package/signed_exchange_consts.cc",
"web_package/web_package_request_matcher.cc",
"web_preferences/web_preferences.cc",
"web_preferences/web_preferences_mojom_traits.cc",
"widget/device_emulation_params_mojom_traits.cc",
"widget/screen_info_mojom_traits.cc",
"widget/visual_properties_mojom_traits.cc",

@ -0,0 +1,2 @@
per-file *_mojom_traits*.*=set noparent
per-file *_mojom_traits*.*=file://ipc/SECURITY_OWNERS

@ -197,7 +197,8 @@ WebPreferences::WebPreferences()
presentation_receiver(false),
media_controls_enabled(true),
do_not_update_selection_on_mutating_selection_range(false),
autoplay_policy(AutoplayPolicy::kDocumentUserActivationRequired),
autoplay_policy(
web_pref::AutoplayPolicy::kDocumentUserActivationRequired),
low_priority_iframes_threshold(net::EFFECTIVE_CONNECTION_TYPE_UNKNOWN),
picture_in_picture_enabled(true),
translate_service_available(false),
@ -206,14 +207,19 @@ WebPreferences::WebPreferences()
allow_mixed_content_upgrades(true),
always_show_focus(false),
touch_drag_drop_enabled(IsTouchDragDropEnabled()) {
standard_font_family_map[kCommonScript] =
standard_font_family_map[web_pref::kCommonScript] =
base::ASCIIToUTF16("Times New Roman");
fixed_font_family_map[kCommonScript] = base::ASCIIToUTF16("Courier New");
serif_font_family_map[kCommonScript] = base::ASCIIToUTF16("Times New Roman");
sans_serif_font_family_map[kCommonScript] = base::ASCIIToUTF16("Arial");
cursive_font_family_map[kCommonScript] = base::ASCIIToUTF16("Script");
fantasy_font_family_map[kCommonScript] = base::ASCIIToUTF16("Impact");
pictograph_font_family_map[kCommonScript] =
fixed_font_family_map[web_pref::kCommonScript] =
base::ASCIIToUTF16("Courier New");
serif_font_family_map[web_pref::kCommonScript] =
base::ASCIIToUTF16("Times New Roman");
sans_serif_font_family_map[web_pref::kCommonScript] =
base::ASCIIToUTF16("Arial");
cursive_font_family_map[web_pref::kCommonScript] =
base::ASCIIToUTF16("Script");
fantasy_font_family_map[web_pref::kCommonScript] =
base::ASCIIToUTF16("Impact");
pictograph_font_family_map[web_pref::kCommonScript] =
base::ASCIIToUTF16("Times New Roman");
}

@ -0,0 +1,532 @@
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "third_party/blink/public/common/web_preferences/web_preferences_mojom_traits.h"
#include "base/strings/string_util.h"
#include "build/build_config.h"
#include "mojo/public/cpp/base/string16_mojom_traits.h"
#include "third_party/blink/public/mojom/widget/screen_info.mojom.h"
#include "url/mojom/url_gurl_mojom_traits.h"
namespace mojo {
// static
blink::mojom::PointerType
EnumTraits<blink::mojom::PointerType, ui::PointerType>::ToMojom(
ui::PointerType scheme) {
switch (scheme) {
case ui::PointerType::POINTER_TYPE_FIRST:
return blink::mojom::PointerType::kPointerFirstType;
case ui::PointerType::POINTER_TYPE_COARSE:
return blink::mojom::PointerType::kPointerCoarseType;
case ui::PointerType::POINTER_TYPE_FINE:
return blink::mojom::PointerType::kPointerFineType;
}
NOTREACHED();
return blink::mojom::PointerType::kMinValue;
}
// static
bool EnumTraits<blink::mojom::PointerType, ui::PointerType>::FromMojom(
blink::mojom::PointerType input,
ui::PointerType* out) {
switch (input) {
case blink::mojom::PointerType::kPointerFirstType:
*out = ui::PointerType::POINTER_TYPE_FIRST;
return true;
case blink::mojom::PointerType::kPointerCoarseType:
*out = ui::PointerType::POINTER_TYPE_COARSE;
return true;
case blink::mojom::PointerType::kPointerFineType:
*out = ui::PointerType::POINTER_TYPE_FINE;
return true;
}
NOTREACHED();
return false;
}
// static
blink::mojom::HoverType EnumTraits<blink::mojom::HoverType,
ui::HoverType>::ToMojom(ui::HoverType type) {
switch (type) {
case ui::HoverType::HOVER_TYPE_FIRST:
return blink::mojom::HoverType::kHoverFirstType;
case ui::HoverType::HOVER_TYPE_HOVER:
return blink::mojom::HoverType::kHoverHoverType;
}
NOTREACHED();
return blink::mojom::HoverType::kMinValue;
}
// static
bool EnumTraits<blink::mojom::HoverType, ui::HoverType>::FromMojom(
blink::mojom::HoverType input,
ui::HoverType* out) {
switch (input) {
case blink::mojom::HoverType::kHoverFirstType:
*out = ui::HoverType::HOVER_TYPE_FIRST;
return true;
case blink::mojom::HoverType::kHoverHoverType:
*out = ui::HoverType::HOVER_TYPE_HOVER;
return true;
}
NOTREACHED();
return false;
}
// static
blink::mojom::EditingBehavior EnumTraits<blink::mojom::EditingBehavior,
blink::web_pref::EditingBehaviorType>::
ToMojom(blink::web_pref::EditingBehaviorType behavior) {
switch (behavior) {
case blink::web_pref::EditingBehaviorType::kEditingMacBehavior:
return blink::mojom::EditingBehavior::kEditingMacBehavior;
case blink::web_pref::EditingBehaviorType::kEditingWindowsBehavior:
return blink::mojom::EditingBehavior::kEditingWindowsBehavior;
case blink::web_pref::EditingBehaviorType::kEditingUnixBehavior:
return blink::mojom::EditingBehavior::kEditingUnixBehavior;
case blink::web_pref::EditingBehaviorType::kEditingAndroidBehavior:
return blink::mojom::EditingBehavior::kEditingAndroidBehavior;
case blink::web_pref::EditingBehaviorType::kEditingChromeOSBehavior:
return blink::mojom::EditingBehavior::kEditingChromeOSBehavior;
}
NOTREACHED();
return blink::mojom::EditingBehavior::kMaxValue;
}
// static
bool EnumTraits<blink::mojom::EditingBehavior,
blink::web_pref::EditingBehaviorType>::
FromMojom(blink::mojom::EditingBehavior input,
blink::web_pref::EditingBehaviorType* out) {
switch (input) {
case blink::mojom::EditingBehavior::kEditingMacBehavior:
*out = blink::web_pref::EditingBehaviorType::kEditingMacBehavior;
return true;
case blink::mojom::EditingBehavior::kEditingWindowsBehavior:
*out = blink::web_pref::EditingBehaviorType::kEditingWindowsBehavior;
return true;
case blink::mojom::EditingBehavior::kEditingUnixBehavior:
*out = blink::web_pref::EditingBehaviorType::kEditingUnixBehavior;
return true;
case blink::mojom::EditingBehavior::kEditingAndroidBehavior:
*out = blink::web_pref::EditingBehaviorType::kEditingAndroidBehavior;
return true;
case blink::mojom::EditingBehavior::kEditingChromeOSBehavior:
*out = blink::web_pref::EditingBehaviorType::kEditingChromeOSBehavior;
return true;
}
NOTREACHED();
return false;
}
// static
blink::mojom::ImageAnimationPolicy
EnumTraits<blink::mojom::ImageAnimationPolicy,
blink::web_pref::ImageAnimationPolicy>::
ToMojom(blink::web_pref::ImageAnimationPolicy policy) {
switch (policy) {
case blink::web_pref::ImageAnimationPolicy::kImageAnimationPolicyAllowed:
return blink::mojom::ImageAnimationPolicy::kImageAnimationPolicyAllowed;
case blink::web_pref::ImageAnimationPolicy::
kImageAnimationPolicyAnimateOnce:
return blink::mojom::ImageAnimationPolicy::
kImageAnimationPolicyAnimateOnce;
case blink::web_pref::ImageAnimationPolicy::
kImageAnimationPolicyNoAnimation:
return blink::mojom::ImageAnimationPolicy::
kImageAnimationPolicyNoAnimation;
}
NOTREACHED();
return blink::mojom::ImageAnimationPolicy::kImageAnimationPolicyNoAnimation;
}
// static
bool EnumTraits<blink::mojom::ImageAnimationPolicy,
blink::web_pref::ImageAnimationPolicy>::
FromMojom(blink::mojom::ImageAnimationPolicy input,
blink::web_pref::ImageAnimationPolicy* out) {
switch (input) {
case blink::mojom::ImageAnimationPolicy::kImageAnimationPolicyAllowed:
*out =
blink::web_pref::ImageAnimationPolicy::kImageAnimationPolicyAllowed;
return true;
case blink::mojom::ImageAnimationPolicy::kImageAnimationPolicyAnimateOnce:
*out = blink::web_pref::ImageAnimationPolicy::
kImageAnimationPolicyAnimateOnce;
return true;
case blink::mojom::ImageAnimationPolicy::kImageAnimationPolicyNoAnimation:
*out = blink::web_pref::ImageAnimationPolicy::
kImageAnimationPolicyNoAnimation;
return true;
}
NOTREACHED();
return false;
}
// static
blink::mojom::ViewportStyle
EnumTraits<blink::mojom::ViewportStyle, blink::web_pref::ViewportStyle>::
ToMojom(blink::web_pref::ViewportStyle style) {
switch (style) {
case blink::web_pref::ViewportStyle::kDefault:
return blink::mojom::ViewportStyle::kDefault;
case blink::web_pref::ViewportStyle::kMobile:
return blink::mojom::ViewportStyle::kMobile;
case blink::web_pref::ViewportStyle::kTelevision:
return blink::mojom::ViewportStyle::kTelevision;
}
NOTREACHED();
return blink::mojom::ViewportStyle::kLast;
}
// static
bool EnumTraits<blink::mojom::ViewportStyle, blink::web_pref::ViewportStyle>::
FromMojom(blink::mojom::ViewportStyle input,
blink::web_pref::ViewportStyle* out) {
switch (input) {
case blink::mojom::ViewportStyle::kDefault:
*out = blink::web_pref::ViewportStyle::kDefault;
return true;
case blink::mojom::ViewportStyle::kMobile:
*out = blink::web_pref::ViewportStyle::kMobile;
return true;
case blink::mojom::ViewportStyle::kTelevision:
*out = blink::web_pref::ViewportStyle::kTelevision;
return true;
}
NOTREACHED();
return false;
}
// static
blink::mojom::AutoplayPolicy
EnumTraits<blink::mojom::AutoplayPolicy, blink::web_pref::AutoplayPolicy>::
ToMojom(blink::web_pref::AutoplayPolicy style) {
switch (style) {
case blink::web_pref::AutoplayPolicy::kNoUserGestureRequired:
return blink::mojom::AutoplayPolicy::kNoUserGestureRequired;
case blink::web_pref::AutoplayPolicy::kUserGestureRequired:
return blink::mojom::AutoplayPolicy::kUserGestureRequired;
case blink::web_pref::AutoplayPolicy::kDocumentUserActivationRequired:
return blink::mojom::AutoplayPolicy::kDocumentUserActivationRequired;
}
NOTREACHED();
return blink::mojom::AutoplayPolicy::kNoUserGestureRequired;
}
// static
bool EnumTraits<blink::mojom::AutoplayPolicy, blink::web_pref::AutoplayPolicy>::
FromMojom(blink::mojom::AutoplayPolicy input,
blink::web_pref::AutoplayPolicy* out) {
switch (input) {
case blink::mojom::AutoplayPolicy::kNoUserGestureRequired:
*out = blink::web_pref::AutoplayPolicy::kNoUserGestureRequired;
return true;
case blink::mojom::AutoplayPolicy::kUserGestureRequired:
*out = blink::web_pref::AutoplayPolicy::kUserGestureRequired;
return true;
case blink::mojom::AutoplayPolicy::kDocumentUserActivationRequired:
*out = blink::web_pref::AutoplayPolicy::kDocumentUserActivationRequired;
return true;
}
NOTREACHED();
return false;
}
// static
blink::mojom::PreferredColorScheme EnumTraits<
blink::mojom::PreferredColorScheme,
blink::PreferredColorScheme>::ToMojom(blink::PreferredColorScheme scheme) {
switch (scheme) {
case blink::PreferredColorScheme::kDark:
return blink::mojom::PreferredColorScheme::kDark;
case blink::PreferredColorScheme::kLight:
return blink::mojom::PreferredColorScheme::kLight;
}
NOTREACHED();
return blink::mojom::PreferredColorScheme::kLight;
}
// static
bool EnumTraits<blink::mojom::PreferredColorScheme,
blink::PreferredColorScheme>::
FromMojom(blink::mojom::PreferredColorScheme input,
blink::PreferredColorScheme* out) {
switch (input) {
case blink::mojom::PreferredColorScheme::kDark:
*out = blink::PreferredColorScheme::kDark;
return true;
case blink::mojom::PreferredColorScheme::kLight:
*out = blink::PreferredColorScheme::kLight;
return true;
}
NOTREACHED();
return false;
}
// static
blink::mojom::EffectiveConnectionType EnumTraits<
blink::mojom::EffectiveConnectionType,
net::EffectiveConnectionType>::ToMojom(net::EffectiveConnectionType type) {
switch (type) {
case net::EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_UNKNOWN:
return blink::mojom::EffectiveConnectionType::
kEffectiveConnectionUnknownType;
case net::EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_OFFLINE:
return blink::mojom::EffectiveConnectionType::
kEffectiveConnectionOfflineType;
case net::EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_SLOW_2G:
return blink::mojom::EffectiveConnectionType::
kEffectiveConnectionSlow2GType;
case net::EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_2G:
return blink::mojom::EffectiveConnectionType::kEffectiveConnection2GType;
case net::EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_3G:
return blink::mojom::EffectiveConnectionType::kEffectiveConnection3GType;
case net::EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_4G:
return blink::mojom::EffectiveConnectionType::kEffectiveConnection4GType;
case net::EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_LAST:
break;
}
NOTREACHED();
return blink::mojom::EffectiveConnectionType::kMaxValue;
}
// static
bool EnumTraits<blink::mojom::EffectiveConnectionType,
net::EffectiveConnectionType>::
FromMojom(blink::mojom::EffectiveConnectionType input,
net::EffectiveConnectionType* out) {
switch (input) {
case blink::mojom::EffectiveConnectionType::kEffectiveConnectionUnknownType:
*out = net::EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_UNKNOWN;
return true;
case blink::mojom::EffectiveConnectionType::kEffectiveConnectionOfflineType:
*out = net::EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_OFFLINE;
return true;
case blink::mojom::EffectiveConnectionType::kEffectiveConnectionSlow2GType:
*out = net::EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_SLOW_2G;
return true;
case blink::mojom::EffectiveConnectionType::kEffectiveConnection2GType:
*out = net::EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_2G;
return true;
case blink::mojom::EffectiveConnectionType::kEffectiveConnection3GType:
*out = net::EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_3G;
return true;
case blink::mojom::EffectiveConnectionType::kEffectiveConnection4GType:
*out = net::EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_4G;
return true;
}
NOTREACHED();
return false;
}
// static
bool StructTraits<blink::mojom::WebPreferencesDataView,
blink::web_pref::WebPreferences>::
Read(blink::mojom::WebPreferencesDataView data,
blink::web_pref::WebPreferences* out) {
if (!data.ReadStandardFontFamilyMap(&out->standard_font_family_map) ||
!data.ReadFixedFontFamilyMap(&out->fixed_font_family_map) ||
!data.ReadSerifFontFamilyMap(&out->serif_font_family_map) ||
!data.ReadSansSerifFontFamilyMap(&out->sans_serif_font_family_map) ||
!data.ReadCursiveFontFamilyMap(&out->cursive_font_family_map) ||
!data.ReadFantasyFontFamilyMap(&out->fantasy_font_family_map) ||
!data.ReadPictographFontFamilyMap(&out->pictograph_font_family_map) ||
!data.ReadLazyFrameLoadingDistanceThresholdsPx(
&out->lazy_frame_loading_distance_thresholds_px) ||
!data.ReadLazyImageLoadingDistanceThresholdsPx(
&out->lazy_image_loading_distance_thresholds_px) ||
!data.ReadLazyImageFirstKFullyLoad(&out->lazy_image_first_k_fully_load) ||
!data.ReadDefaultEncoding(&out->default_encoding) ||
!data.ReadTextTrackBackgroundColor(&out->text_track_background_color) ||
!data.ReadDefaultEncoding(&out->text_track_text_color) ||
!data.ReadTextTrackTextSize(&out->text_track_text_size) ||
!data.ReadTextTrackTextShadow(&out->text_track_text_shadow) ||
!data.ReadTextTrackFontFamily(&out->text_track_font_family) ||
!data.ReadTextTrackFontStyle(&out->text_track_font_style) ||
!data.ReadTextTrackFontVariant(&out->text_track_font_variant) ||
!data.ReadTextTrackWindowColor(&out->text_track_window_color) ||
!data.ReadTextTrackWindowPadding(&out->text_track_window_padding) ||
!data.ReadTextTrackWindowRadius(&out->text_track_window_radius) ||
!data.ReadPrimaryPointerType(&out->primary_pointer_type) ||
!data.ReadPrimaryHoverType(&out->primary_hover_type) ||
!data.ReadEditingBehavior(&out->editing_behavior) ||
!data.ReadViewportStyle(&out->viewport_style) ||
!data.ReadAnimationPolicy(&out->animation_policy) ||
!data.ReadAutoplayPolicy(&out->autoplay_policy) ||
!data.ReadPreferredColorScheme(&out->preferred_color_scheme) ||
!data.ReadLowPriorityIframesThreshold(
&out->low_priority_iframes_threshold) ||
!data.ReadNetworkQualityEstimatorWebHoldback(
&out->network_quality_estimator_web_holdback) ||
!data.ReadWebAppScope(&out->web_app_scope)
#if defined(OS_ANDROID)
|| !data.ReadDefaultVideoPosterUrl(&out->default_video_poster_url)
#endif
)
return false;
out->default_font_size = data.default_font_size();
out->default_fixed_font_size = data.default_fixed_font_size();
out->minimum_font_size = data.minimum_font_size();
out->minimum_logical_font_size = data.minimum_logical_font_size();
out->context_menu_on_mouse_up = data.context_menu_on_mouse_up();
out->javascript_enabled = data.javascript_enabled();
out->web_security_enabled = data.web_security_enabled();
out->loads_images_automatically = data.loads_images_automatically();
out->images_enabled = data.images_enabled();
out->plugins_enabled = data.plugins_enabled();
out->dom_paste_enabled = data.dom_paste_enabled();
out->shrinks_standalone_images_to_fit =
data.shrinks_standalone_images_to_fit();
out->text_areas_are_resizable = data.text_areas_are_resizable();
out->allow_scripts_to_close_windows = data.allow_scripts_to_close_windows();
out->remote_fonts_enabled = data.remote_fonts_enabled();
out->javascript_can_access_clipboard = data.javascript_can_access_clipboard();
out->xslt_enabled = data.xslt_enabled();
out->dns_prefetching_enabled = data.dns_prefetching_enabled();
out->data_saver_enabled = data.data_saver_enabled();
out->data_saver_holdback_web_api_enabled =
data.data_saver_holdback_web_api_enabled();
out->local_storage_enabled = data.local_storage_enabled();
out->databases_enabled = data.databases_enabled();
out->application_cache_enabled = data.application_cache_enabled();
out->tabs_to_links = data.tabs_to_links();
out->disable_ipc_flooding_protection = data.disable_ipc_flooding_protection();
out->hyperlink_auditing_enabled = data.hyperlink_auditing_enabled();
out->allow_universal_access_from_file_urls =
data.allow_universal_access_from_file_urls();
out->allow_file_access_from_file_urls =
data.allow_file_access_from_file_urls();
out->webgl1_enabled = data.webgl1_enabled();
out->webgl2_enabled = data.webgl2_enabled();
out->pepper_3d_enabled = data.pepper_3d_enabled();
out->flash_3d_enabled = data.flash_3d_enabled();
out->flash_stage3d_enabled = data.flash_stage3d_enabled();
out->flash_stage3d_baseline_enabled = data.flash_stage3d_baseline_enabled();
out->privileged_webgl_extensions_enabled =
data.privileged_webgl_extensions_enabled();
out->webgl_errors_to_console_enabled = data.webgl_errors_to_console_enabled();
out->hide_scrollbars = data.hide_scrollbars();
out->accelerated_2d_canvas_enabled = data.accelerated_2d_canvas_enabled();
out->new_canvas_2d_api_enabled = data.new_canvas_2d_api_enabled();
out->antialiased_2d_canvas_disabled = data.antialiased_2d_canvas_disabled();
out->antialiased_clips_2d_canvas_enabled =
data.antialiased_clips_2d_canvas_enabled();
out->accelerated_filters_enabled = data.accelerated_filters_enabled();
out->deferred_filters_enabled = data.deferred_filters_enabled();
out->container_culling_enabled = data.container_culling_enabled();
out->allow_running_insecure_content = data.allow_running_insecure_content();
out->disable_reading_from_canvas = data.disable_reading_from_canvas();
out->strict_mixed_content_checking = data.strict_mixed_content_checking();
out->strict_powerful_feature_restrictions =
data.strict_powerful_feature_restrictions();
out->allow_geolocation_on_insecure_origins =
data.allow_geolocation_on_insecure_origins();
out->strictly_block_blockable_mixed_content =
data.strictly_block_blockable_mixed_content();
out->block_mixed_plugin_content = data.block_mixed_plugin_content();
out->password_echo_enabled = data.password_echo_enabled();
out->disable_reading_from_canvas = data.disable_reading_from_canvas();
out->should_clear_document_background =
data.should_clear_document_background();
out->enable_scroll_animator = data.enable_scroll_animator();
out->prefers_reduced_motion = data.prefers_reduced_motion();
out->touch_event_feature_detection_enabled =
data.touch_event_feature_detection_enabled();
out->pointer_events_max_touch_points = data.pointer_events_max_touch_points();
out->available_pointer_types = data.available_pointer_types();
out->available_hover_types = data.available_hover_types();
out->dont_send_key_events_to_javascript =
data.dont_send_key_events_to_javascript();
out->barrel_button_for_drag_enabled = data.barrel_button_for_drag_enabled();
out->sync_xhr_in_documents_enabled = data.sync_xhr_in_documents_enabled();
out->number_of_cpu_cores = data.number_of_cpu_cores();
out->supports_multiple_windows = data.supports_multiple_windows();
out->viewport_enabled = data.viewport_enabled();
out->viewport_meta_enabled = data.viewport_meta_enabled();
out->shrinks_viewport_contents_to_fit =
data.shrinks_viewport_contents_to_fit();
out->smooth_scroll_for_find_enabled = data.smooth_scroll_for_find_enabled();
out->main_frame_resizes_are_orientation_changes =
data.main_frame_resizes_are_orientation_changes();
out->initialize_at_minimum_page_scale =
data.initialize_at_minimum_page_scale();
out->smart_insert_delete_enabled = data.smart_insert_delete_enabled();
out->spatial_navigation_enabled = data.spatial_navigation_enabled();
out->navigate_on_drag_drop = data.navigate_on_drag_drop();
out->v8_cache_options = data.v8_cache_options();
out->record_whole_document = data.record_whole_document();
out->cookie_enabled = data.cookie_enabled();
out->accelerated_video_decode_enabled =
data.accelerated_video_decode_enabled();
out->user_gesture_required_for_presentation =
data.user_gesture_required_for_presentation();
out->text_tracks_enabled = data.text_tracks_enabled();
out->text_track_margin_percentage = data.text_track_margin_percentage();
out->immersive_mode_enabled = data.immersive_mode_enabled();
out->double_tap_to_zoom_enabled = data.double_tap_to_zoom_enabled();
out->fullscreen_supported = data.fullscreen_supported();
out->text_autosizing_enabled = data.text_autosizing_enabled();
#if defined(OS_ANDROID)
out->font_scale_factor = data.font_scale_factor();
out->device_scale_adjustment = data.device_scale_adjustment();
out->force_enable_zoom = data.force_enable_zoom();
out->support_deprecated_target_density_dpi =
data.support_deprecated_target_density_dpi();
out->use_legacy_background_size_shorthand_behavior =
data.use_legacy_background_size_shorthand_behavior();
out->wide_viewport_quirk = data.wide_viewport_quirk();
out->use_wide_viewport = data.use_wide_viewport();
out->force_zero_layout_height = data.force_zero_layout_height();
out->viewport_meta_merge_content_quirk =
data.viewport_meta_merge_content_quirk();
out->viewport_meta_non_user_scalable_quirk =
data.viewport_meta_non_user_scalable_quirk();
out->viewport_meta_zero_values_quirk = data.viewport_meta_zero_values_quirk();
out->clobber_user_agent_initial_scale_quirk =
data.clobber_user_agent_initial_scale_quirk();
out->ignore_main_frame_overflow_hidden_quirk =
data.ignore_main_frame_overflow_hidden_quirk();
out->report_screen_size_in_physical_pixels_quirk =
data.report_screen_size_in_physical_pixels_quirk();
out->reuse_global_for_unowned_main_frame =
data.reuse_global_for_unowned_main_frame();
out->spellcheck_enabled_by_default = data.spellcheck_enabled_by_default();
out->video_fullscreen_orientation_lock_enabled =
data.video_fullscreen_orientation_lock_enabled();
out->video_rotate_to_fullscreen_enabled =
data.video_rotate_to_fullscreen_enabled();
out->embedded_media_experience_enabled =
data.embedded_media_experience_enabled();
out->css_hex_alpha_color_enabled = data.css_hex_alpha_color_enabled();
out->scroll_top_left_interop_enabled = data.scroll_top_left_interop_enabled();
out->disable_features_depending_on_viz =
data.disable_features_depending_on_viz();
out->disable_accelerated_small_canvases =
data.disable_accelerated_small_canvases();
out->reenable_web_components_v0 = data.reenable_web_components_v0();
#endif
out->force_dark_mode_enabled = data.force_dark_mode_enabled();
out->default_minimum_page_scale_factor =
data.default_minimum_page_scale_factor();
out->default_maximum_page_scale_factor =
data.default_maximum_page_scale_factor();
out->hide_download_ui = data.hide_download_ui();
out->presentation_receiver = data.presentation_receiver();
out->media_controls_enabled = data.media_controls_enabled();
out->do_not_update_selection_on_mutating_selection_range =
data.do_not_update_selection_on_mutating_selection_range();
out->picture_in_picture_enabled = data.picture_in_picture_enabled();
out->translate_service_available = data.translate_service_available();
out->lazy_load_enabled = data.lazy_load_enabled();
out->allow_mixed_content_upgrades = data.allow_mixed_content_upgrades();
out->always_show_focus = data.always_show_focus();
out->touch_drag_drop_enabled = data.touch_drag_drop_enabled();
return true;
}
} // namespace mojo

@ -0,0 +1,2 @@
per-file *_mojom_traits*.*=set noparent
per-file *_mojom_traits*.*=file://ipc/SECURITY_OWNERS

@ -43,8 +43,7 @@ enum EditingBehaviorType {
kEditingWindowsBehavior,
kEditingUnixBehavior,
kEditingAndroidBehavior,
kEditingChromeOSBehavior,
kEditingLastBehavior
kEditingChromeOSBehavior
};
} // namespace web_pref

@ -0,0 +1,832 @@
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_PUBLIC_COMMON_WEB_PREFERENCES_WEB_PREFERENCES_MOJOM_TRAITS_H_
#define THIRD_PARTY_BLINK_PUBLIC_COMMON_WEB_PREFERENCES_WEB_PREFERENCES_MOJOM_TRAITS_H_
#include "build/build_config.h"
#include "mojo/public/cpp/bindings/struct_traits.h"
#include "net/nqe/effective_connection_type.h"
#include "third_party/blink/public/common/common_export.h"
#include "third_party/blink/public/common/css/preferred_color_scheme.h"
#include "third_party/blink/public/common/web_preferences/web_preferences.h"
#include "third_party/blink/public/mojom/webpreferences/web_preferences.mojom.h"
#include "ui/base/pointer/pointer_device.h"
namespace mojo {
template <>
struct BLINK_COMMON_EXPORT
EnumTraits<blink::mojom::PointerType, ui::PointerType> {
static blink::mojom::PointerType ToMojom(ui::PointerType type);
static bool FromMojom(blink::mojom::PointerType input, ui::PointerType* out);
};
template <>
struct BLINK_COMMON_EXPORT EnumTraits<blink::mojom::HoverType, ui::HoverType> {
static blink::mojom::HoverType ToMojom(ui::HoverType type);
static bool FromMojom(blink::mojom::HoverType input, ui::HoverType* out);
};
template <>
struct BLINK_COMMON_EXPORT EnumTraits<blink::mojom::PreferredColorScheme,
blink::PreferredColorScheme> {
static blink::mojom::PreferredColorScheme ToMojom(
blink::PreferredColorScheme scheme);
static bool FromMojom(blink::mojom::PreferredColorScheme input,
blink::PreferredColorScheme* out);
};
template <>
struct BLINK_COMMON_EXPORT EnumTraits<blink::mojom::EditingBehavior,
blink::web_pref::EditingBehaviorType> {
static blink::mojom::EditingBehavior ToMojom(
blink::web_pref::EditingBehaviorType behavior);
static bool FromMojom(blink::mojom::EditingBehavior input,
blink::web_pref::EditingBehaviorType* out);
};
template <>
struct BLINK_COMMON_EXPORT EnumTraits<blink::mojom::ImageAnimationPolicy,
blink::web_pref::ImageAnimationPolicy> {
static blink::mojom::ImageAnimationPolicy ToMojom(
blink::web_pref::ImageAnimationPolicy policy);
static bool FromMojom(blink::mojom::ImageAnimationPolicy input,
blink::web_pref::ImageAnimationPolicy* out);
};
template <>
struct BLINK_COMMON_EXPORT
EnumTraits<blink::mojom::ViewportStyle, blink::web_pref::ViewportStyle> {
static blink::mojom::ViewportStyle ToMojom(
blink::web_pref::ViewportStyle style);
static bool FromMojom(blink::mojom::ViewportStyle input,
blink::web_pref::ViewportStyle* out);
};
template <>
struct BLINK_COMMON_EXPORT
EnumTraits<blink::mojom::AutoplayPolicy, blink::web_pref::AutoplayPolicy> {
static blink::mojom::AutoplayPolicy ToMojom(
blink::web_pref::AutoplayPolicy policy);
static bool FromMojom(blink::mojom::AutoplayPolicy input,
blink::web_pref::AutoplayPolicy* out);
};
template <>
struct BLINK_COMMON_EXPORT EnumTraits<blink::mojom::EffectiveConnectionType,
net::EffectiveConnectionType> {
static blink::mojom::EffectiveConnectionType ToMojom(
net::EffectiveConnectionType policy);
static bool FromMojom(blink::mojom::EffectiveConnectionType input,
net::EffectiveConnectionType* out);
};
template <>
struct BLINK_COMMON_EXPORT StructTraits<blink::mojom::WebPreferencesDataView,
blink::web_pref::WebPreferences> {
static const std::map<std::string, base::string16>& standard_font_family_map(
const blink::web_pref::WebPreferences& r) {
return r.standard_font_family_map;
}
static const std::map<std::string, base::string16>& fixed_font_family_map(
const blink::web_pref::WebPreferences& r) {
return r.fixed_font_family_map;
}
static const std::map<std::string, base::string16>& serif_font_family_map(
const blink::web_pref::WebPreferences& r) {
return r.serif_font_family_map;
}
static const std::map<std::string, base::string16>&
sans_serif_font_family_map(const blink::web_pref::WebPreferences& r) {
return r.sans_serif_font_family_map;
}
static const std::map<std::string, base::string16>& cursive_font_family_map(
const blink::web_pref::WebPreferences& r) {
return r.cursive_font_family_map;
}
static const std::map<std::string, base::string16>& fantasy_font_family_map(
const blink::web_pref::WebPreferences& r) {
return r.fantasy_font_family_map;
}
static const std::map<std::string, base::string16>&
pictograph_font_family_map(const blink::web_pref::WebPreferences& r) {
return r.pictograph_font_family_map;
}
static uint32_t default_font_size(const blink::web_pref::WebPreferences& r) {
return r.default_font_size;
}
static uint32_t default_fixed_font_size(
const blink::web_pref::WebPreferences& r) {
return r.default_fixed_font_size;
}
static uint32_t minimum_font_size(const blink::web_pref::WebPreferences& r) {
return r.minimum_font_size;
}
static uint32_t minimum_logical_font_size(
const blink::web_pref::WebPreferences& r) {
return r.minimum_logical_font_size;
}
static std::string default_encoding(
const blink::web_pref::WebPreferences& r) {
return r.default_encoding;
}
static bool context_menu_on_mouse_up(
const blink::web_pref::WebPreferences& r) {
return r.context_menu_on_mouse_up;
}
static bool javascript_enabled(const blink::web_pref::WebPreferences& r) {
return r.javascript_enabled;
}
static bool web_security_enabled(const blink::web_pref::WebPreferences& r) {
return r.web_security_enabled;
}
static bool loads_images_automatically(
const blink::web_pref::WebPreferences& r) {
return r.loads_images_automatically;
}
static bool images_enabled(const blink::web_pref::WebPreferences& r) {
return r.images_enabled;
}
static bool plugins_enabled(const blink::web_pref::WebPreferences& r) {
return r.plugins_enabled;
}
static bool dom_paste_enabled(const blink::web_pref::WebPreferences& r) {
return r.dom_paste_enabled;
}
static bool shrinks_standalone_images_to_fit(
const blink::web_pref::WebPreferences& r) {
return r.shrinks_standalone_images_to_fit;
}
static bool text_areas_are_resizable(
const blink::web_pref::WebPreferences& r) {
return r.text_areas_are_resizable;
}
static bool allow_scripts_to_close_windows(
const blink::web_pref::WebPreferences& r) {
return r.allow_scripts_to_close_windows;
}
static bool remote_fonts_enabled(const blink::web_pref::WebPreferences& r) {
return r.remote_fonts_enabled;
}
static bool javascript_can_access_clipboard(
const blink::web_pref::WebPreferences& r) {
return r.javascript_can_access_clipboard;
}
static bool xslt_enabled(const blink::web_pref::WebPreferences& r) {
return r.xslt_enabled;
}
static bool dns_prefetching_enabled(
const blink::web_pref::WebPreferences& r) {
return r.dns_prefetching_enabled;
}
static bool data_saver_enabled(const blink::web_pref::WebPreferences& r) {
return r.data_saver_enabled;
}
static bool data_saver_holdback_web_api_enabled(
const blink::web_pref::WebPreferences& r) {
return r.data_saver_holdback_web_api_enabled;
}
static bool local_storage_enabled(const blink::web_pref::WebPreferences& r) {
return r.local_storage_enabled;
}
static bool databases_enabled(const blink::web_pref::WebPreferences& r) {
return r.databases_enabled;
}
static bool application_cache_enabled(
const blink::web_pref::WebPreferences& r) {
return r.application_cache_enabled;
}
static bool tabs_to_links(const blink::web_pref::WebPreferences& r) {
return r.tabs_to_links;
}
static bool disable_ipc_flooding_protection(
const blink::web_pref::WebPreferences& r) {
return r.disable_ipc_flooding_protection;
}
static bool hyperlink_auditing_enabled(
const blink::web_pref::WebPreferences& r) {
return r.hyperlink_auditing_enabled;
}
static bool allow_universal_access_from_file_urls(
const blink::web_pref::WebPreferences& r) {
return r.allow_universal_access_from_file_urls;
}
static bool allow_file_access_from_file_urls(
const blink::web_pref::WebPreferences& r) {
return r.allow_file_access_from_file_urls;
}
static bool webgl1_enabled(const blink::web_pref::WebPreferences& r) {
return r.webgl1_enabled;
}
static bool webgl2_enabled(const blink::web_pref::WebPreferences& r) {
return r.webgl2_enabled;
}
static bool pepper_3d_enabled(const blink::web_pref::WebPreferences& r) {
return r.pepper_3d_enabled;
}
static bool flash_3d_enabled(const blink::web_pref::WebPreferences& r) {
return r.flash_3d_enabled;
}
static bool flash_stage3d_enabled(const blink::web_pref::WebPreferences& r) {
return r.flash_stage3d_enabled;
}
static bool flash_stage3d_baseline_enabled(
const blink::web_pref::WebPreferences& r) {
return r.flash_stage3d_baseline_enabled;
}
static bool privileged_webgl_extensions_enabled(
const blink::web_pref::WebPreferences& r) {
return r.privileged_webgl_extensions_enabled;
}
static bool webgl_errors_to_console_enabled(
const blink::web_pref::WebPreferences& r) {
return r.webgl_errors_to_console_enabled;
}
static bool hide_scrollbars(const blink::web_pref::WebPreferences& r) {
return r.hide_scrollbars;
}
static bool accelerated_2d_canvas_enabled(
const blink::web_pref::WebPreferences& r) {
return r.accelerated_2d_canvas_enabled;
}
static bool new_canvas_2d_api_enabled(
const blink::web_pref::WebPreferences& r) {
return r.new_canvas_2d_api_enabled;
}
static bool antialiased_2d_canvas_disabled(
const blink::web_pref::WebPreferences& r) {
return r.antialiased_2d_canvas_disabled;
}
static bool antialiased_clips_2d_canvas_enabled(
const blink::web_pref::WebPreferences& r) {
return r.antialiased_clips_2d_canvas_enabled;
}
static bool accelerated_filters_enabled(
const blink::web_pref::WebPreferences& r) {
return r.accelerated_filters_enabled;
}
static bool deferred_filters_enabled(
const blink::web_pref::WebPreferences& r) {
return r.deferred_filters_enabled;
}
static bool container_culling_enabled(
const blink::web_pref::WebPreferences& r) {
return r.container_culling_enabled;
}
static bool allow_running_insecure_content(
const blink::web_pref::WebPreferences& r) {
return r.allow_running_insecure_content;
}
static bool disable_reading_from_canvas(
const blink::web_pref::WebPreferences& r) {
return r.disable_reading_from_canvas;
}
static bool strict_mixed_content_checking(
const blink::web_pref::WebPreferences& r) {
return r.strict_mixed_content_checking;
}
static bool strict_powerful_feature_restrictions(
const blink::web_pref::WebPreferences& r) {
return r.strict_powerful_feature_restrictions;
}
static bool allow_geolocation_on_insecure_origins(
const blink::web_pref::WebPreferences& r) {
return r.allow_geolocation_on_insecure_origins;
}
static bool strictly_block_blockable_mixed_content(
const blink::web_pref::WebPreferences& r) {
return r.strictly_block_blockable_mixed_content;
}
static bool block_mixed_plugin_content(
const blink::web_pref::WebPreferences& r) {
return r.block_mixed_plugin_content;
}
static bool password_echo_enabled(const blink::web_pref::WebPreferences& r) {
return r.password_echo_enabled;
}
static bool should_clear_document_background(
const blink::web_pref::WebPreferences& r) {
return r.should_clear_document_background;
}
static bool enable_scroll_animator(const blink::web_pref::WebPreferences& r) {
return r.enable_scroll_animator;
}
static bool prefers_reduced_motion(const blink::web_pref::WebPreferences& r) {
return r.prefers_reduced_motion;
}
static bool touch_event_feature_detection_enabled(
const blink::web_pref::WebPreferences& r) {
return r.touch_event_feature_detection_enabled;
}
static uint32_t pointer_events_max_touch_points(
const blink::web_pref::WebPreferences& r) {
return r.pointer_events_max_touch_points;
}
static uint32_t available_pointer_types(
const blink::web_pref::WebPreferences& r) {
return r.available_pointer_types;
}
static ui::PointerType primary_pointer_type(
const blink::web_pref::WebPreferences& r) {
return r.primary_pointer_type;
}
static uint32_t available_hover_types(
const blink::web_pref::WebPreferences& r) {
return r.available_hover_types;
}
static ui::HoverType primary_hover_type(
const blink::web_pref::WebPreferences& r) {
return r.primary_hover_type;
}
static bool dont_send_key_events_to_javascript(
const blink::web_pref::WebPreferences& r) {
return r.dont_send_key_events_to_javascript;
}
static bool barrel_button_for_drag_enabled(
const blink::web_pref::WebPreferences& r) {
return r.barrel_button_for_drag_enabled;
}
static bool sync_xhr_in_documents_enabled(
const blink::web_pref::WebPreferences& r) {
return r.sync_xhr_in_documents_enabled;
}
static uint32_t number_of_cpu_cores(
const blink::web_pref::WebPreferences& r) {
return r.number_of_cpu_cores;
}
static blink::web_pref::EditingBehaviorType editing_behavior(
const blink::web_pref::WebPreferences& r) {
return r.editing_behavior;
}
static bool supports_multiple_windows(
const blink::web_pref::WebPreferences& r) {
return r.supports_multiple_windows;
}
static bool viewport_enabled(const blink::web_pref::WebPreferences& r) {
return r.viewport_enabled;
}
static bool viewport_meta_enabled(const blink::web_pref::WebPreferences& r) {
return r.viewport_meta_enabled;
}
static bool shrinks_viewport_contents_to_fit(
const blink::web_pref::WebPreferences& r) {
return r.shrinks_viewport_contents_to_fit;
}
static blink::web_pref::ViewportStyle viewport_style(
const blink::web_pref::WebPreferences& r) {
return r.viewport_style;
}
static bool smooth_scroll_for_find_enabled(
const blink::web_pref::WebPreferences& r) {
return r.smooth_scroll_for_find_enabled;
}
static bool main_frame_resizes_are_orientation_changes(
const blink::web_pref::WebPreferences& r) {
return r.main_frame_resizes_are_orientation_changes;
}
static bool initialize_at_minimum_page_scale(
const blink::web_pref::WebPreferences& r) {
return r.initialize_at_minimum_page_scale;
}
static bool smart_insert_delete_enabled(
const blink::web_pref::WebPreferences& r) {
return r.smart_insert_delete_enabled;
}
static bool spatial_navigation_enabled(
const blink::web_pref::WebPreferences& r) {
return r.spatial_navigation_enabled;
}
static bool navigate_on_drag_drop(const blink::web_pref::WebPreferences& r) {
return r.navigate_on_drag_drop;
}
static const blink::mojom::V8CacheOptions& v8_cache_options(
const blink::web_pref::WebPreferences& r) {
return r.v8_cache_options;
}
static bool record_whole_document(const blink::web_pref::WebPreferences& r) {
return r.record_whole_document;
}
static bool cookie_enabled(const blink::web_pref::WebPreferences& r) {
return r.cookie_enabled;
}
static bool accelerated_video_decode_enabled(
const blink::web_pref::WebPreferences& r) {
return r.accelerated_video_decode_enabled;
}
static blink::web_pref::ImageAnimationPolicy animation_policy(
const blink::web_pref::WebPreferences& r) {
return r.animation_policy;
}
static bool user_gesture_required_for_presentation(
const blink::web_pref::WebPreferences& r) {
return r.user_gesture_required_for_presentation;
}
static bool text_tracks_enabled(const blink::web_pref::WebPreferences& r) {
return r.text_tracks_enabled;
}
static const std::string& text_track_background_color(
const blink::web_pref::WebPreferences& r) {
return r.text_track_background_color;
}
static const std::string& text_track_text_color(
const blink::web_pref::WebPreferences& r) {
return r.text_track_text_color;
}
static const std::string& text_track_text_size(
const blink::web_pref::WebPreferences& r) {
return r.text_track_text_size;
}
static const std::string& text_track_text_shadow(
const blink::web_pref::WebPreferences& r) {
return r.text_track_text_shadow;
}
static const std::string& text_track_font_family(
const blink::web_pref::WebPreferences& r) {
return r.text_track_font_family;
}
static const std::string& text_track_font_style(
const blink::web_pref::WebPreferences& r) {
return r.text_track_font_style;
}
static const std::string& text_track_font_variant(
const blink::web_pref::WebPreferences& r) {
return r.text_track_font_variant;
}
static const std::string& text_track_window_color(
const blink::web_pref::WebPreferences& r) {
return r.text_track_window_color;
}
static const std::string& text_track_window_padding(
const blink::web_pref::WebPreferences& r) {
return r.text_track_window_padding;
}
static const std::string& text_track_window_radius(
const blink::web_pref::WebPreferences& r) {
return r.text_track_window_radius;
}
static float text_track_margin_percentage(
const blink::web_pref::WebPreferences& r) {
return r.text_track_margin_percentage;
}
static bool immersive_mode_enabled(const blink::web_pref::WebPreferences& r) {
return r.immersive_mode_enabled;
}
static bool double_tap_to_zoom_enabled(
const blink::web_pref::WebPreferences& r) {
return r.double_tap_to_zoom_enabled;
}
static bool fullscreen_supported(const blink::web_pref::WebPreferences& r) {
return r.fullscreen_supported;
}
static bool text_autosizing_enabled(
const blink::web_pref::WebPreferences& r) {
return r.text_autosizing_enabled;
}
static const GURL& web_app_scope(const ::blink::web_pref::WebPreferences& r) {
return r.web_app_scope;
}
#if defined(OS_ANDROID)
static float font_scale_factor(const blink::web_pref::WebPreferences& r) {
return r.font_scale_factor;
}
static float device_scale_adjustment(
const blink::web_pref::WebPreferences& r) {
return r.device_scale_adjustment;
}
static bool force_enable_zoom(const blink::web_pref::WebPreferences& r) {
return r.force_enable_zoom;
}
static const GURL& default_video_poster_url(
const blink::web_pref::WebPreferences& r) {
return r.default_video_poster_url;
}
static bool support_deprecated_target_density_dpi(
const blink::web_pref::WebPreferences& r) {
return r.support_deprecated_target_density_dpi;
}
static bool use_legacy_background_size_shorthand_behavior(
const blink::web_pref::WebPreferences& r) {
return r.use_legacy_background_size_shorthand_behavior;
}
static bool wide_viewport_quirk(const blink::web_pref::WebPreferences& r) {
return r.wide_viewport_quirk;
}
static bool use_wide_viewport(const blink::web_pref::WebPreferences& r) {
return r.use_wide_viewport;
}
static bool force_zero_layout_height(
const blink::web_pref::WebPreferences& r) {
return r.force_zero_layout_height;
}
static bool viewport_meta_merge_content_quirk(
const blink::web_pref::WebPreferences& r) {
return r.viewport_meta_merge_content_quirk;
}
static bool viewport_meta_non_user_scalable_quirk(
const blink::web_pref::WebPreferences& r) {
return r.viewport_meta_non_user_scalable_quirk;
}
static bool viewport_meta_zero_values_quirk(
const blink::web_pref::WebPreferences& r) {
return r.viewport_meta_zero_values_quirk;
}
static bool clobber_user_agent_initial_scale_quirk(
const blink::web_pref::WebPreferences& r) {
return r.clobber_user_agent_initial_scale_quirk;
}
static bool ignore_main_frame_overflow_hidden_quirk(
const blink::web_pref::WebPreferences& r) {
return r.ignore_main_frame_overflow_hidden_quirk;
}
static bool report_screen_size_in_physical_pixels_quirk(
const blink::web_pref::WebPreferences& r) {
return r.report_screen_size_in_physical_pixels_quirk;
}
static bool reuse_global_for_unowned_main_frame(
const blink::web_pref::WebPreferences& r) {
return r.reuse_global_for_unowned_main_frame;
}
static bool spellcheck_enabled_by_default(
const blink::web_pref::WebPreferences& r) {
return r.spellcheck_enabled_by_default;
}
static bool video_fullscreen_orientation_lock_enabled(
const blink::web_pref::WebPreferences& r) {
return r.video_fullscreen_orientation_lock_enabled;
}
static bool video_rotate_to_fullscreen_enabled(
const blink::web_pref::WebPreferences& r) {
return r.video_rotate_to_fullscreen_enabled;
}
static bool embedded_media_experience_enabled(
const blink::web_pref::WebPreferences& r) {
return r.embedded_media_experience_enabled;
}
static bool css_hex_alpha_color_enabled(
const blink::web_pref::WebPreferences& r) {
return r.css_hex_alpha_color_enabled;
}
static bool scroll_top_left_interop_enabled(
const blink::web_pref::WebPreferences& r) {
return r.scroll_top_left_interop_enabled;
}
static bool disable_features_depending_on_viz(
const blink::web_pref::WebPreferences& r) {
return r.disable_features_depending_on_viz;
}
static bool disable_accelerated_small_canvases(
const blink::web_pref::WebPreferences& r) {
return r.disable_accelerated_small_canvases;
}
static bool reenable_web_components_v0(
const blink::web_pref::WebPreferences& r) {
return r.reenable_web_components_v0;
}
#endif
static bool force_dark_mode_enabled(
const blink::web_pref::WebPreferences& r) {
return r.force_dark_mode_enabled;
}
static float default_minimum_page_scale_factor(
const blink::web_pref::WebPreferences& r) {
return r.default_minimum_page_scale_factor;
}
static float default_maximum_page_scale_factor(
const blink::web_pref::WebPreferences& r) {
return r.default_maximum_page_scale_factor;
}
static bool hide_download_ui(const blink::web_pref::WebPreferences& r) {
return r.hide_download_ui;
}
static bool presentation_receiver(const blink::web_pref::WebPreferences& r) {
return r.presentation_receiver;
}
static bool media_controls_enabled(const blink::web_pref::WebPreferences& r) {
return r.media_controls_enabled;
}
static bool do_not_update_selection_on_mutating_selection_range(
const blink::web_pref::WebPreferences& r) {
return r.do_not_update_selection_on_mutating_selection_range;
}
static blink::web_pref::AutoplayPolicy autoplay_policy(
const blink::web_pref::WebPreferences& r) {
return r.autoplay_policy;
}
static blink::PreferredColorScheme preferred_color_scheme(
const blink::web_pref::WebPreferences& r) {
return r.preferred_color_scheme;
}
static net::EffectiveConnectionType low_priority_iframes_threshold(
const blink::web_pref::WebPreferences& r) {
return r.low_priority_iframes_threshold;
}
static bool picture_in_picture_enabled(
const blink::web_pref::WebPreferences& r) {
return r.picture_in_picture_enabled;
}
static bool translate_service_available(
const blink::web_pref::WebPreferences& r) {
return r.translate_service_available;
}
static net::EffectiveConnectionType network_quality_estimator_web_holdback(
const blink::web_pref::WebPreferences& r) {
return r.network_quality_estimator_web_holdback;
}
static bool lazy_load_enabled(const blink::web_pref::WebPreferences& r) {
return r.lazy_load_enabled;
}
static const std::map<net::EffectiveConnectionType, int32_t>&
lazy_frame_loading_distance_thresholds_px(
const blink::web_pref::WebPreferences& r) {
return r.lazy_frame_loading_distance_thresholds_px;
}
static const std::map<net::EffectiveConnectionType, int32_t>&
lazy_image_loading_distance_thresholds_px(
const blink::web_pref::WebPreferences& r) {
return r.lazy_image_loading_distance_thresholds_px;
}
static const std::map<net::EffectiveConnectionType, int32_t>&
lazy_image_first_k_fully_load(const blink::web_pref::WebPreferences& r) {
return r.lazy_image_first_k_fully_load;
}
static bool allow_mixed_content_upgrades(
const blink::web_pref::WebPreferences& r) {
return r.allow_mixed_content_upgrades;
}
static bool always_show_focus(const blink::web_pref::WebPreferences& r) {
return r.always_show_focus;
}
static bool touch_drag_drop_enabled(
const blink::web_pref::WebPreferences& r) {
return r.touch_drag_drop_enabled;
}
static bool Read(blink::mojom::WebPreferencesDataView r,
blink::web_pref::WebPreferences* out);
};
} // namespace mojo
#endif // THIRD_PARTY_BLINK_PUBLIC_COMMON_WEB_PREFERENCES_WEB_PREFERENCES_MOJOM_TRAITS_H_

@ -174,6 +174,7 @@ mojom("mojom_platform") {
"web_launch/web_launch.mojom",
"webaudio/audio_context_manager.mojom",
"webdatabase/web_database.mojom",
"webpreferences/web_preferences.mojom",
"websockets/websocket_connector.mojom",
"webtransport/quic_transport_connector.mojom",
"widget/device_emulation_params.mojom",
@ -405,6 +406,15 @@ mojom("mojom_platform") {
traits_headers = [ "//third_party/blink/public/common/frame/frame_owner_properties_mojom_traits.h" ]
traits_public_deps = [ "//third_party/blink/public/common:headers" ]
},
{
types = [
{
mojom = "blink.mojom.WebPreferences"
cpp = "::blink::web_pref::WebPreferences"
},
]
traits_headers = [ "//third_party/blink/public/common/web_preferences/web_preferences_mojom_traits.h" ]
},
]
cpp_typemaps = [
{

@ -5,6 +5,7 @@
module blink.mojom;
import "mojo/public/mojom/base/time.mojom";
import "third_party/blink/public/mojom/page/page_visibility_state.mojom";
import "third_party/blink/public/mojom/webpreferences/web_preferences.mojom";
enum PagehideDispatch {
// We haven't dispatched pagehide and should do so when appropriate.
@ -56,4 +57,7 @@ interface PageBroadcast {
// Notifies renderers when a portal web contents is activated or if a
// web contents is adopted as a portal.
SetInsidePortal(bool is_inside_portal);
// Notifies the renderer when updating a set of blink preferences.
UpdateWebPreferences(blink.mojom.WebPreferences preferences);
};

@ -0,0 +1,2 @@
per-file *.mojom=set noparent
per-file *.mojom=file://ipc/SECURITY_OWNERS

@ -0,0 +1,423 @@
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module blink.mojom;
import "third_party/blink/public/mojom/v8_cache_options.mojom";
import "url/mojom/url.mojom";
import "mojo/public/mojom/base/string16.mojom";
enum PointerType {
kPointerFirstType = 1, // 1 << 0
kPointerCoarseType = 2, // 1 << 1
kPointerFineType = 4 // 1 << 2
};
enum HoverType {
kHoverFirstType = 1, // 1 << 0
kHoverHoverType = 2 // 1 << 1
};
enum PreferredColorScheme {
kDark,
kLight,
};
// TODO(gyuyoung): This Mojo enum will replace all uses of
// web_pref::EditingBehaviorType in a follow-up CL.
enum EditingBehavior {
kEditingMacBehavior,
kEditingWindowsBehavior,
kEditingUnixBehavior,
kEditingAndroidBehavior,
kEditingChromeOSBehavior
};
// ImageAnimationPolicy is used for controlling image animation
// when image frame is rendered for animation.
// See third_party/WebKit/Source/platform/graphics/ImageAnimationPolicy.h
// for information on the options.
enum ImageAnimationPolicy {
kImageAnimationPolicyAllowed,
kImageAnimationPolicyAnimateOnce,
kImageAnimationPolicyNoAnimation
};
enum ViewportStyle { kDefault, kMobile, kTelevision, kLast = kTelevision };
// Defines the autoplay policy to be used. Should match the class in
// WebSettings.h.
enum AutoplayPolicy {
kNoUserGestureRequired,
kUserGestureRequired,
kDocumentUserActivationRequired,
};
enum EffectiveConnectionType {
// Effective connection type reported when the network quality is unknown.
kEffectiveConnectionUnknownType,
// Effective connection type reported when the Internet is unreachable
// because the device does not have a connection (as reported by underlying
// platform APIs). Note that due to rare but potential bugs in the platform
// APIs, it is possible that effective connection type is reported as
// EFFECTIVE_CONNECTION_TYPE_OFFLINE. Callers must use caution when using
// acting on this.
kEffectiveConnectionOfflineType,
// Effective connection type reported when the network has the quality of a
// poor 2G connection.
kEffectiveConnectionSlow2GType,
// Effective connection type reported when the network has the quality of a
// faster 2G connection.
kEffectiveConnection2GType,
// Effective connection type reported when the network has the quality of a 3G
// connection.
kEffectiveConnection3GType,
// Effective connection type reported when the network has the quality of a 4G
// connection.
kEffectiveConnection4GType,
};
struct WebPreferences {
map<string, mojo_base.mojom.String16> standard_font_family_map;
map<string, mojo_base.mojom.String16> fixed_font_family_map;
map<string, mojo_base.mojom.String16> serif_font_family_map;
map<string, mojo_base.mojom.String16> sans_serif_font_family_map;
map<string, mojo_base.mojom.String16> cursive_font_family_map;
map<string, mojo_base.mojom.String16> fantasy_font_family_map;
map<string, mojo_base.mojom.String16> pictograph_font_family_map;
int32 default_font_size;
int32 default_fixed_font_size;
int32 minimum_font_size;
int32 minimum_logical_font_size;
string default_encoding;
bool context_menu_on_mouse_up;
bool javascript_enabled;
bool web_security_enabled;
bool loads_images_automatically;
bool images_enabled;
bool plugins_enabled;
bool dom_paste_enabled;
bool shrinks_standalone_images_to_fit;
bool text_areas_are_resizable;
bool allow_scripts_to_close_windows;
bool remote_fonts_enabled;
bool javascript_can_access_clipboard;
bool xslt_enabled;
// We don't use dns_prefetching_enabled to disable DNS prefetching. Instead,
// we disable the feature at a lower layer so that we catch non-WebKit uses
// of DNS prefetch as well.
bool dns_prefetching_enabled;
// Preference to save data. When enabled, requests will contain the header
// 'Save-Data: on'.
bool data_saver_enabled;
// Whether data saver holdback for Web APIs is enabled. If enabled, data saver
// appears as disabled to the web consumers even if it has been actually
// enabled by the user.
bool data_saver_holdback_web_api_enabled;
bool local_storage_enabled;
bool databases_enabled;
bool application_cache_enabled;
bool tabs_to_links;
bool disable_ipc_flooding_protection;
bool hyperlink_auditing_enabled;
bool allow_universal_access_from_file_urls;
bool allow_file_access_from_file_urls;
bool webgl1_enabled;
bool webgl2_enabled;
bool pepper_3d_enabled;
bool flash_3d_enabled;
bool flash_stage3d_enabled;
bool flash_stage3d_baseline_enabled;
bool privileged_webgl_extensions_enabled;
bool webgl_errors_to_console_enabled;
bool hide_scrollbars;
bool accelerated_2d_canvas_enabled;
bool new_canvas_2d_api_enabled;
bool antialiased_2d_canvas_disabled;
bool antialiased_clips_2d_canvas_enabled;
bool accelerated_filters_enabled;
bool deferred_filters_enabled;
bool container_culling_enabled;
bool allow_running_insecure_content;
// If true, taint32s all <canvas> elements, regardless of origin.
bool disable_reading_from_canvas;
// Strict mixed content checking disables both displaying and running insecure
// mixed content, and disables embedder notifications that such content was
// requested (thereby preventing user override).
bool strict_mixed_content_checking;
// Strict powerful feature restrictions block insecure usage of powerful
// features (like device orientation) that we haven't yet disabled for the web
// at large.
bool strict_powerful_feature_restrictions;
// TODO(jww): Remove when WebView no longer needs this exception.
bool allow_geolocation_on_insecure_origins;
// Disallow user opt-in for blockable mixed content.
bool strictly_block_blockable_mixed_content;
bool block_mixed_plugin_content;
bool password_echo_enabled;
bool should_clear_document_background;
bool enable_scroll_animator;
bool prefers_reduced_motion;
bool touch_event_feature_detection_enabled;
int32 pointer_events_max_touch_points;
int32 available_pointer_types;
PointerType primary_pointer_type;
int32 available_hover_types;
HoverType primary_hover_type;
bool dont_send_key_events_to_javascript;
bool barrel_button_for_drag_enabled;
bool sync_xhr_in_documents_enabled;
int32 number_of_cpu_cores;
EditingBehavior editing_behavior;
bool supports_multiple_windows;
bool viewport_enabled;
bool viewport_meta_enabled;
// If true - Blink will clamp the minimum scale factor to the content width,
// preventing zoom beyond the visible content. This is really only needed if
// viewport_enabled is on.
bool shrinks_viewport_contents_to_fit;
ViewportStyle viewport_style;
bool smooth_scroll_for_find_enabled;
bool main_frame_resizes_are_orientation_changes;
bool initialize_at_minimum_page_scale;
bool smart_insert_delete_enabled;
bool spatial_navigation_enabled;
bool navigate_on_drag_drop;
V8CacheOptions v8_cache_options;
bool record_whole_document;
// This flags corresponds to a Page's Settings' setCookieEnabled state. It
// only controls whether or not the "document.cookie" field is properly
// connected to the backing store, for instance if you wanted to be able to
// define custom getters and setters from within a unique security content
// without raising a DOM security exception.
bool cookie_enabled;
// This flag indicates whether H/W accelerated video decode is enabled.
// Defaults to false.
bool accelerated_video_decode_enabled;
ImageAnimationPolicy animation_policy;
bool user_gesture_required_for_presentation;
bool text_tracks_enabled;
// These fields specify the foreground and background color for WebVTT text
// tracks. Their values can be any legal CSS color descriptor.
string text_track_background_color;
string text_track_text_color;
// These fields specify values for CSS properties used to style WebVTT text
// tracks.
// Specifies CSS font-size property in percentage.
string text_track_text_size;
string text_track_text_shadow;
string text_track_font_family;
string text_track_font_style;
// Specifies the value for CSS font-variant property.
string text_track_font_variant;
// These fields specify values for CSS properties used to style the window
// around WebVTT text tracks.
// Window color can be any legal CSS color descriptor.
string text_track_window_color;
// Window padding is in em.
string text_track_window_padding;
// Window radius is in pixels.
string text_track_window_radius;
// Specifies the margin for WebVTT text tracks as a percentage of media
// element height/width (for horizontal/vertical text respectively).
// Cues will not be placed in this margin area.
float text_track_margin_percentage;
bool immersive_mode_enabled;
bool double_tap_to_zoom_enabled;
bool fullscreen_supported;
bool text_autosizing_enabled;
// Representation of the Web App Manifest scope if any.
url.mojom.Url web_app_scope;
[EnableIf=is_android]
float font_scale_factor;
[EnableIf=is_android]
float device_scale_adjustment;
[EnableIf=is_android]
bool force_enable_zoom;
[EnableIf=is_android]
url.mojom.Url default_video_poster_url;
[EnableIf=is_android]
bool support_deprecated_target_density_dpi;
[EnableIf=is_android]
bool use_legacy_background_size_shorthand_behavior;
[EnableIf=is_android]
bool wide_viewport_quirk;
[EnableIf=is_android]
bool use_wide_viewport;
[EnableIf=is_android]
bool force_zero_layout_height;
[EnableIf=is_android]
bool viewport_meta_merge_content_quirk;
[EnableIf=is_android]
bool viewport_meta_non_user_scalable_quirk;
[EnableIf=is_android]
bool viewport_meta_zero_values_quirk;
[EnableIf=is_android]
bool clobber_user_agent_initial_scale_quirk;
[EnableIf=is_android]
bool ignore_main_frame_overflow_hidden_quirk;
[EnableIf=is_android]
bool report_screen_size_in_physical_pixels_quirk;
// Used by Android_WebView only to support legacy apps that inject script int32o
// a top-level initial empty document and expect it to persist on navigation.
[EnableIf=is_android]
bool reuse_global_for_unowned_main_frame;
// Specifies default setting for spellcheck when the spellcheck attribute is
// not explicitly specified.
[EnableIf=is_android]
bool spellcheck_enabled_by_default;
// If enabled, when a video goes fullscreen, the orientation should be locked.
[EnableIf=is_android]
bool video_fullscreen_orientation_lock_enabled;
// If enabled, fullscreen should be entered/exited when the device is rotated
// to/from the orientation of the video.
[EnableIf=is_android]
bool video_rotate_to_fullscreen_enabled;
[EnableIf=is_android]
bool embedded_media_experience_enabled;
// Enable 8 (#RRGGBBAA) and 4 (#RGBA) value hex colors in CSS Android
// WebView quirk (http://crbug.com/618472).
[EnableIf=is_android]
bool css_hex_alpha_color_enabled;
// Enable support for document.scrollingElement
// WebView sets this to false to retain old documentElement behaviour
// (http://crbug.com/761016).
[EnableIf=is_android]
bool scroll_top_left_interop_enabled;
// Disable features such as offscreen canvas that depend on the viz
// architecture of surface embedding. Android WebView does not support this
// architecture yet.
[EnableIf=is_android]
bool disable_features_depending_on_viz;
[EnableIf=is_android]
// Don't accelerate small canvases to avoid crashes TODO(crbug.com/1004304)
bool disable_accelerated_small_canvases;
// Re-enable Web Components v0 on Webview, temporarily. This should get
// removed when crbug.com/1021631 gets fixed.
[EnableIf=is_android]
bool reenable_web_components_v0;
// Enable forcibly modifying content rendering to result in a light on dark
// color scheme.
bool force_dark_mode_enabled;
// Default (used if the page or UA doesn't override these) values for page
// scale limits. These are set directly on the WebView so there's no analogue
// in WebSettings.
float default_minimum_page_scale_factor;
float default_maximum_page_scale_factor;
// Whether download UI should be hidden on this page.
bool hide_download_ui;
// Whether it is a presentation receiver.
bool presentation_receiver;
// If disabled, media controls should never be used.
bool media_controls_enabled;
// Whether we want to disable updating selection on mutating selection range.
// This is to work around Samsung's email app issue. See
// https://crbug.com/699943 for details.
// TODO(changwan): remove this once we no longer support Android N.
bool do_not_update_selection_on_mutating_selection_range;
// Defines the current autoplay policy.
AutoplayPolicy autoplay_policy;
// The preferred color scheme for the web content. The scheme is used to
// evaluate the prefers-color-scheme media query and resolve UA color scheme
// to be used based on the supported-color-schemes META tag and CSS property.
PreferredColorScheme preferred_color_scheme;
// Network quality threshold below which resources from iframes are assigned
// either kVeryLow or kVeryLow Blink priority.
EffectiveConnectionType low_priority_iframes_threshold;
// Whether Picture-in-Picture is enabled.
bool picture_in_picture_enabled;
// Whether a translate service is available.
// blink's hrefTranslate attribute existence relies on the result.
// See https://github.com/dtapuska/html-translate
bool translate_service_available;
// A value other than net::EFFECTIVE_CONNECTION_TYPE_UNKNOWN implies that the
// network quality estimate related Web APIs are in the holdback mode. When
// the holdback is enabled, the related Web APIs return network quality
// estimate corresponding to |network_quality_estimator_web_holdback|
// regardless of the actual quality.
EffectiveConnectionType network_quality_estimator_web_holdback;
// Whether lazy loading of frames and images is enabled.
bool lazy_load_enabled;
// Specifies how close a lazily loaded iframe or image should be from the
// viewport before it should start being loaded in, depending on the effective
// connection type of the current network. Blink will use the default distance
// threshold for effective connection types that aren't specified here.
map<EffectiveConnectionType, int32>
lazy_frame_loading_distance_thresholds_px;
map<EffectiveConnectionType, int32>
lazy_image_loading_distance_thresholds_px;
map<EffectiveConnectionType, int32> lazy_image_first_k_fully_load;
// Setting to false disables upgrades to HTTPS for HTTP resources in HTTPS
// sites.
bool allow_mixed_content_upgrades;
// Whether the focused element should always be indicated (for example, by
// forcing :focus-visible to match regardless of focus method).
bool always_show_focus;
// Whether touch input can trigger HTML drag-and-drop operations. The
// default value depends on the platform.
bool touch_drag_drop_enabled;
};

@ -240,6 +240,8 @@ class CORE_EXPORT WebViewImpl final : public WebView,
SetPageLifecycleStateCallback callback) override;
void AudioStateChanged(bool is_audio_playing) override;
void SetInsidePortal(bool is_inside_portal) override;
void UpdateWebPreferences(
const blink::web_pref::WebPreferences& preferences) override;
void DispatchPageshow(base::TimeTicks navigation_start);
void DispatchPagehide(mojom::blink::PagehideDispatch pagehide_dispatch);
@ -541,9 +543,6 @@ class CORE_EXPORT WebViewImpl final : public WebView,
// browser.
void DoDeferredCloseWindowSoon();
// Applies blink related preferences to this view.
void UpdateWebPreferences(const blink::web_pref::WebPreferences& preferences);
WebViewImpl(
WebViewClient*,
mojom::blink::PageVisibilityState visibility,

@ -9,9 +9,9 @@ if (window.testRunner) {
onload = function() {
var newWindow = window.open('resources/5000x5000.png', 'image', 'width=100,height=150');
if (newWindow.internals)
newWindow.internals.settings.setViewportEnabled(true);
newWindow.onload = function() {
if (newWindow.internals)
newWindow.internals.settings.setViewportEnabled(true);
runAfterLayoutAndPaint(function() {
document.getElementById('output').textContent =
'\nviewport meta: ' + newWindow.document.querySelector('meta').outerHTML