Commit c1df3739 authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Revert "Propagate update on RendererPreferences to ServiceWorkerFetchContextImpl"

This reverts commit b6cde39f.

Reason for revert: Caused flaky compile failures, e.g. https://ci.chromium.org/buildbot/chromium.chrome/Google%20Chrome%20ChromeOS/54711 , https://ci.chromium.org/p/chromium/builders/luci.chromium.ci/mac-rel/192 , https://ci.chromium.org/p/chromium/builders/luci.chromium.ci/linux-rel/1165

Original change's description:
> Propagate update on RendererPreferences to ServiceWorkerFetchContextImpl
> 
> Each FetchContexts needs to be notified it's update. This introduces a new Mojo
> interface (mojom::RendererPreferenceWatcher) to observe changes in the
> preferences.
> 
> Bug: 853085
> Change-Id: I3985c0ee363e073099d1a3ac85bf210f5bbce537
> Reviewed-on: https://chromium-review.googlesource.com/1164151
> Reviewed-by: Avi Drissman <avi@chromium.org>
> Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
> Commit-Queue: Makoto Shimazu <shimazu@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#582445}

TBR=avi@chromium.org,kinuko@chromium.org,shimazu@chromium.org

Change-Id: Idda3a12439b55f00269ba3a3c0ea129a44c2fcf6
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 853085
Reviewed-on: https://chromium-review.googlesource.com/1171716Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#582451}
parent 13044802
......@@ -130,7 +130,6 @@
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/chrome_select_file_policy.h"
#include "chrome/browser/ui/login/login_handler.h"
#include "chrome/browser/ui/prefs/pref_watcher.h"
#include "chrome/browser/ui/sync/sync_promo_ui.h"
#include "chrome/browser/ui/tab_contents/chrome_web_contents_view_delegate.h"
#include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h"
......@@ -4674,13 +4673,6 @@ bool ChromeContentBrowserClient::IsSafeRedirectTarget(
return true;
}
void ChromeContentBrowserClient::RegisterRendererPreferenceWatcherForWorkers(
content::BrowserContext* browser_context,
content::mojom::RendererPreferenceWatcherPtr watcher) {
Profile* profile = Profile::FromBrowserContext(browser_context);
PrefWatcher::Get(profile)->RegisterWatcherForWorkers(std::move(watcher));
}
// Static; handles rewriting Web UI URLs.
bool ChromeContentBrowserClient::HandleWebUI(
GURL* url,
......
......@@ -488,9 +488,6 @@ class ChromeContentBrowserClient : public content::ContentBrowserClient {
content::PictureInPictureWindowController* controller) override;
bool IsSafeRedirectTarget(const GURL& url,
content::ResourceContext* context) override;
void RegisterRendererPreferenceWatcherForWorkers(
content::BrowserContext* browser_context,
content::mojom::RendererPreferenceWatcherPtr watcher) override;
protected:
static bool HandleWebUI(GURL* url, content::BrowserContext* browser_context);
......
......@@ -161,13 +161,15 @@ IN_PROC_BROWSER_TEST_F(ChromeDoNotTrackTest, FetchFromServiceWorker) {
ExpectPageTextEq("1");
// Updating settings should be reflected immediately.
SetEnableDoNotTrack(false /* enabled */);
ASSERT_TRUE(ExecJs(GetWebContents(), script));
{
content::TitleWatcher watcher(GetWebContents(), title);
EXPECT_EQ(title, watcher.WaitAndGetTitle());
}
ExpectPageTextEq("None");
// Disabled due to crbug.com/853085.
//
// SetEnableDoNotTrack(false /* enabled */);
// ASSERT_TRUE(ExecJs(GetWebContents(), script));
// {
// content::TitleWatcher watcher(GetWebContents(), title);
// EXPECT_EQ(title, watcher.WaitAndGetTitle());
// }
// ExpectPageTextEq("None");
}
} // namespace
......@@ -668,8 +668,6 @@ jumbo_split_static_library("ui") {
"passwords/password_manager_presenter.h",
"passwords/password_ui_view.h",
"permission_bubble/permission_prompt.h",
"prefs/pref_watcher.cc",
"prefs/pref_watcher.h",
"prefs/prefs_tab_helper.cc",
"prefs/prefs_tab_helper.h",
"profile_chooser_constants.h",
......
// Copyright 2018 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 "chrome/browser/ui/prefs/pref_watcher.h"
#include "base/bind.h"
#include "build/build_config.h"
#include "chrome/browser/profiles/incognito_helpers.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/renderer_preferences_util.h"
#include "chrome/browser/ui/prefs/prefs_tab_helper.h"
#include "chrome/common/pref_names.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "content/public/common/renderer_preferences.h"
namespace {
// The list of prefs we want to observe.
const char* const kWebPrefsToObserve[] = {
#if BUILDFLAG(ENABLE_EXTENSIONS)
prefs::kAnimationPolicy,
#endif
prefs::kDataSaverEnabled,
prefs::kDefaultCharset,
prefs::kDisable3DAPIs,
prefs::kEnableHyperlinkAuditing,
prefs::kWebKitAllowRunningInsecureContent,
prefs::kWebKitDefaultFixedFontSize,
prefs::kWebKitDefaultFontSize,
prefs::kWebKitDomPasteEnabled,
#if defined(OS_ANDROID)
prefs::kWebKitFontScaleFactor,
prefs::kWebKitForceEnableZoom,
prefs::kWebKitPasswordEchoEnabled,
#endif
prefs::kWebKitJavascriptEnabled,
prefs::kWebKitLoadsImagesAutomatically,
prefs::kWebKitMinimumFontSize,
prefs::kWebKitMinimumLogicalFontSize,
prefs::kWebKitPluginsEnabled,
prefs::kWebkitTabsToLinks,
prefs::kWebKitTextAreasAreResizable,
prefs::kWebKitWebSecurityEnabled,
};
const int kWebPrefsToObserveLength = base::size(kWebPrefsToObserve);
} // namespace
// Watching all these settings per tab is slow when a user has a lot of tabs and
// and they use session restore. So watch them once per profile.
// http://crbug.com/452693
PrefWatcher::PrefWatcher(Profile* profile) : profile_(profile) {
pref_change_registrar_.Init(profile_->GetPrefs());
base::RepeatingClosure renderer_callback = base::BindRepeating(
&PrefWatcher::UpdateRendererPreferences, base::Unretained(this));
pref_change_registrar_.Add(prefs::kAcceptLanguages, renderer_callback);
pref_change_registrar_.Add(prefs::kEnableDoNotTrack, renderer_callback);
pref_change_registrar_.Add(prefs::kEnableReferrers, renderer_callback);
pref_change_registrar_.Add(prefs::kEnableEncryptedMedia, renderer_callback);
pref_change_registrar_.Add(prefs::kWebRTCMultipleRoutesEnabled,
renderer_callback);
pref_change_registrar_.Add(prefs::kWebRTCNonProxiedUdpEnabled,
renderer_callback);
pref_change_registrar_.Add(prefs::kWebRTCIPHandlingPolicy, renderer_callback);
pref_change_registrar_.Add(prefs::kWebRTCUDPPortRange, renderer_callback);
#if !defined(OS_MACOSX)
pref_change_registrar_.Add(prefs::kFullscreenAllowed, renderer_callback);
#endif
PrefChangeRegistrar::NamedChangeCallback webkit_callback =
base::BindRepeating(&PrefWatcher::OnWebPrefChanged,
base::Unretained(this));
for (int i = 0; i < kWebPrefsToObserveLength; ++i) {
const char* pref_name = kWebPrefsToObserve[i];
pref_change_registrar_.Add(pref_name, webkit_callback);
}
}
PrefWatcher::~PrefWatcher() = default;
void PrefWatcher::RegisterHelper(PrefsTabHelper* helper) {
tab_helpers_.insert(helper);
}
void PrefWatcher::UnregisterHelper(PrefsTabHelper* helper) {
tab_helpers_.erase(helper);
}
void PrefWatcher::RegisterWatcherForWorkers(
content::mojom::RendererPreferenceWatcherPtr worker_watcher) {
worker_watchers_.AddPtr(std::move(worker_watcher));
}
void PrefWatcher::Shutdown() {
pref_change_registrar_.RemoveAll();
}
void PrefWatcher::UpdateRendererPreferences() {
for (auto* helper : tab_helpers_)
helper->UpdateRendererPreferences();
content::RendererPreferences prefs;
renderer_preferences_util::UpdateFromSystemSettings(&prefs, profile_);
worker_watchers_.ForAllPtrs(
[&prefs](content::mojom::RendererPreferenceWatcher* watcher) {
watcher->NotifyUpdate(prefs);
});
}
void PrefWatcher::OnWebPrefChanged(const std::string& pref_name) {
for (auto* helper : tab_helpers_)
helper->OnWebPrefChanged(pref_name);
}
// static
PrefWatcher* PrefWatcherFactory::GetForProfile(Profile* profile) {
return static_cast<PrefWatcher*>(
GetInstance()->GetServiceForBrowserContext(profile, true));
}
// static
PrefWatcherFactory* PrefWatcherFactory::GetInstance() {
return base::Singleton<PrefWatcherFactory>::get();
}
PrefWatcherFactory::PrefWatcherFactory()
: BrowserContextKeyedServiceFactory(
"PrefWatcher",
BrowserContextDependencyManager::GetInstance()) {}
PrefWatcherFactory::~PrefWatcherFactory() = default;
KeyedService* PrefWatcherFactory::BuildServiceInstanceFor(
content::BrowserContext* browser_context) const {
return new PrefWatcher(Profile::FromBrowserContext(browser_context));
}
content::BrowserContext* PrefWatcherFactory::GetBrowserContextToUse(
content::BrowserContext* context) const {
return chrome::GetBrowserContextOwnInstanceInIncognito(context);
}
// static
PrefWatcher* PrefWatcher::Get(Profile* profile) {
return PrefWatcherFactory::GetForProfile(profile);
}
// Copyright 2018 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 CHROME_BROWSER_UI_PREFS_PREF_WATCHER_H_
#define CHROME_BROWSER_UI_PREFS_PREF_WATCHER_H_
#include "base/memory/singleton.h"
#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
#include "components/keyed_service/core/keyed_service.h"
#include "components/prefs/pref_change_registrar.h"
#include "content/public/common/renderer_preference_watcher.mojom.h"
#include "mojo/public/cpp/bindings/interface_ptr_set.h"
class Profile;
class PrefsTabHelper;
namespace content {
class RendererPreferenceWatcher;
} // namespace content
// Watches updates in WebKitPreferences and RendererPreferences, and notifies
// tab helpers and watchers for workers of those updates.
class PrefWatcher : public KeyedService {
public:
explicit PrefWatcher(Profile* profile);
~PrefWatcher() override;
static PrefWatcher* Get(Profile* profile);
void RegisterHelper(PrefsTabHelper* helper);
void UnregisterHelper(PrefsTabHelper* helper);
void RegisterWatcherForWorkers(
content::mojom::RendererPreferenceWatcherPtr worker_watcher);
private:
// KeyedService overrides:
void Shutdown() override;
void UpdateRendererPreferences();
void OnWebPrefChanged(const std::string& pref_name);
Profile* profile_;
PrefChangeRegistrar pref_change_registrar_;
// |tab_helpers_| observe changes in WebKitPreferences and
// RendererPreferences.
std::set<PrefsTabHelper*> tab_helpers_;
// |worker_watchers_| observe changes in RendererPreferences.
mojo::InterfacePtrSet<content::mojom::RendererPreferenceWatcher>
worker_watchers_;
};
class PrefWatcherFactory : public BrowserContextKeyedServiceFactory {
public:
static PrefWatcher* GetForProfile(Profile* profile);
static PrefWatcherFactory* GetInstance();
private:
friend struct base::DefaultSingletonTraits<PrefWatcherFactory>;
PrefWatcherFactory();
~PrefWatcherFactory() override;
// BrowserContextKeyedServiceFactory:
KeyedService* BuildServiceInstanceFor(
content::BrowserContext* browser_context) const override;
content::BrowserContext* GetBrowserContextToUse(
content::BrowserContext* context) const override;
};
#endif // CHROME_BROWSER_UI_PREFS_PREF_WATCHER_H_
......@@ -12,6 +12,7 @@
#include "base/command_line.h"
#include "base/macros.h"
#include "base/memory/singleton.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
......@@ -21,15 +22,19 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/font_pref_change_notifier_factory.h"
#include "chrome/browser/profiles/incognito_helpers.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/renderer_preferences_util.h"
#include "chrome/browser/ui/prefs/pref_watcher.h"
#include "chrome/common/pref_font_webkit_names.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/pref_names_util.h"
#include "chrome/grit/platform_locale_settings.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
#include "components/keyed_service/core/keyed_service.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/overlay_user_pref_store.h"
#include "components/prefs/pref_change_registrar.h"
#include "components/prefs/pref_service.h"
#include "components/proxy_config/proxy_config_pref_names.h"
#include "components/strings/grit/components_locale_settings.h"
......@@ -59,6 +64,36 @@ using content::WebPreferences;
namespace {
// The list of prefs we want to observe.
const char* const kWebPrefsToObserve[] = {
#if BUILDFLAG(ENABLE_EXTENSIONS)
prefs::kAnimationPolicy,
#endif
prefs::kDataSaverEnabled,
prefs::kDefaultCharset,
prefs::kDisable3DAPIs,
prefs::kEnableHyperlinkAuditing,
prefs::kWebKitAllowRunningInsecureContent,
prefs::kWebKitDefaultFixedFontSize,
prefs::kWebKitDefaultFontSize,
prefs::kWebKitDomPasteEnabled,
#if defined(OS_ANDROID)
prefs::kWebKitFontScaleFactor,
prefs::kWebKitForceEnableZoom,
prefs::kWebKitPasswordEchoEnabled,
#endif
prefs::kWebKitJavascriptEnabled,
prefs::kWebKitLoadsImagesAutomatically,
prefs::kWebKitMinimumFontSize,
prefs::kWebKitMinimumLogicalFontSize,
prefs::kWebKitPluginsEnabled,
prefs::kWebkitTabsToLinks,
prefs::kWebKitTextAreasAreResizable,
prefs::kWebKitWebSecurityEnabled,
};
const int kWebPrefsToObserveLength = arraysize(kWebPrefsToObserve);
#if !defined(OS_ANDROID)
// Registers a preference under the path |pref_name| for each script used for
// per-script font prefs.
......@@ -280,6 +315,109 @@ void RegisterLocalizedFontPref(user_prefs::PrefRegistrySyncable* registry,
} // namespace
// Watching all these settings per tab is slow when a user has a lot of tabs and
// and they use session restore. So watch them once per profile.
// http://crbug.com/452693
class PrefWatcher : public KeyedService {
public:
explicit PrefWatcher(Profile* profile) : profile_(profile) {
pref_change_registrar_.Init(profile_->GetPrefs());
base::Closure renderer_callback = base::Bind(
&PrefWatcher::UpdateRendererPreferences, base::Unretained(this));
pref_change_registrar_.Add(prefs::kAcceptLanguages, renderer_callback);
pref_change_registrar_.Add(prefs::kEnableDoNotTrack, renderer_callback);
pref_change_registrar_.Add(prefs::kEnableReferrers, renderer_callback);
pref_change_registrar_.Add(prefs::kEnableEncryptedMedia, renderer_callback);
pref_change_registrar_.Add(prefs::kWebRTCMultipleRoutesEnabled,
renderer_callback);
pref_change_registrar_.Add(prefs::kWebRTCNonProxiedUdpEnabled,
renderer_callback);
pref_change_registrar_.Add(prefs::kWebRTCIPHandlingPolicy,
renderer_callback);
pref_change_registrar_.Add(prefs::kWebRTCUDPPortRange, renderer_callback);
#if !defined(OS_MACOSX)
pref_change_registrar_.Add(prefs::kFullscreenAllowed, renderer_callback);
#endif
PrefChangeRegistrar::NamedChangeCallback webkit_callback = base::Bind(
&PrefWatcher::OnWebPrefChanged, base::Unretained(this));
for (int i = 0; i < kWebPrefsToObserveLength; ++i) {
const char* pref_name = kWebPrefsToObserve[i];
pref_change_registrar_.Add(pref_name, webkit_callback);
}
}
static PrefWatcher* Get(Profile* profile);
void RegisterHelper(PrefsTabHelper* helper) {
helpers_.insert(helper);
}
void UnregisterHelper(PrefsTabHelper* helper) {
helpers_.erase(helper);
}
private:
// KeyedService overrides:
void Shutdown() override {
pref_change_registrar_.RemoveAll();
}
void UpdateRendererPreferences() {
for (auto* helper : helpers_)
helper->UpdateRendererPreferences();
}
void OnWebPrefChanged(const std::string& pref_name) {
for (auto* helper : helpers_)
helper->OnWebPrefChanged(pref_name);
}
Profile* profile_;
PrefChangeRegistrar pref_change_registrar_;
std::set<PrefsTabHelper*> helpers_;
};
class PrefWatcherFactory : public BrowserContextKeyedServiceFactory {
public:
static PrefWatcher* GetForProfile(Profile* profile) {
return static_cast<PrefWatcher*>(
GetInstance()->GetServiceForBrowserContext(profile, true));
}
static PrefWatcherFactory* GetInstance() {
return base::Singleton<PrefWatcherFactory>::get();
}
private:
friend struct base::DefaultSingletonTraits<PrefWatcherFactory>;
PrefWatcherFactory() : BrowserContextKeyedServiceFactory(
"PrefWatcher",
BrowserContextDependencyManager::GetInstance()) {
}
~PrefWatcherFactory() override {}
// BrowserContextKeyedServiceFactory:
KeyedService* BuildServiceInstanceFor(
content::BrowserContext* browser_context) const override {
return new PrefWatcher(Profile::FromBrowserContext(browser_context));
}
content::BrowserContext* GetBrowserContextToUse(
content::BrowserContext* context) const override {
return chrome::GetBrowserContextOwnInstanceInIncognito(context);
}
};
// static
PrefWatcher* PrefWatcher::Get(Profile* profile) {
return PrefWatcherFactory::GetForProfile(profile);
}
PrefsTabHelper::PrefsTabHelper(WebContents* contents)
: web_contents_(contents),
profile_(Profile::FromBrowserContext(web_contents_->GetBrowserContext())),
......
......@@ -29,7 +29,6 @@
#include "content/public/common/child_process_host.h"
#include "content/public/common/content_client.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/renderer_preference_watcher.mojom.h"
#include "ipc/ipc_message.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "third_party/blink/public/common/features.h"
......@@ -219,12 +218,6 @@ void SetupOnUIThread(base::WeakPtr<ServiceWorkerProcessManager> process_manager,
GetContentClient()->browser()->UpdateRendererPreferencesForWorker(
process_manager->browser_context(), &params->renderer_preferences);
// Create a RendererPreferenceWatcher to observe updates in the preferences.
mojom::RendererPreferenceWatcherPtr watcher_ptr;
params->preference_watcher_request = mojo::MakeRequest(&watcher_ptr);
GetContentClient()->browser()->RegisterRendererPreferenceWatcherForWorkers(
process_manager->browser_context(), std::move(watcher_ptr));
// Continue to OnSetupCompleted on the IO thread.
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
......
......@@ -18,6 +18,9 @@ struct FrameOwnerProperties;
[Native]
struct FrameReplicationState;
[Native]
struct RendererPreferences;
[Native]
struct VisualProperties;
......
......@@ -18,6 +18,7 @@ public_headers = [
"//content/common/input/synthetic_smooth_drag_gesture_params.h",
"//content/common/input/synthetic_smooth_scroll_gesture_params.h",
"//content/common/input/synthetic_tap_gesture_params.h",
"//content/public/common/renderer_preferences.h",
"//content/public/common/web_preferences.h",
"//net/base/network_change_notifier.h",
"//third_party/blink/public/platform/web_gesture_device.h",
......@@ -77,6 +78,7 @@ type_mappings = [
"content.mojom.NetworkConnectionType=net::NetworkChangeNotifier::ConnectionType",
"content.mojom.DidOverscrollParams=ui::DidOverscrollParams",
"content.mojom.PointerType=blink::WebPointerProperties::PointerType",
"content.mojom.RendererPreferences=content::RendererPreferences",
"content.mojom.VisualProperties=content::VisualProperties",
"content.mojom.ScrollUnits=blink::WebGestureEvent::ScrollUnits",
"content.mojom.SyntheticSmoothDrag=content::SyntheticSmoothDragGestureParams",
......
......@@ -7,7 +7,6 @@ module content.mojom;
import "content/common/input/input_handler.mojom";
import "content/common/native_types.mojom";
import "content/common/widget.mojom";
import "content/public/common/renderer_preferences.mojom";
import "mojo/public/mojom/base/thread_priority.mojom";
import "mojo/public/mojom/base/time.mojom";
import "url/mojom/origin.mojom";
......
......@@ -6,7 +6,6 @@ module content.mojom;
import "content/common/native_types.mojom";
import "content/common/service_worker/embedded_worker.mojom";
import "content/public/common/renderer_preferences.mojom";
import "ipc/constants.mojom";
import "mojo/public/mojom/base/time.mojom";
import "mojo/public/mojom/base/unguessable_token.mojom";
......
......@@ -8,8 +8,6 @@ import "content/common/native_types.mojom";
import "content/common/service_worker/controller_service_worker.mojom";
import "content/common/service_worker/service_worker.mojom";
import "content/common/service_worker/service_worker_provider.mojom";
import "content/public/common/renderer_preference_watcher.mojom";
import "content/public/common/renderer_preferences.mojom";
import "mojo/public/mojom/base/string16.mojom";
import "mojo/public/mojom/base/time.mojom";
import "mojo/public/mojom/base/unguessable_token.mojom";
......@@ -66,8 +64,6 @@ struct EmbeddedWorkerStartParams {
ServiceWorkerProviderInfoForStartWorker provider_info;
// Interface for the renderer to query the content settings in the browser.
blink.mojom.WorkerContentSettingsProxy content_settings_proxy;
// Interface for keeping track of the renderer preferences.
RendererPreferenceWatcher& preference_watcher_request;
};
// Holds timing information about the start worker sequence for UMA.
......
......@@ -4,12 +4,12 @@
module content.mojom;
import "content/common/native_types.mojom";
import "content/common/service_worker/service_worker_provider.mojom";
import "content/common/shared_worker/shared_worker.mojom";
import "content/common/shared_worker/shared_worker_host.mojom";
import "content/common/shared_worker/shared_worker_info.mojom";
import "content/common/url_loader_factory_bundle.mojom";
import "content/public/common/renderer_preferences.mojom";
import "mojo/public/mojom/base/unguessable_token.mojom";
import "services/network/public/mojom/url_loader_factory.mojom";
import "services/service_manager/public/mojom/interface_provider.mojom";
......
......@@ -97,6 +97,10 @@ IPC_ENUM_TRAITS_MAX_VALUE(content::NavigationGesture,
IPC_ENUM_TRAITS_MIN_MAX_VALUE(content::PageZoom,
content::PageZoom::PAGE_ZOOM_OUT,
content::PageZoom::PAGE_ZOOM_IN)
IPC_ENUM_TRAITS_MAX_VALUE(gfx::FontRenderParams::Hinting,
gfx::FontRenderParams::HINTING_MAX)
IPC_ENUM_TRAITS_MAX_VALUE(gfx::FontRenderParams::SubpixelRendering,
gfx::FontRenderParams::SUBPIXEL_RENDERING_MAX)
IPC_ENUM_TRAITS_MAX_VALUE(content::ScreenOrientationValues,
content::SCREEN_ORIENTATION_VALUES_LAST)
IPC_ENUM_TRAITS_MAX_VALUE(content::ThreeDAPIType,
......@@ -184,6 +188,57 @@ IPC_STRUCT_TRAITS_BEGIN(content::DateTimeSuggestion)
IPC_STRUCT_TRAITS_MEMBER(label)
IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(content::RendererPreferences)
IPC_STRUCT_TRAITS_MEMBER(can_accept_load_drops)
IPC_STRUCT_TRAITS_MEMBER(should_antialias_text)
IPC_STRUCT_TRAITS_MEMBER(hinting)
IPC_STRUCT_TRAITS_MEMBER(use_autohinter)
IPC_STRUCT_TRAITS_MEMBER(use_bitmaps)
IPC_STRUCT_TRAITS_MEMBER(subpixel_rendering)
IPC_STRUCT_TRAITS_MEMBER(use_subpixel_positioning)
IPC_STRUCT_TRAITS_MEMBER(focus_ring_color)
IPC_STRUCT_TRAITS_MEMBER(thumb_active_color)
IPC_STRUCT_TRAITS_MEMBER(thumb_inactive_color)
IPC_STRUCT_TRAITS_MEMBER(track_color)
IPC_STRUCT_TRAITS_MEMBER(active_selection_bg_color)
IPC_STRUCT_TRAITS_MEMBER(active_selection_fg_color)
IPC_STRUCT_TRAITS_MEMBER(inactive_selection_bg_color)
IPC_STRUCT_TRAITS_MEMBER(inactive_selection_fg_color)
IPC_STRUCT_TRAITS_MEMBER(browser_handles_all_top_level_requests)
IPC_STRUCT_TRAITS_MEMBER(caret_blink_interval)
IPC_STRUCT_TRAITS_MEMBER(use_custom_colors)
IPC_STRUCT_TRAITS_MEMBER(enable_referrers)
IPC_STRUCT_TRAITS_MEMBER(enable_do_not_track)
IPC_STRUCT_TRAITS_MEMBER(enable_encrypted_media)
IPC_STRUCT_TRAITS_MEMBER(webrtc_ip_handling_policy)
IPC_STRUCT_TRAITS_MEMBER(webrtc_udp_min_port)
IPC_STRUCT_TRAITS_MEMBER(webrtc_udp_max_port)
IPC_STRUCT_TRAITS_MEMBER(user_agent_override)
IPC_STRUCT_TRAITS_MEMBER(accept_languages)
IPC_STRUCT_TRAITS_MEMBER(disable_client_blocked_error_page)
IPC_STRUCT_TRAITS_MEMBER(plugin_fullscreen_allowed)
IPC_STRUCT_TRAITS_MEMBER(network_contry_iso)
#if defined(OS_LINUX)
IPC_STRUCT_TRAITS_MEMBER(system_font_family_name)
#endif
#if defined(OS_WIN)
IPC_STRUCT_TRAITS_MEMBER(caption_font_family_name)
IPC_STRUCT_TRAITS_MEMBER(caption_font_height)
IPC_STRUCT_TRAITS_MEMBER(small_caption_font_family_name)
IPC_STRUCT_TRAITS_MEMBER(small_caption_font_height)
IPC_STRUCT_TRAITS_MEMBER(menu_font_family_name)
IPC_STRUCT_TRAITS_MEMBER(menu_font_height)
IPC_STRUCT_TRAITS_MEMBER(status_font_family_name)
IPC_STRUCT_TRAITS_MEMBER(status_font_height)
IPC_STRUCT_TRAITS_MEMBER(message_font_family_name)
IPC_STRUCT_TRAITS_MEMBER(message_font_height)
IPC_STRUCT_TRAITS_MEMBER(vertical_scroll_bar_width_in_dips)
IPC_STRUCT_TRAITS_MEMBER(horizontal_scroll_bar_height_in_dips)
IPC_STRUCT_TRAITS_MEMBER(arrow_bitmap_height_vertical_scroll_bar_in_dips)
IPC_STRUCT_TRAITS_MEMBER(arrow_bitmap_width_horizontal_scroll_bar_in_dips)
#endif
IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(content::TextInputState)
IPC_STRUCT_TRAITS_MEMBER(type)
IPC_STRUCT_TRAITS_MEMBER(mode)
......
......@@ -794,8 +794,4 @@ bool ContentBrowserClient::IsSafeRedirectTarget(const GURL& url,
return true;
}
void ContentBrowserClient::RegisterRendererPreferenceWatcherForWorkers(
BrowserContext* browser_context,
mojom::RendererPreferenceWatcherPtr watcher) {}
} // namespace content
......@@ -27,7 +27,6 @@
#include "content/public/browser/resource_request_info.h"
#include "content/public/common/content_client.h"
#include "content/public/common/media_stream_request.h"
#include "content/public/common/renderer_preference_watcher.mojom.h"
#include "content/public/common/resource_type.h"
#include "content/public/common/socket_permission_request.h"
#include "content/public/common/window_container_type.mojom.h"
......@@ -1307,12 +1306,6 @@ class CONTENT_EXPORT ContentBrowserClient {
// Returns true if it is safe to redirect to |url|, otherwise returns false.
// This is called on the IO thread.
virtual bool IsSafeRedirectTarget(const GURL& url, ResourceContext* context);
// Registers the watcher to observe updates in RendererPreferences. The
// watchers are for shared workers and service workers.
virtual void RegisterRendererPreferenceWatcherForWorkers(
BrowserContext* browser_context,
mojom::RendererPreferenceWatcherPtr watcher);
};
} // namespace content
......
......@@ -353,8 +353,6 @@ mojom("interfaces") {
"fullscreen_video_element.mojom",
"load_timing_info.mojom",
"push_messaging_status.mojom",
"renderer_preference_watcher.mojom",
"renderer_preferences.mojom",
"resource_load_info.mojom",
"resource_usage_reporter.mojom",
"transferrable_url_loader.mojom",
......
......@@ -12,7 +12,6 @@
#include "cc/input/touch_action.h"
#include "content/public/common/console_message_level.h"
#include "content/public/common/referrer.h"
#include "content/public/common/renderer_preferences.h"
#include "content/public/common/web_preferences.h"
#include "content/public/common/webplugininfo_param_traits.h"
#include "ipc/ipc_message_macros.h"
......@@ -288,60 +287,4 @@ IPC_STRUCT_TRAITS_BEGIN(ui::AXEvent)
IPC_STRUCT_TRAITS_MEMBER(action_request_id)
IPC_STRUCT_TRAITS_END()
IPC_ENUM_TRAITS_MAX_VALUE(gfx::FontRenderParams::Hinting,
gfx::FontRenderParams::HINTING_MAX)
IPC_ENUM_TRAITS_MAX_VALUE(gfx::FontRenderParams::SubpixelRendering,
gfx::FontRenderParams::SUBPIXEL_RENDERING_MAX)
IPC_STRUCT_TRAITS_BEGIN(content::RendererPreferences)
IPC_STRUCT_TRAITS_MEMBER(can_accept_load_drops)
IPC_STRUCT_TRAITS_MEMBER(should_antialias_text)
IPC_STRUCT_TRAITS_MEMBER(hinting)
IPC_STRUCT_TRAITS_MEMBER(use_autohinter)
IPC_STRUCT_TRAITS_MEMBER(use_bitmaps)
IPC_STRUCT_TRAITS_MEMBER(subpixel_rendering)
IPC_STRUCT_TRAITS_MEMBER(use_subpixel_positioning)
IPC_STRUCT_TRAITS_MEMBER(focus_ring_color)
IPC_STRUCT_TRAITS_MEMBER(thumb_active_color)
IPC_STRUCT_TRAITS_MEMBER(thumb_inactive_color)
IPC_STRUCT_TRAITS_MEMBER(track_color)
IPC_STRUCT_TRAITS_MEMBER(active_selection_bg_color)
IPC_STRUCT_TRAITS_MEMBER(active_selection_fg_color)
IPC_STRUCT_TRAITS_MEMBER(inactive_selection_bg_color)
IPC_STRUCT_TRAITS_MEMBER(inactive_selection_fg_color)
IPC_STRUCT_TRAITS_MEMBER(browser_handles_all_top_level_requests)
IPC_STRUCT_TRAITS_MEMBER(caret_blink_interval)
IPC_STRUCT_TRAITS_MEMBER(use_custom_colors)
IPC_STRUCT_TRAITS_MEMBER(enable_referrers)
IPC_STRUCT_TRAITS_MEMBER(enable_do_not_track)
IPC_STRUCT_TRAITS_MEMBER(enable_encrypted_media)
IPC_STRUCT_TRAITS_MEMBER(webrtc_ip_handling_policy)
IPC_STRUCT_TRAITS_MEMBER(webrtc_udp_min_port)
IPC_STRUCT_TRAITS_MEMBER(webrtc_udp_max_port)
IPC_STRUCT_TRAITS_MEMBER(user_agent_override)
IPC_STRUCT_TRAITS_MEMBER(accept_languages)
IPC_STRUCT_TRAITS_MEMBER(disable_client_blocked_error_page)
IPC_STRUCT_TRAITS_MEMBER(plugin_fullscreen_allowed)
IPC_STRUCT_TRAITS_MEMBER(network_contry_iso)
#if defined(OS_LINUX)
IPC_STRUCT_TRAITS_MEMBER(system_font_family_name)
#endif
#if defined(OS_WIN)
IPC_STRUCT_TRAITS_MEMBER(caption_font_family_name)
IPC_STRUCT_TRAITS_MEMBER(caption_font_height)
IPC_STRUCT_TRAITS_MEMBER(small_caption_font_family_name)
IPC_STRUCT_TRAITS_MEMBER(small_caption_font_height)
IPC_STRUCT_TRAITS_MEMBER(menu_font_family_name)
IPC_STRUCT_TRAITS_MEMBER(menu_font_height)
IPC_STRUCT_TRAITS_MEMBER(status_font_family_name)
IPC_STRUCT_TRAITS_MEMBER(status_font_height)
IPC_STRUCT_TRAITS_MEMBER(message_font_family_name)
IPC_STRUCT_TRAITS_MEMBER(message_font_height)
IPC_STRUCT_TRAITS_MEMBER(vertical_scroll_bar_width_in_dips)
IPC_STRUCT_TRAITS_MEMBER(horizontal_scroll_bar_height_in_dips)
IPC_STRUCT_TRAITS_MEMBER(arrow_bitmap_height_vertical_scroll_bar_in_dips)
IPC_STRUCT_TRAITS_MEMBER(arrow_bitmap_width_horizontal_scroll_bar_in_dips)
#endif
IPC_STRUCT_TRAITS_END()
#endif // CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_MACROS_H_
// Copyright 2018 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;
import "content/public/common/renderer_preferences.mojom";
// Implementation of this interface usually lives in the renderer process and
// the browser process calls NotifyUpdate() whenever preferences are updated.
interface RendererPreferenceWatcher {
// Send the new preference to the receiver.
NotifyUpdate(RendererPreferences new_prefs);
};
\ No newline at end of file
// Copyright 2018 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 RendererPreferences;
# Copyright 2018 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.
mojom = "//content/public/common/renderer_preferences.mojom"
public_headers = [ "//content/public/common/renderer_preferences.h" ]
traits_headers = [ "//content/public/common/common_param_traits_macros.h" ]
type_mappings =
[ "content.mojom.RendererPreferences=content::RendererPreferences" ]
......@@ -5,7 +5,6 @@
typemaps = [
"//content/public/common/load_timing_info.typemap",
"//content/public/common/referrer.typemap",
"//content/public/common/renderer_preferences.typemap",
"//content/public/common/resource_type.typemap",
"//content/public/common/webplugininfo.typemap",
]
......@@ -76,7 +76,7 @@ void EmbeddedWorkerInstanceClientImpl::StartWorker(
std::move(params->service_worker_request),
std::move(params->controller_request), std::move(params->instance_host),
std::move(params->provider_info), std::move(temporal_self_),
std::move(start_timing), std::move(params->preference_watcher_request),
std::move(start_timing),
RenderThreadImpl::current()
->GetWebMainThreadScheduler()
->DefaultTaskRunner());
......
......@@ -709,7 +709,6 @@ ServiceWorkerContextClient::ServiceWorkerContextClient(
mojom::ServiceWorkerProviderInfoForStartWorkerPtr provider_info,
std::unique_ptr<EmbeddedWorkerInstanceClientImpl> embedded_worker_client,
mojom::EmbeddedWorkerStartTimingPtr start_timing,
mojom::RendererPreferenceWatcherRequest preference_watcher_request,
scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner)
: embedded_worker_id_(embedded_worker_id),
service_worker_version_id_(service_worker_version_id),
......@@ -717,7 +716,6 @@ ServiceWorkerContextClient::ServiceWorkerContextClient(
script_url_(script_url),
is_starting_installed_worker_(is_starting_installed_worker),
renderer_preferences_(std::move(renderer_preferences)),
preference_watcher_request_(std::move(preference_watcher_request)),
main_thread_task_runner_(std::move(main_thread_task_runner)),
proxy_(nullptr),
pending_service_worker_request_(std::move(service_worker_request)),
......@@ -1372,7 +1370,6 @@ std::unique_ptr<blink::WebWorkerFetchContext>
ServiceWorkerContextClient::CreateServiceWorkerFetchContext(
blink::WebServiceWorkerNetworkProvider* provider) {
DCHECK(main_thread_task_runner_->RunsTasksInCurrentSequence());
DCHECK(preference_watcher_request_.is_pending());
scoped_refptr<ChildURLLoaderFactoryBundle> url_loader_factory_bundle =
RenderThreadImpl::current()
......@@ -1399,8 +1396,7 @@ ServiceWorkerContextClient::CreateServiceWorkerFetchContext(
URLLoaderThrottleProviderType::kWorker),
GetContentClient()
->renderer()
->CreateWebSocketHandshakeThrottleProvider(),
std::move(preference_watcher_request_));
->CreateWebSocketHandshakeThrottleProvider());
}
std::unique_ptr<blink::WebServiceWorkerProvider>
......
......@@ -98,7 +98,6 @@ class CONTENT_EXPORT ServiceWorkerContextClient
mojom::ServiceWorkerProviderInfoForStartWorkerPtr provider_info,
std::unique_ptr<EmbeddedWorkerInstanceClientImpl> embedded_worker_client,
mojom::EmbeddedWorkerStartTimingPtr start_timing,
mojom::RendererPreferenceWatcherRequest preference_watcher_request,
scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner);
~ServiceWorkerContextClient() override;
......@@ -416,8 +415,6 @@ class CONTENT_EXPORT ServiceWorkerContextClient
const bool is_starting_installed_worker_;
RendererPreferences renderer_preferences_;
// Passed on creation of ServiceWorkerFetchContext.
mojom::RendererPreferenceWatcherRequest preference_watcher_request_;
scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
scoped_refptr<base::TaskRunner> worker_task_runner_;
......
......@@ -281,7 +281,6 @@ class ServiceWorkerContextClientTest : public testing::Test {
embedded_worker_host_ptr.PassInterface(), CreateProviderInfo(),
nullptr /* embedded_worker_client */,
mojom::EmbeddedWorkerStartTiming::New(),
nullptr /* preference_watcher_request */,
blink::scheduler::GetSingleThreadTaskRunnerForTesting());
context_client->WorkerContextStarted(proxy);
......
......@@ -28,8 +28,7 @@ ServiceWorkerFetchContextImpl::ServiceWorkerFetchContextImpl(
int service_worker_provider_id,
std::unique_ptr<URLLoaderThrottleProvider> throttle_provider,
std::unique_ptr<WebSocketHandshakeThrottleProvider>
websocket_handshake_throttle_provider,
mojom::RendererPreferenceWatcherRequest preference_watcher_request)
websocket_handshake_throttle_provider)
: renderer_preferences_(std::move(renderer_preferences)),
worker_script_url_(worker_script_url),
url_loader_factory_info_(std::move(url_loader_factory_info)),
......@@ -37,9 +36,7 @@ ServiceWorkerFetchContextImpl::ServiceWorkerFetchContextImpl(
service_worker_provider_id_(service_worker_provider_id),
throttle_provider_(std::move(throttle_provider)),
websocket_handshake_throttle_provider_(
std::move(websocket_handshake_throttle_provider)),
preference_watcher_binding_(this),
preference_watcher_request_(std::move(preference_watcher_request)) {}
std::move(websocket_handshake_throttle_provider)) {}
ServiceWorkerFetchContextImpl::~ServiceWorkerFetchContextImpl() {}
......@@ -53,7 +50,6 @@ void ServiceWorkerFetchContextImpl::InitializeOnWorkerThread() {
resource_dispatcher_ = std::make_unique<ResourceDispatcher>();
resource_dispatcher_->set_terminate_sync_load_event(
terminate_sync_load_event_);
preference_watcher_binding_.Bind(std::move(preference_watcher_request_));
url_loader_factory_ = network::SharedURLLoaderFactory::Create(
std::move(url_loader_factory_info_));
......@@ -132,9 +128,4 @@ ServiceWorkerFetchContextImpl::CreateWebSocketHandshakeThrottle() {
MSG_ROUTING_NONE);
}
void ServiceWorkerFetchContextImpl::NotifyUpdate(
const RendererPreferences& new_prefs) {
renderer_preferences_ = new_prefs;
}
} // namespace content
......@@ -5,9 +5,7 @@
#ifndef CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_FETCH_CONTEXT_IMPL_H_
#define CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_FETCH_CONTEXT_IMPL_H_
#include "content/public/common/renderer_preference_watcher.mojom.h"
#include "content/public/common/renderer_preferences.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "third_party/blink/public/platform/web_worker_fetch_context.h"
#include "url/gurl.h"
......@@ -17,8 +15,7 @@ class ResourceDispatcher;
class URLLoaderThrottleProvider;
class WebSocketHandshakeThrottleProvider;
class ServiceWorkerFetchContextImpl : public blink::WebWorkerFetchContext,
public mojom::RendererPreferenceWatcher {
class ServiceWorkerFetchContextImpl : public blink::WebWorkerFetchContext {
public:
// |url_loader_factory_info| is used for regular loads from the service worker
// (i.e., Fetch API). It typically goes to network, but it might internally
......@@ -37,8 +34,7 @@ class ServiceWorkerFetchContextImpl : public blink::WebWorkerFetchContext,
int service_worker_provider_id,
std::unique_ptr<URLLoaderThrottleProvider> throttle_provider,
std::unique_ptr<WebSocketHandshakeThrottleProvider>
websocket_handshake_throttle_provider,
mojom::RendererPreferenceWatcherRequest preference_watcher_request);
websocket_handshake_throttle_provider);
~ServiceWorkerFetchContextImpl() override;
// blink::WebWorkerFetchContext implementation:
......@@ -57,9 +53,6 @@ class ServiceWorkerFetchContextImpl : public blink::WebWorkerFetchContext,
CreateWebSocketHandshakeThrottle() override;
private:
// Implements mojom::RendererPreferenceWatcher.
void NotifyUpdate(const RendererPreferences& new_prefs) override;
RendererPreferences renderer_preferences_;
const GURL worker_script_url_;
// Consumed on the worker thread to create |url_loader_factory_|.
......@@ -81,12 +74,6 @@ class ServiceWorkerFetchContextImpl : public blink::WebWorkerFetchContext,
std::unique_ptr<WebSocketHandshakeThrottleProvider>
websocket_handshake_throttle_provider_;
mojo::Binding<mojom::RendererPreferenceWatcher> preference_watcher_binding_;
// Kept while staring up the worker thread. Valid until
// InitializeOnWorkerThread().
mojom::RendererPreferenceWatcherRequest preference_watcher_request_;
// This is owned by ThreadedMessagingProxyBase on the main thread.
base::WaitableEvent* terminate_sync_load_event_ = nullptr;
};
......
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