Commit 14c0551e authored by Mario Sanchez Prada's avatar Mario Sanchez Prada Committed by Commit Bot

Move RemoteSet<blink::mojom::RendererPreferenceWatcher> to WebViewImpl

Now that we have migrated the PageMsg_SetRendererPrefs legacy IPC to
Mojo and the ownership of blink::RendererPreferences to WebViewImpl,
we can also move this mojo RemoteSet to WebViewImpl as well, enabling
us to move even more code from RenderViewImpl into Blink.

Thus, this CL moves |renderer_preferences_watcher| into WebViewImpl by
defining a new WebView::RegisterRendererPreferenceWatcher() method that
would receive a CrossVariantMojoRemote as parameter to bind the remote
in Blink. With that in place WebViewImpl::SetRendererPreferences() does
no longer rely on RenderViewImpl::DidUpdateRendererPreferences() to
notify the watchers, getting us one step closer to entirely remove that
method from WebViewClient and its only implementor i.e. RenderViewImpl.

Bug: 1102442
Change-Id: If35c5302616e6411198965d35f55f04683a73db4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2498503
Commit-Queue: Mario Sanchez Prada <mario@igalia.com>
Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821236}
parent 936e8ffe
......@@ -646,7 +646,7 @@ void RenderViewImpl::DidUpdateMainFrameLayout() {
void RenderViewImpl::RegisterRendererPreferenceWatcher(
mojo::PendingRemote<blink::mojom::RendererPreferenceWatcher> watcher) {
renderer_preference_watchers_.Add(std::move(watcher));
GetWebView()->RegisterRendererPreferenceWatcher(std::move(watcher));
}
const blink::RendererPreferences& RenderViewImpl::GetRendererPreferences()
......@@ -730,12 +730,9 @@ blink::WebView* RenderViewImpl::GetWebView() {
}
void RenderViewImpl::DidUpdateRendererPreferences() {
const blink::RendererPreferences& renderer_prefs = GetRendererPreferences();
for (auto& watcher : renderer_preference_watchers_)
watcher->NotifyUpdate(renderer_prefs);
#if defined(OS_WIN)
// Update Theme preferences on Windows.
const blink::RendererPreferences& renderer_prefs = GetRendererPreferences();
WebThemeEngineDefault::cacheScrollBarMetrics(
renderer_prefs.vertical_scroll_bar_width_in_dips,
renderer_prefs.horizontal_scroll_bar_height_in_dips,
......
......@@ -371,11 +371,6 @@ class CONTENT_EXPORT RenderViewImpl : public blink::WebViewClient,
// Settings ------------------------------------------------------------------
// These are observing changes in the WebView's RendererPreferences. This is
// used for keeping WorkerFetchContext in sync.
mojo::RemoteSet<blink::mojom::RendererPreferenceWatcher>
renderer_preference_watchers_;
// Whether content state (such as form state, scroll position and page
// contents) should be sent to the browser immediately. This is normally
// false, but set to true by some tests.
......
......@@ -38,6 +38,7 @@
#include "third_party/blink/public/mojom/input/focus_type.mojom-shared.h"
#include "third_party/blink/public/mojom/page/page.mojom-shared.h"
#include "third_party/blink/public/mojom/page/page_visibility_state.mojom-shared.h"
#include "third_party/blink/public/mojom/renderer_preference_watcher.mojom-shared.h"
#include "third_party/blink/public/mojom/widget/screen_orientation.mojom-shared.h"
#include "third_party/blink/public/platform/cross_variant_mojo_util.h"
#include "third_party/blink/public/platform/scheduler/web_agent_group_scheduler.h"
......@@ -438,6 +439,10 @@ class WebView {
// Renderer preferences ---------------------------------------------------
virtual void RegisterRendererPreferenceWatcher(
CrossVariantMojoRemote<mojom::RendererPreferenceWatcherInterfaceBase>
watcher) = 0;
virtual void SetRendererPreferences(
const RendererPreferences& preferences) = 0;
virtual const RendererPreferences& GetRendererPreferences() = 0;
......
......@@ -3888,6 +3888,12 @@ void WebViewImpl::SetInsidePortal(bool inside_portal) {
web_widget_->SetIsNestedMainFrameWidget(inside_portal);
}
void WebViewImpl::RegisterRendererPreferenceWatcher(
CrossVariantMojoRemote<mojom::RendererPreferenceWatcherInterfaceBase>
watcher) {
renderer_preference_watchers_.Add(std::move(watcher));
}
void WebViewImpl::SetRendererPreferences(
const RendererPreferences& preferences) {
UpdateRendererPreferences(preferences);
......@@ -3902,10 +3908,12 @@ void WebViewImpl::UpdateRendererPreferences(
std::string old_accept_languages = renderer_preferences_.accept_languages;
renderer_preferences_ = preferences;
for (auto& watcher : renderer_preference_watchers_)
watcher->NotifyUpdate(renderer_preferences_);
// TODO(crbug.com/1102442): Remove once we no longer need to update theme
// preferences on Windows via content::WebThemeEngineDefault.
web_view_client_->DidUpdateRendererPreferences();
UpdateFontRenderingFromRendererPrefs();
blink::SetCaretBlinkInterval(
......
......@@ -37,6 +37,7 @@
#include "build/build_config.h"
#include "mojo/public/cpp/bindings/associated_receiver.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "mojo/public/cpp/bindings/remote_set.h"
#include "third_party/blink/public/common/input/web_gesture_event.h"
#include "third_party/blink/public/common/input/web_input_event.h"
#include "third_party/blink/public/common/renderer_preferences/renderer_preferences.h"
......@@ -44,6 +45,7 @@
#include "third_party/blink/public/mojom/input/focus_type.mojom-blink-forward.h"
#include "third_party/blink/public/mojom/page/page.mojom-blink.h"
#include "third_party/blink/public/mojom/page/page_visibility_state.mojom-blink.h"
#include "third_party/blink/public/mojom/renderer_preference_watcher.mojom-blink.h"
#include "third_party/blink/public/platform/scheduler/web_agent_group_scheduler.h"
#include "third_party/blink/public/platform/web_input_event_result.h"
#include "third_party/blink/public/platform/web_rect.h"
......@@ -206,6 +208,9 @@ class CORE_EXPORT WebViewImpl final : public WebView,
void SetDeviceColorSpaceForTesting(
const gfx::ColorSpace& color_space) override;
void PaintContent(cc::PaintCanvas*, const gfx::Rect&) override;
void RegisterRendererPreferenceWatcher(
CrossVariantMojoRemote<mojom::RendererPreferenceWatcherInterfaceBase>
watcher) override;
void SetRendererPreferences(const RendererPreferences& preferences) override;
const RendererPreferences& GetRendererPreferences() override;
void SetWebPreferences(const web_pref::WebPreferences& preferences) override;
......@@ -866,6 +871,11 @@ class CORE_EXPORT WebViewImpl final : public WebView,
mojom::blink::PageLifecycleStatePtr lifecycle_state_;
mojo::AssociatedReceiver<mojom::blink::PageBroadcast> receiver_;
// These are observing changes in |renderer_preferences_|. This is used for
// keeping WorkerFetchContext in sync.
mojo::RemoteSet<mojom::blink::RendererPreferenceWatcher>
renderer_preference_watchers_;
base::WeakPtrFactory<WebViewImpl> weak_ptr_factory_{this};
};
......
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