Commit cbe8dae1 authored by Gyuyoung Kim's avatar Gyuyoung Kim Committed by Commit Bot

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/+/2426070Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Gyuyoung Kim <gyuyoung@igalia.com>
Cr-Commit-Position: refs/heads/master@{#812602}
parent f397d738
......@@ -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" ]
}
// 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",
......
per-file *_mojom_traits*.*=set noparent
per-file *_mojom_traits*.*=file://ipc/SECURITY_OWNERS
\ No newline at end of file
......@@ -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");
}
......
per-file *_mojom_traits*.*=set noparent
per-file *_mojom_traits*.*=file://ipc/SECURITY_OWNERS
\ No newline at end of file
......@@ -43,8 +43,7 @@ enum EditingBehaviorType {
kEditingWindowsBehavior,
kEditingUnixBehavior,
kEditingAndroidBehavior,
kEditingChromeOSBehavior,
kEditingLastBehavior
kEditingChromeOSBehavior
};
} // namespace web_pref
......
......@@ -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);
};
per-file *.mojom=set noparent
per-file *.mojom=file://ipc/SECURITY_OWNERS
\ No newline at end of file
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment