Commit 60e4cc66 authored by Kenichi Ishibashi's avatar Kenichi Ishibashi Committed by Commit Bot

worker: Remove WorkerContentSettingsClient

Before this CL WebContentSettingsClient was indirectly passed to
WorkerOrWorkletGlobalScope via WorkerContentSettingsClient. This was
an unnecessary abstraction. We can just pass WebContentSettingsClient
as a part of GlobalScopeCreationParams and keep it in
WorkerOrWorkletGlobalScope. This eliminates creating a GarbageCollected
object.

This CL doesn't have behavioral changes.

Bug: 988335
Change-Id: If740aebdb33aa0bffd1ed8c9659d3a0c92c8e20a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1722464Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Reviewed-by: default avatarHiroki Nakagawa <nhiroki@chromium.org>
Commit-Queue: Kenichi Ishibashi <bashi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#681737}
parent 64ec468d
...@@ -59,7 +59,6 @@ ...@@ -59,7 +59,6 @@
#include "third_party/blink/renderer/core/workers/shared_worker_content_settings_proxy.h" #include "third_party/blink/renderer/core/workers/shared_worker_content_settings_proxy.h"
#include "third_party/blink/renderer/core/workers/shared_worker_global_scope.h" #include "third_party/blink/renderer/core/workers/shared_worker_global_scope.h"
#include "third_party/blink/renderer/core/workers/shared_worker_thread.h" #include "third_party/blink/renderer/core/workers/shared_worker_thread.h"
#include "third_party/blink/renderer/core/workers/worker_content_settings_client.h"
#include "third_party/blink/renderer/core/workers/worker_global_scope.h" #include "third_party/blink/renderer/core/workers/worker_global_scope.h"
#include "third_party/blink/renderer/platform/heap/handle.h" #include "third_party/blink/renderer/platform/heap/handle.h"
#include "third_party/blink/renderer/platform/heap/persistent.h" #include "third_party/blink/renderer/platform/heap/persistent.h"
...@@ -295,6 +294,8 @@ void WebSharedWorkerImpl::ContinueStartWorkerContext() { ...@@ -295,6 +294,8 @@ void WebSharedWorkerImpl::ContinueStartWorkerContext() {
Vector<CSPHeaderAndType>(), network::mojom::ReferrerPolicy::kDefault, Vector<CSPHeaderAndType>(), network::mojom::ReferrerPolicy::kDefault,
outside_settings_object->GetSecurityOrigin(), document->IsSecureContext(), outside_settings_object->GetSecurityOrigin(), document->IsSecureContext(),
outside_settings_object->GetHttpsState(), CreateWorkerClients(), outside_settings_object->GetHttpsState(), CreateWorkerClients(),
std::make_unique<SharedWorkerContentSettingsProxy>(
std::move(content_settings_info_)),
base::nullopt /* response_address_space */, base::nullopt /* response_address_space */,
nullptr /* origin_trial_tokens */, devtools_worker_token_, nullptr /* origin_trial_tokens */, devtools_worker_token_,
std::move(worker_settings), kV8CacheOptionsDefault, std::move(worker_settings), kV8CacheOptionsDefault,
...@@ -341,9 +342,6 @@ WorkerClients* WebSharedWorkerImpl::CreateWorkerClients() { ...@@ -341,9 +342,6 @@ WorkerClients* WebSharedWorkerImpl::CreateWorkerClients() {
*worker_clients); *worker_clients);
CoreInitializer::GetInstance().ProvideIndexedDBClientToWorker( CoreInitializer::GetInstance().ProvideIndexedDBClientToWorker(
*worker_clients); *worker_clients);
ProvideContentSettingsClientToWorker(
worker_clients, std::make_unique<SharedWorkerContentSettingsProxy>(
std::move(content_settings_info_)));
return worker_clients; return worker_clients;
} }
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include "third_party/blink/renderer/core/origin_trials/origin_trial_context.h" #include "third_party/blink/renderer/core/origin_trials/origin_trial_context.h"
#include "third_party/blink/renderer/core/script/script.h" #include "third_party/blink/renderer/core/script/script.h"
#include "third_party/blink/renderer/core/workers/global_scope_creation_params.h" #include "third_party/blink/renderer/core/workers/global_scope_creation_params.h"
#include "third_party/blink/renderer/core/workers/worker_content_settings_client.h"
#include "third_party/blink/renderer/core/workers/worklet_module_responses_map.h" #include "third_party/blink/renderer/core/workers/worklet_module_responses_map.h"
#include "third_party/blink/renderer/platform/weborigin/kurl.h" #include "third_party/blink/renderer/platform/weborigin/kurl.h"
#include "third_party/blink/renderer/platform/wtf/wtf.h" #include "third_party/blink/renderer/platform/wtf/wtf.h"
...@@ -39,9 +38,8 @@ LayoutWorkletGlobalScopeProxy::LayoutWorkletGlobalScopeProxy( ...@@ -39,9 +38,8 @@ LayoutWorkletGlobalScopeProxy::LayoutWorkletGlobalScopeProxy(
String global_scope_name = String global_scope_name =
StringView("LayoutWorklet #") + String::Number(global_scope_number); StringView("LayoutWorklet #") + String::Number(global_scope_number);
// TODO(bashi): Pass nullptr instead of an empty WorkerClients?
auto* worker_clients = MakeGarbageCollected<WorkerClients>(); auto* worker_clients = MakeGarbageCollected<WorkerClients>();
ProvideContentSettingsClientToWorker(
worker_clients, frame->Client()->CreateWorkerContentSettingsClient());
auto creation_params = std::make_unique<GlobalScopeCreationParams>( auto creation_params = std::make_unique<GlobalScopeCreationParams>(
document->Url(), mojom::ScriptType::kModule, document->Url(), mojom::ScriptType::kModule,
...@@ -50,9 +48,13 @@ LayoutWorkletGlobalScopeProxy::LayoutWorkletGlobalScopeProxy( ...@@ -50,9 +48,13 @@ LayoutWorkletGlobalScopeProxy::LayoutWorkletGlobalScopeProxy(
document->GetContentSecurityPolicy()->Headers(), document->GetContentSecurityPolicy()->Headers(),
document->GetReferrerPolicy(), document->GetSecurityOrigin(), document->GetReferrerPolicy(), document->GetSecurityOrigin(),
document->IsSecureContext(), document->GetHttpsState(), worker_clients, document->IsSecureContext(), document->GetHttpsState(), worker_clients,
frame->Client()->CreateWorkerContentSettingsClient(),
document->AddressSpace(), OriginTrialContext::GetTokens(document).get(), document->AddressSpace(), OriginTrialContext::GetTokens(document).get(),
base::UnguessableToken::Create(), nullptr /* worker_settings */, base::UnguessableToken::Create(), nullptr /* worker_settings */,
kV8CacheOptionsDefault, module_responses_map); kV8CacheOptionsDefault, module_responses_map,
service_manager::mojom::blink::InterfaceProviderPtrInfo(),
BeginFrameProviderParams(), nullptr /* parent_feature_policy */,
base::UnguessableToken() /* agent_cluster_id */);
global_scope_ = LayoutWorkletGlobalScope::Create( global_scope_ = LayoutWorkletGlobalScope::Create(
frame, std::move(creation_params), *reporting_proxy_, frame, std::move(creation_params), *reporting_proxy_,
pending_layout_registry); pending_layout_registry);
......
...@@ -47,7 +47,6 @@ ...@@ -47,7 +47,6 @@
#include "third_party/blink/renderer/core/loader/document_loader.h" #include "third_party/blink/renderer/core/loader/document_loader.h"
#include "third_party/blink/renderer/core/loader/frame_fetch_context.h" #include "third_party/blink/renderer/core/loader/frame_fetch_context.h"
#include "third_party/blink/renderer/core/loader/worker_fetch_context.h" #include "third_party/blink/renderer/core/loader/worker_fetch_context.h"
#include "third_party/blink/renderer/core/workers/worker_content_settings_client.h"
#include "third_party/blink/renderer/core/workers/worker_global_scope.h" #include "third_party/blink/renderer/core/workers/worker_global_scope.h"
#include "third_party/blink/renderer/core/workers/worker_or_worklet_global_scope.h" #include "third_party/blink/renderer/core/workers/worker_or_worklet_global_scope.h"
#include "third_party/blink/renderer/core/workers/worker_settings.h" #include "third_party/blink/renderer/core/workers/worker_settings.h"
...@@ -521,10 +520,9 @@ bool MixedContentChecker::ShouldBlockFetchOnWorker( ...@@ -521,10 +520,9 @@ bool MixedContentChecker::ShouldBlockFetchOnWorker(
!strict_mode && (!settings->GetStrictlyBlockBlockableMixedContent() || !strict_mode && (!settings->GetStrictlyBlockBlockableMixedContent() ||
settings->GetAllowRunningOfInsecureContent()); settings->GetAllowRunningOfInsecureContent());
allowed = should_ask_embedder && allowed = should_ask_embedder &&
worker_fetch_context.GetWorkerContentSettingsClient() worker_fetch_context.AllowRunningInsecureContent(
->AllowRunningInsecureContent( settings->GetAllowRunningOfInsecureContent(),
settings->GetAllowRunningOfInsecureContent(), fetch_client_settings_object.GetSecurityOrigin(), url);
fetch_client_settings_object.GetSecurityOrigin(), url);
if (allowed) { if (allowed) {
worker_fetch_context.GetWebWorkerFetchContext()->DidRunInsecureContent( worker_fetch_context.GetWebWorkerFetchContext()->DidRunInsecureContent(
WebSecurityOrigin(fetch_client_settings_object.GetSecurityOrigin()), WebSecurityOrigin(fetch_client_settings_object.GetSecurityOrigin()),
...@@ -607,17 +605,13 @@ bool MixedContentChecker::IsWebSocketAllowed( ...@@ -607,17 +605,13 @@ bool MixedContentChecker::IsWebSocketAllowed(
} }
WorkerSettings* settings = worker_fetch_context.GetWorkerSettings(); WorkerSettings* settings = worker_fetch_context.GetWorkerSettings();
WorkerContentSettingsClient* content_settings_client =
worker_fetch_context.GetWorkerContentSettingsClient();
const SecurityOrigin* security_origin = const SecurityOrigin* security_origin =
fetch_client_settings_object.GetSecurityOrigin(); fetch_client_settings_object.GetSecurityOrigin();
bool allowed = bool allowed =
IsWebSocketAllowedInWorker(worker_fetch_context, settings, url); IsWebSocketAllowedInWorker(worker_fetch_context, settings, url);
if (content_settings_client) { allowed = worker_fetch_context.AllowRunningInsecureContent(
allowed = content_settings_client->AllowRunningInsecureContent( allowed, security_origin, url);
allowed, security_origin, url);
}
if (allowed) { if (allowed) {
worker_fetch_context.GetWebWorkerFetchContext()->DidRunInsecureContent( worker_fetch_context.GetWebWorkerFetchContext()->DidRunInsecureContent(
......
...@@ -193,9 +193,10 @@ void ModuleScriptLoaderTest::InitializeForWorklet() { ...@@ -193,9 +193,10 @@ void ModuleScriptLoaderTest::InitializeForWorklet() {
"UserAgent", nullptr /* web_worker_fetch_context */, "UserAgent", nullptr /* web_worker_fetch_context */,
Vector<CSPHeaderAndType>(), network::mojom::ReferrerPolicy::kDefault, Vector<CSPHeaderAndType>(), network::mojom::ReferrerPolicy::kDefault,
security_origin_.get(), true /* is_secure_context */, HttpsState::kModern, security_origin_.get(), true /* is_secure_context */, HttpsState::kModern,
nullptr /* worker_clients */, mojom::IPAddressSpace::kLocal, nullptr /* worker_clients */, nullptr /* content_settings_client */,
nullptr /* origin_trial_token */, base::UnguessableToken::Create(), mojom::IPAddressSpace::kLocal, nullptr /* origin_trial_token */,
nullptr /* worker_settings */, kV8CacheOptionsDefault, base::UnguessableToken::Create(), nullptr /* worker_settings */,
kV8CacheOptionsDefault,
MakeGarbageCollected<WorkletModuleResponsesMap>()); MakeGarbageCollected<WorkletModuleResponsesMap>());
global_scope_ = MakeGarbageCollected<WorkletGlobalScope>( global_scope_ = MakeGarbageCollected<WorkletGlobalScope>(
std::move(creation_params), *reporting_proxy_, &GetFrame()); std::move(creation_params), *reporting_proxy_, &GetFrame());
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include "third_party/blink/renderer/core/probe/core_probes.h" #include "third_party/blink/renderer/core/probe/core_probes.h"
#include "third_party/blink/renderer/core/timing/worker_global_scope_performance.h" #include "third_party/blink/renderer/core/timing/worker_global_scope_performance.h"
#include "third_party/blink/renderer/core/workers/worker_clients.h" #include "third_party/blink/renderer/core/workers/worker_clients.h"
#include "third_party/blink/renderer/core/workers/worker_content_settings_client.h"
#include "third_party/blink/renderer/core/workers/worker_global_scope.h" #include "third_party/blink/renderer/core/workers/worker_global_scope.h"
#include "third_party/blink/renderer/platform/exported/wrapped_resource_request.h" #include "third_party/blink/renderer/platform/exported/wrapped_resource_request.h"
#include "third_party/blink/renderer/platform/instrumentation/use_counter.h" #include "third_party/blink/renderer/platform/instrumentation/use_counter.h"
...@@ -81,11 +80,13 @@ WorkerFetchContext::GetPreviewsResourceLoadingHints() const { ...@@ -81,11 +80,13 @@ WorkerFetchContext::GetPreviewsResourceLoadingHints() const {
} }
bool WorkerFetchContext::AllowScriptFromSource(const KURL& url) const { bool WorkerFetchContext::AllowScriptFromSource(const KURL& url) const {
WorkerContentSettingsClient* settings_client = if (!global_scope_->ContentSettingsClient()) {
WorkerContentSettingsClient::From(*global_scope_); return true;
}
// If we're on a worker, script should be enabled, so no need to plumb // If we're on a worker, script should be enabled, so no need to plumb
// Settings::GetScriptEnabled() here. // Settings::GetScriptEnabled() here.
return !settings_client || settings_client->AllowScriptFromSource(true, url); return global_scope_->ContentSettingsClient()->AllowScriptFromSource(true,
url);
} }
bool WorkerFetchContext::ShouldBlockRequestByInspector(const KURL& url) const { bool WorkerFetchContext::ShouldBlockRequestByInspector(const KURL& url) const {
...@@ -254,9 +255,14 @@ WorkerSettings* WorkerFetchContext::GetWorkerSettings() const { ...@@ -254,9 +255,14 @@ WorkerSettings* WorkerFetchContext::GetWorkerSettings() const {
return scope ? scope->GetWorkerSettings() : nullptr; return scope ? scope->GetWorkerSettings() : nullptr;
} }
WorkerContentSettingsClient* bool WorkerFetchContext::AllowRunningInsecureContent(
WorkerFetchContext::GetWorkerContentSettingsClient() const { bool enabled_per_settings,
return WorkerContentSettingsClient::From(*global_scope_); const SecurityOrigin* origin,
const KURL& url) const {
if (!global_scope_->ContentSettingsClient())
return enabled_per_settings;
return global_scope_->ContentSettingsClient()->AllowRunningInsecureContent(
enabled_per_settings, WebSecurityOrigin(origin), url);
} }
void WorkerFetchContext::Trace(blink::Visitor* visitor) { void WorkerFetchContext::Trace(blink::Visitor* visitor) {
......
...@@ -18,7 +18,6 @@ namespace blink { ...@@ -18,7 +18,6 @@ namespace blink {
class CoreProbeSink; class CoreProbeSink;
class SubresourceFilter; class SubresourceFilter;
class WebWorkerFetchContext; class WebWorkerFetchContext;
class WorkerContentSettingsClient;
class WorkerResourceTimingNotifier; class WorkerResourceTimingNotifier;
class WorkerSettings; class WorkerSettings;
class WorkerOrWorkletGlobalScope; class WorkerOrWorkletGlobalScope;
...@@ -85,11 +84,14 @@ class WorkerFetchContext final : public BaseFetchContext { ...@@ -85,11 +84,14 @@ class WorkerFetchContext final : public BaseFetchContext {
ResourceRequest&) override; ResourceRequest&) override;
WorkerSettings* GetWorkerSettings() const; WorkerSettings* GetWorkerSettings() const;
WorkerContentSettingsClient* GetWorkerContentSettingsClient() const;
WebWorkerFetchContext* GetWebWorkerFetchContext() const { WebWorkerFetchContext* GetWebWorkerFetchContext() const {
return web_context_.get(); return web_context_.get();
} }
bool AllowRunningInsecureContent(bool enabled_per_settings,
const SecurityOrigin* origin,
const KURL& url) const;
void Trace(blink::Visitor*) override; void Trace(blink::Visitor*) override;
private: private:
......
...@@ -57,8 +57,6 @@ blink_core_sources("workers") { ...@@ -57,8 +57,6 @@ blink_core_sources("workers") {
"worker_classic_script_loader.h", "worker_classic_script_loader.h",
"worker_clients.cc", "worker_clients.cc",
"worker_clients.h", "worker_clients.h",
"worker_content_settings_client.cc",
"worker_content_settings_client.h",
"worker_global_scope.cc", "worker_global_scope.cc",
"worker_global_scope.h", "worker_global_scope.h",
"worker_location.h", "worker_location.h",
......
...@@ -37,7 +37,6 @@ ...@@ -37,7 +37,6 @@
#include "third_party/blink/renderer/core/workers/dedicated_worker_messaging_proxy.h" #include "third_party/blink/renderer/core/workers/dedicated_worker_messaging_proxy.h"
#include "third_party/blink/renderer/core/workers/worker_classic_script_loader.h" #include "third_party/blink/renderer/core/workers/worker_classic_script_loader.h"
#include "third_party/blink/renderer/core/workers/worker_clients.h" #include "third_party/blink/renderer/core/workers/worker_clients.h"
#include "third_party/blink/renderer/core/workers/worker_content_settings_client.h"
#include "third_party/blink/renderer/core/workers/worker_global_scope.h" #include "third_party/blink/renderer/core/workers/worker_global_scope.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h" #include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/bindings/script_state.h" #include "third_party/blink/renderer/platform/bindings/script_state.h"
...@@ -364,21 +363,22 @@ WorkerClients* DedicatedWorker::CreateWorkerClients() { ...@@ -364,21 +363,22 @@ WorkerClients* DedicatedWorker::CreateWorkerClients() {
*worker_clients); *worker_clients);
CoreInitializer::GetInstance().ProvideIndexedDBClientToWorker( CoreInitializer::GetInstance().ProvideIndexedDBClientToWorker(
*worker_clients); *worker_clients);
return worker_clients;
}
std::unique_ptr<WebContentSettingsClient> client; std::unique_ptr<WebContentSettingsClient>
DedicatedWorker::CreateWebContentSettingsClient() {
std::unique_ptr<WebContentSettingsClient> content_settings_client;
if (auto* document = DynamicTo<Document>(GetExecutionContext())) { if (auto* document = DynamicTo<Document>(GetExecutionContext())) {
LocalFrame* frame = document->GetFrame(); LocalFrame* frame = document->GetFrame();
client = frame->Client()->CreateWorkerContentSettingsClient(); return frame->Client()->CreateWorkerContentSettingsClient();
} else if (GetExecutionContext()->IsWorkerGlobalScope()) { } else if (GetExecutionContext()->IsWorkerGlobalScope()) {
WebContentSettingsClient* web_worker_content_settings_client = WebContentSettingsClient* web_worker_content_settings_client =
WorkerContentSettingsClient::From(*GetExecutionContext()) To<WorkerGlobalScope>(GetExecutionContext())->ContentSettingsClient();
->GetWebContentSettingsClient();
if (web_worker_content_settings_client) if (web_worker_content_settings_client)
client = web_worker_content_settings_client->Clone(); return web_worker_content_settings_client->Clone();
} }
return nullptr;
ProvideContentSettingsClientToWorker(worker_clients, std::move(client));
return worker_clients;
} }
void DedicatedWorker::OnResponse() { void DedicatedWorker::OnResponse() {
...@@ -464,7 +464,7 @@ DedicatedWorker::CreateGlobalScopeCreationParams( ...@@ -464,7 +464,7 @@ DedicatedWorker::CreateGlobalScopeCreationParams(
referrer_policy, GetExecutionContext()->GetSecurityOrigin(), referrer_policy, GetExecutionContext()->GetSecurityOrigin(),
GetExecutionContext()->IsSecureContext(), GetExecutionContext()->IsSecureContext(),
GetExecutionContext()->GetHttpsState(), CreateWorkerClients(), GetExecutionContext()->GetHttpsState(), CreateWorkerClients(),
response_address_space, CreateWebContentSettingsClient(), response_address_space,
OriginTrialContext::GetTokens(GetExecutionContext()).get(), OriginTrialContext::GetTokens(GetExecutionContext()).get(),
parent_devtools_token, std::move(settings), kV8CacheOptionsDefault, parent_devtools_token, std::move(settings), kV8CacheOptionsDefault,
nullptr /* worklet_module_responses_map */, nullptr /* worklet_module_responses_map */,
......
...@@ -135,6 +135,8 @@ class CORE_EXPORT DedicatedWorker final ...@@ -135,6 +135,8 @@ class CORE_EXPORT DedicatedWorker final
base::Optional<mojom::IPAddressSpace> response_address_space); base::Optional<mojom::IPAddressSpace> response_address_space);
scoped_refptr<WebWorkerFetchContext> CreateWebWorkerFetchContext(); scoped_refptr<WebWorkerFetchContext> CreateWebWorkerFetchContext();
WorkerClients* CreateWorkerClients(); WorkerClients* CreateWorkerClients();
// May return nullptr.
std::unique_ptr<WebContentSettingsClient> CreateWebContentSettingsClient();
// Callbacks for |classic_script_loader_|. // Callbacks for |classic_script_loader_|.
void OnResponse(); void OnResponse();
......
...@@ -140,10 +140,10 @@ class DedicatedWorkerMessagingProxyForTest ...@@ -140,10 +140,10 @@ class DedicatedWorkerMessagingProxyForTest
network::mojom::ReferrerPolicy::kDefault, security_origin_.get(), network::mojom::ReferrerPolicy::kDefault, security_origin_.get(),
false /* starter_secure_context */, false /* starter_secure_context */,
CalculateHttpsState(security_origin_.get()), CalculateHttpsState(security_origin_.get()),
nullptr /* worker_clients */, mojom::IPAddressSpace::kLocal, nullptr /* worker_clients */, nullptr /* content_settings_client */,
nullptr /* origin_trial_tokens */, base::UnguessableToken::Create(), mojom::IPAddressSpace::kLocal, nullptr /* origin_trial_tokens */,
std::move(worker_settings), kV8CacheOptionsDefault, base::UnguessableToken::Create(), std::move(worker_settings),
nullptr /* worklet_module_responses_map */), kV8CacheOptionsDefault, nullptr /* worklet_module_responses_map */),
WorkerBackingThreadStartupData( WorkerBackingThreadStartupData(
WorkerBackingThreadStartupData::HeapLimitMode::kDefault, WorkerBackingThreadStartupData::HeapLimitMode::kDefault,
WorkerBackingThreadStartupData::AtomicsWaitMode::kAllow)); WorkerBackingThreadStartupData::AtomicsWaitMode::kAllow));
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "third_party/blink/renderer/core/workers/global_scope_creation_params.h" #include "third_party/blink/renderer/core/workers/global_scope_creation_params.h"
#include <memory> #include <memory>
#include "base/feature_list.h" #include "base/feature_list.h"
#include "third_party/blink/public/common/features.h" #include "third_party/blink/public/common/features.h"
#include "third_party/blink/renderer/platform/network/content_security_policy_parsers.h" #include "third_party/blink/renderer/platform/network/content_security_policy_parsers.h"
...@@ -24,6 +25,7 @@ GlobalScopeCreationParams::GlobalScopeCreationParams( ...@@ -24,6 +25,7 @@ GlobalScopeCreationParams::GlobalScopeCreationParams(
bool starter_secure_context, bool starter_secure_context,
HttpsState starter_https_state, HttpsState starter_https_state,
WorkerClients* worker_clients, WorkerClients* worker_clients,
std::unique_ptr<WebContentSettingsClient> content_settings_client,
base::Optional<mojom::IPAddressSpace> response_address_space, base::Optional<mojom::IPAddressSpace> response_address_space,
const Vector<String>* origin_trial_tokens, const Vector<String>* origin_trial_tokens,
const base::UnguessableToken& parent_devtools_token, const base::UnguessableToken& parent_devtools_token,
...@@ -46,6 +48,7 @@ GlobalScopeCreationParams::GlobalScopeCreationParams( ...@@ -46,6 +48,7 @@ GlobalScopeCreationParams::GlobalScopeCreationParams(
starter_secure_context(starter_secure_context), starter_secure_context(starter_secure_context),
starter_https_state(starter_https_state), starter_https_state(starter_https_state),
worker_clients(worker_clients), worker_clients(worker_clients),
content_settings_client(std::move(content_settings_client)),
response_address_space(response_address_space), response_address_space(response_address_space),
parent_devtools_token(parent_devtools_token), parent_devtools_token(parent_devtools_token),
worker_settings(std::move(worker_settings)), worker_settings(std::move(worker_settings)),
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "third_party/blink/public/common/feature_policy/feature_policy.h" #include "third_party/blink/public/common/feature_policy/feature_policy.h"
#include "third_party/blink/public/mojom/net/ip_address_space.mojom-blink.h" #include "third_party/blink/public/mojom/net/ip_address_space.mojom-blink.h"
#include "third_party/blink/public/mojom/script/script_type.mojom-blink.h" #include "third_party/blink/public/mojom/script/script_type.mojom-blink.h"
#include "third_party/blink/public/platform/web_content_settings_client.h"
#include "third_party/blink/public/platform/web_worker_fetch_context.h" #include "third_party/blink/public/platform/web_worker_fetch_context.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_cache_options.h" #include "third_party/blink/renderer/bindings/core/v8/v8_cache_options.h"
#include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/core/core_export.h"
...@@ -53,6 +54,7 @@ struct CORE_EXPORT GlobalScopeCreationParams final { ...@@ -53,6 +54,7 @@ struct CORE_EXPORT GlobalScopeCreationParams final {
bool starter_secure_context, bool starter_secure_context,
HttpsState starter_https_state, HttpsState starter_https_state,
WorkerClients*, WorkerClients*,
std::unique_ptr<WebContentSettingsClient>,
base::Optional<mojom::IPAddressSpace>, base::Optional<mojom::IPAddressSpace>,
const Vector<String>* origin_trial_tokens, const Vector<String>* origin_trial_tokens,
const base::UnguessableToken& parent_devtools_token, const base::UnguessableToken& parent_devtools_token,
...@@ -132,6 +134,8 @@ struct CORE_EXPORT GlobalScopeCreationParams final { ...@@ -132,6 +134,8 @@ struct CORE_EXPORT GlobalScopeCreationParams final {
// supplies no extra 'clients', m_workerClients can be left as empty/null. // supplies no extra 'clients', m_workerClients can be left as empty/null.
CrossThreadPersistent<WorkerClients> worker_clients; CrossThreadPersistent<WorkerClients> worker_clients;
std::unique_ptr<WebContentSettingsClient> content_settings_client;
// Worker script response's address space. This is valid only when the worker // Worker script response's address space. This is valid only when the worker
// script is fetched on the main thread (i.e., when // script is fetched on the main thread (i.e., when
// |off_main_thread_fetch_option| is kDisabled). // |off_main_thread_fetch_option| is kDisabled).
......
...@@ -70,8 +70,8 @@ class MainThreadWorkletTest : public PageTestBase { ...@@ -70,8 +70,8 @@ class MainThreadWorkletTest : public PageTestBase {
document->GetContentSecurityPolicy()->Headers(), document->GetContentSecurityPolicy()->Headers(),
document->GetReferrerPolicy(), document->GetSecurityOrigin(), document->GetReferrerPolicy(), document->GetSecurityOrigin(),
document->IsSecureContext(), document->GetHttpsState(), document->IsSecureContext(), document->GetHttpsState(),
nullptr /* worker_clients */, document->AddressSpace(), nullptr /* worker_clients */, nullptr /* content_settings_client */,
OriginTrialContext::GetTokens(document).get(), document->AddressSpace(), OriginTrialContext::GetTokens(document).get(),
base::UnguessableToken::Create(), nullptr /* worker_settings */, base::UnguessableToken::Create(), nullptr /* worker_settings */,
kV8CacheOptionsDefault, kV8CacheOptionsDefault,
MakeGarbageCollected<WorkletModuleResponsesMap>()); MakeGarbageCollected<WorkletModuleResponsesMap>());
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include "third_party/blink/renderer/core/workers/global_scope_creation_params.h" #include "third_party/blink/renderer/core/workers/global_scope_creation_params.h"
#include "third_party/blink/renderer/core/workers/threaded_worklet_object_proxy.h" #include "third_party/blink/renderer/core/workers/threaded_worklet_object_proxy.h"
#include "third_party/blink/renderer/core/workers/worker_clients.h" #include "third_party/blink/renderer/core/workers/worker_clients.h"
#include "third_party/blink/renderer/core/workers/worker_content_settings_client.h"
#include "third_party/blink/renderer/core/workers/worklet_global_scope.h" #include "third_party/blink/renderer/core/workers/worklet_global_scope.h"
#include "third_party/blink/renderer/core/workers/worklet_module_responses_map.h" #include "third_party/blink/renderer/core/workers/worklet_module_responses_map.h"
#include "third_party/blink/renderer/core/workers/worklet_pending_tasks.h" #include "third_party/blink/renderer/core/workers/worklet_pending_tasks.h"
...@@ -55,10 +54,6 @@ void ThreadedWorkletMessagingProxy::Initialize( ...@@ -55,10 +54,6 @@ void ThreadedWorkletMessagingProxy::Initialize(
ContentSecurityPolicy* csp = document->GetContentSecurityPolicy(); ContentSecurityPolicy* csp = document->GetContentSecurityPolicy();
DCHECK(csp); DCHECK(csp);
ProvideContentSettingsClientToWorker(
worker_clients,
document->GetFrame()->Client()->CreateWorkerContentSettingsClient());
auto global_scope_creation_params = auto global_scope_creation_params =
std::make_unique<GlobalScopeCreationParams>( std::make_unique<GlobalScopeCreationParams>(
document->Url(), mojom::ScriptType::kModule, document->Url(), mojom::ScriptType::kModule,
...@@ -67,7 +62,9 @@ void ThreadedWorkletMessagingProxy::Initialize( ...@@ -67,7 +62,9 @@ void ThreadedWorkletMessagingProxy::Initialize(
document->GetFrame()->Client()->CreateWorkerFetchContext(), document->GetFrame()->Client()->CreateWorkerFetchContext(),
csp->Headers(), document->GetReferrerPolicy(), csp->Headers(), document->GetReferrerPolicy(),
document->GetSecurityOrigin(), document->IsSecureContext(), document->GetSecurityOrigin(), document->IsSecureContext(),
document->GetHttpsState(), worker_clients, document->AddressSpace(), document->GetHttpsState(), worker_clients,
document->GetFrame()->Client()->CreateWorkerContentSettingsClient(),
document->AddressSpace(),
OriginTrialContext::GetTokens(document).get(), OriginTrialContext::GetTokens(document).get(),
base::UnguessableToken::Create(), base::UnguessableToken::Create(),
std::make_unique<WorkerSettings>(document->GetSettings()), std::make_unique<WorkerSettings>(document->GetSettings()),
......
...@@ -210,7 +210,8 @@ class ThreadedWorkletMessagingProxyForTest ...@@ -210,7 +210,8 @@ class ThreadedWorkletMessagingProxyForTest
document->GetContentSecurityPolicy()->Headers(), document->GetContentSecurityPolicy()->Headers(),
document->GetReferrerPolicy(), document->GetSecurityOrigin(), document->GetReferrerPolicy(), document->GetSecurityOrigin(),
document->IsSecureContext(), document->GetHttpsState(), document->IsSecureContext(), document->GetHttpsState(),
worker_clients, document->AddressSpace(), worker_clients, nullptr /* content_settings_client */,
document->AddressSpace(),
OriginTrialContext::GetTokens(document).get(), OriginTrialContext::GetTokens(document).get(),
base::UnguessableToken::Create(), std::move(worker_settings), base::UnguessableToken::Create(), std::move(worker_settings),
kV8CacheOptionsDefault, kV8CacheOptionsDefault,
......
/*
* Copyright (C) 2013 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "third_party/blink/renderer/core/workers/worker_content_settings_client.h"
#include <memory>
#include "third_party/blink/public/platform/web_security_origin.h"
#include "third_party/blink/public/platform/web_string.h"
#include "third_party/blink/renderer/core/workers/worker_global_scope.h"
#include "third_party/blink/renderer/platform/weborigin/security_origin.h"
namespace blink {
WorkerContentSettingsClient::~WorkerContentSettingsClient() = default;
bool WorkerContentSettingsClient::RequestFileSystemAccessSync() {
if (!client_)
return true;
return client_->RequestFileSystemAccessSync();
}
bool WorkerContentSettingsClient::AllowIndexedDB() {
if (!client_)
return true;
return client_->AllowIndexedDB(WebSecurityOrigin());
}
bool WorkerContentSettingsClient::AllowCacheStorage() {
if (!client_)
return true;
return client_->AllowCacheStorage(WebSecurityOrigin());
}
bool WorkerContentSettingsClient::AllowScriptFromSource(
bool enabled_per_settings,
const KURL& url) {
if (client_) {
return client_->AllowScriptFromSource(enabled_per_settings, url);
}
return enabled_per_settings;
}
bool WorkerContentSettingsClient::AllowRunningInsecureContent(
bool enabled_per_settings,
const SecurityOrigin* origin,
const KURL& url) {
if (client_) {
return client_->AllowRunningInsecureContent(enabled_per_settings,
WebSecurityOrigin(origin), url);
}
return enabled_per_settings;
}
const char WorkerContentSettingsClient::kSupplementName[] =
"WorkerContentSettingsClient";
WorkerContentSettingsClient* WorkerContentSettingsClient::From(
ExecutionContext& context) {
WorkerClients* clients = To<WorkerOrWorkletGlobalScope>(context).Clients();
DCHECK(clients);
return Supplement<WorkerClients>::From<WorkerContentSettingsClient>(*clients);
}
WorkerContentSettingsClient::WorkerContentSettingsClient(
std::unique_ptr<WebContentSettingsClient> client)
: client_(std::move(client)) {}
void ProvideContentSettingsClientToWorker(
WorkerClients* clients,
std::unique_ptr<WebContentSettingsClient> client) {
DCHECK(clients);
WorkerContentSettingsClient::ProvideTo(
*clients,
MakeGarbageCollected<WorkerContentSettingsClient>(std::move(client)));
}
} // namespace blink
/*
* Copyright (C) 2013 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_WORKERS_WORKER_CONTENT_SETTINGS_CLIENT_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_WORKERS_WORKER_CONTENT_SETTINGS_CLIENT_H_
#include <memory>
#include "third_party/blink/public/platform/web_content_settings_client.h"
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/workers/worker_clients.h"
#include "third_party/blink/renderer/platform/wtf/forward.h"
namespace blink {
class ExecutionContext;
class KURL;
class SecurityOrigin;
class CORE_EXPORT WorkerContentSettingsClient final
: public GarbageCollectedFinalized<WorkerContentSettingsClient>,
public Supplement<WorkerClients> {
USING_GARBAGE_COLLECTED_MIXIN(WorkerContentSettingsClient);
public:
static const char kSupplementName[];
explicit WorkerContentSettingsClient(
std::unique_ptr<WebContentSettingsClient>);
virtual ~WorkerContentSettingsClient();
bool RequestFileSystemAccessSync();
bool AllowIndexedDB();
bool AllowCacheStorage();
bool AllowRunningInsecureContent(bool enabled_per_settings,
const SecurityOrigin*,
const KURL&);
bool AllowScriptFromSource(bool enabled_per_settings, const KURL&);
static WorkerContentSettingsClient* From(ExecutionContext&);
WebContentSettingsClient* GetWebContentSettingsClient() {
return client_.get();
}
void Trace(blink::Visitor* visitor) override {
Supplement<WorkerClients>::Trace(visitor);
}
private:
std::unique_ptr<WebContentSettingsClient> client_;
};
void CORE_EXPORT
ProvideContentSettingsClientToWorker(WorkerClients*,
std::unique_ptr<WebContentSettingsClient>);
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_WORKERS_WORKER_CONTENT_SETTINGS_CLIENT_H_
...@@ -476,6 +476,7 @@ WorkerGlobalScope::WorkerGlobalScope( ...@@ -476,6 +476,7 @@ WorkerGlobalScope::WorkerGlobalScope(
creation_params->parent_devtools_token, creation_params->parent_devtools_token,
creation_params->v8_cache_options, creation_params->v8_cache_options,
creation_params->worker_clients, creation_params->worker_clients,
std::move(creation_params->content_settings_client),
std::move(creation_params->web_worker_fetch_context), std::move(creation_params->web_worker_fetch_context),
thread->GetWorkerReportingProxy()), thread->GetWorkerReportingProxy()),
script_type_(creation_params->script_type), script_type_(creation_params->script_type),
......
...@@ -175,6 +175,7 @@ WorkerOrWorkletGlobalScope::WorkerOrWorkletGlobalScope( ...@@ -175,6 +175,7 @@ WorkerOrWorkletGlobalScope::WorkerOrWorkletGlobalScope(
const base::UnguessableToken& parent_devtools_token, const base::UnguessableToken& parent_devtools_token,
V8CacheOptions v8_cache_options, V8CacheOptions v8_cache_options,
WorkerClients* worker_clients, WorkerClients* worker_clients,
std::unique_ptr<WebContentSettingsClient> content_settings_client,
scoped_refptr<WebWorkerFetchContext> web_worker_fetch_context, scoped_refptr<WebWorkerFetchContext> web_worker_fetch_context,
WorkerReportingProxy& reporting_proxy) WorkerReportingProxy& reporting_proxy)
: ExecutionContext(isolate, : ExecutionContext(isolate,
...@@ -185,6 +186,7 @@ WorkerOrWorkletGlobalScope::WorkerOrWorkletGlobalScope( ...@@ -185,6 +186,7 @@ WorkerOrWorkletGlobalScope::WorkerOrWorkletGlobalScope(
name_(name), name_(name),
parent_devtools_token_(parent_devtools_token), parent_devtools_token_(parent_devtools_token),
worker_clients_(worker_clients), worker_clients_(worker_clients),
content_settings_client_(std::move(content_settings_client)),
web_worker_fetch_context_(std::move(web_worker_fetch_context)), web_worker_fetch_context_(std::move(web_worker_fetch_context)),
script_controller_( script_controller_(
MakeGarbageCollected<WorkerOrWorkletScriptController>(this, isolate)), MakeGarbageCollected<WorkerOrWorkletScriptController>(this, isolate)),
......
...@@ -53,6 +53,7 @@ class CORE_EXPORT WorkerOrWorkletGlobalScope : public EventTargetWithInlineData, ...@@ -53,6 +53,7 @@ class CORE_EXPORT WorkerOrWorkletGlobalScope : public EventTargetWithInlineData,
const base::UnguessableToken& parent_devtools_token, const base::UnguessableToken& parent_devtools_token,
V8CacheOptions, V8CacheOptions,
WorkerClients*, WorkerClients*,
std::unique_ptr<WebContentSettingsClient>,
scoped_refptr<WebWorkerFetchContext>, scoped_refptr<WebWorkerFetchContext>,
WorkerReportingProxy&); WorkerReportingProxy&);
~WorkerOrWorkletGlobalScope() override; ~WorkerOrWorkletGlobalScope() override;
...@@ -125,6 +126,11 @@ class CORE_EXPORT WorkerOrWorkletGlobalScope : public EventTargetWithInlineData, ...@@ -125,6 +126,11 @@ class CORE_EXPORT WorkerOrWorkletGlobalScope : public EventTargetWithInlineData,
WorkerClients* Clients() const { return worker_clients_.Get(); } WorkerClients* Clients() const { return worker_clients_.Get(); }
// May return nullptr.
WebContentSettingsClient* ContentSettingsClient() const {
return content_settings_client_.get();
}
WorkerOrWorkletScriptController* ScriptController() { WorkerOrWorkletScriptController* ScriptController() {
return script_controller_.Get(); return script_controller_.Get();
} }
...@@ -180,6 +186,7 @@ class CORE_EXPORT WorkerOrWorkletGlobalScope : public EventTargetWithInlineData, ...@@ -180,6 +186,7 @@ class CORE_EXPORT WorkerOrWorkletGlobalScope : public EventTargetWithInlineData,
const base::UnguessableToken parent_devtools_token_; const base::UnguessableToken parent_devtools_token_;
CrossThreadPersistent<WorkerClients> worker_clients_; CrossThreadPersistent<WorkerClients> worker_clients_;
std::unique_ptr<WebContentSettingsClient> content_settings_client_;
Member<ResourceFetcher> inside_settings_resource_fetcher_; Member<ResourceFetcher> inside_settings_resource_fetcher_;
......
...@@ -404,7 +404,8 @@ TEST_F(WorkerThreadTest, Terminate_WhileDebuggerTaskIsRunningOnInitialization) { ...@@ -404,7 +404,8 @@ TEST_F(WorkerThreadTest, Terminate_WhileDebuggerTaskIsRunningOnInitialization) {
network::mojom::ReferrerPolicy::kDefault, security_origin_.get(), network::mojom::ReferrerPolicy::kDefault, security_origin_.get(),
false /* starter_secure_context */, false /* starter_secure_context */,
CalculateHttpsState(security_origin_.get()), CalculateHttpsState(security_origin_.get()),
MakeGarbageCollected<WorkerClients>(), mojom::IPAddressSpace::kLocal, MakeGarbageCollected<WorkerClients>(),
nullptr /* content_settings_client */, mojom::IPAddressSpace::kLocal,
nullptr /* originTrialToken */, base::UnguessableToken::Create(), nullptr /* originTrialToken */, base::UnguessableToken::Create(),
std::make_unique<WorkerSettings>(std::make_unique<Settings>().get()), std::make_unique<WorkerSettings>(std::make_unique<Settings>().get()),
kV8CacheOptionsDefault, nullptr /* worklet_module_responses_map */); kV8CacheOptionsDefault, nullptr /* worklet_module_responses_map */);
......
...@@ -130,8 +130,8 @@ class WorkerThreadForTest : public WorkerThread { ...@@ -130,8 +130,8 @@ class WorkerThreadForTest : public WorkerThread {
network::mojom::ReferrerPolicy::kDefault, security_origin, network::mojom::ReferrerPolicy::kDefault, security_origin,
false /* starter_secure_context */, false /* starter_secure_context */,
CalculateHttpsState(security_origin), worker_clients, CalculateHttpsState(security_origin), worker_clients,
mojom::IPAddressSpace::kLocal, nullptr, nullptr /* content_settings_client */, mojom::IPAddressSpace::kLocal,
base::UnguessableToken::Create(), nullptr, base::UnguessableToken::Create(),
std::make_unique<WorkerSettings>(std::make_unique<Settings>().get()), std::make_unique<WorkerSettings>(std::make_unique<Settings>().get()),
kV8CacheOptionsDefault, nullptr /* worklet_module_responses_map */); kV8CacheOptionsDefault, nullptr /* worklet_module_responses_map */);
......
...@@ -75,6 +75,7 @@ WorkletGlobalScope::WorkletGlobalScope( ...@@ -75,6 +75,7 @@ WorkletGlobalScope::WorkletGlobalScope(
creation_params->parent_devtools_token, creation_params->parent_devtools_token,
creation_params->v8_cache_options, creation_params->v8_cache_options,
creation_params->worker_clients, creation_params->worker_clients,
std::move(creation_params->content_settings_client),
std::move(creation_params->web_worker_fetch_context), std::move(creation_params->web_worker_fetch_context),
reporting_proxy), reporting_proxy),
url_(creation_params->script_url), url_(creation_params->script_url),
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include "third_party/blink/renderer/core/fetch/response.h" #include "third_party/blink/renderer/core/fetch/response.h"
#include "third_party/blink/renderer/core/frame/local_frame.h" #include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/inspector/console_message.h" #include "third_party/blink/renderer/core/inspector/console_message.h"
#include "third_party/blink/renderer/core/workers/worker_content_settings_client.h"
#include "third_party/blink/renderer/modules/cache_storage/cache_storage_error.h" #include "third_party/blink/renderer/modules/cache_storage/cache_storage_error.h"
#include "third_party/blink/renderer/modules/cache_storage/cache_storage_trace_utils.h" #include "third_party/blink/renderer/modules/cache_storage/cache_storage_trace_utils.h"
#include "third_party/blink/renderer/modules/service_worker/service_worker_global_scope.h" #include "third_party/blink/renderer/modules/service_worker/service_worker_global_scope.h"
...@@ -74,9 +73,12 @@ bool IsCacheStorageAllowed(ScriptState* script_state) { ...@@ -74,9 +73,12 @@ bool IsCacheStorageAllowed(ScriptState* script_state) {
return true; return true;
} }
WorkerGlobalScope& worker_global = *To<WorkerGlobalScope>(context); WebContentSettingsClient* content_settings_client =
To<WorkerGlobalScope>(context)->ContentSettingsClient();
if (!content_settings_client)
return true;
// This triggers a sync IPC. // This triggers a sync IPC.
return WorkerContentSettingsClient::From(worker_global)->AllowCacheStorage(); return content_settings_client->AllowCacheStorage(WebSecurityOrigin());
} }
} // namespace } // namespace
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include "third_party/blink/renderer/core/origin_trials/origin_trial_context.h" #include "third_party/blink/renderer/core/origin_trials/origin_trial_context.h"
#include "third_party/blink/renderer/core/script/script.h" #include "third_party/blink/renderer/core/script/script.h"
#include "third_party/blink/renderer/core/workers/global_scope_creation_params.h" #include "third_party/blink/renderer/core/workers/global_scope_creation_params.h"
#include "third_party/blink/renderer/core/workers/worker_content_settings_client.h"
#include "third_party/blink/renderer/core/workers/worklet_module_responses_map.h" #include "third_party/blink/renderer/core/workers/worklet_module_responses_map.h"
#include "third_party/blink/renderer/platform/weborigin/kurl.h" #include "third_party/blink/renderer/platform/weborigin/kurl.h"
#include "third_party/blink/renderer/platform/wtf/wtf.h" #include "third_party/blink/renderer/platform/wtf/wtf.h"
...@@ -38,9 +37,8 @@ PaintWorkletGlobalScopeProxy::PaintWorkletGlobalScopeProxy( ...@@ -38,9 +37,8 @@ PaintWorkletGlobalScopeProxy::PaintWorkletGlobalScopeProxy(
String global_scope_name = String global_scope_name =
StringView("PaintWorklet #") + String::Number(global_scope_number); StringView("PaintWorklet #") + String::Number(global_scope_number);
// TODO(bashi): Pass nullptr instead of an empty WorkerClients?
auto* worker_clients = MakeGarbageCollected<WorkerClients>(); auto* worker_clients = MakeGarbageCollected<WorkerClients>();
ProvideContentSettingsClientToWorker(
worker_clients, frame->Client()->CreateWorkerContentSettingsClient());
auto creation_params = std::make_unique<GlobalScopeCreationParams>( auto creation_params = std::make_unique<GlobalScopeCreationParams>(
document->Url(), mojom::ScriptType::kModule, document->Url(), mojom::ScriptType::kModule,
...@@ -49,9 +47,13 @@ PaintWorkletGlobalScopeProxy::PaintWorkletGlobalScopeProxy( ...@@ -49,9 +47,13 @@ PaintWorkletGlobalScopeProxy::PaintWorkletGlobalScopeProxy(
document->GetContentSecurityPolicy()->Headers(), document->GetContentSecurityPolicy()->Headers(),
document->GetReferrerPolicy(), document->GetSecurityOrigin(), document->GetReferrerPolicy(), document->GetSecurityOrigin(),
document->IsSecureContext(), document->GetHttpsState(), worker_clients, document->IsSecureContext(), document->GetHttpsState(), worker_clients,
frame->Client()->CreateWorkerContentSettingsClient(),
document->AddressSpace(), OriginTrialContext::GetTokens(document).get(), document->AddressSpace(), OriginTrialContext::GetTokens(document).get(),
base::UnguessableToken::Create(), nullptr /* worker_settings */, base::UnguessableToken::Create(), nullptr /* worker_settings */,
kV8CacheOptionsDefault, module_responses_map); kV8CacheOptionsDefault, module_responses_map,
service_manager::mojom::blink::InterfaceProviderPtrInfo(),
BeginFrameProviderParams(), nullptr /* parent_feature_policy */,
base::UnguessableToken() /* agent_cluster_id */);
global_scope_ = PaintWorkletGlobalScope::Create( global_scope_ = PaintWorkletGlobalScope::Create(
frame, std::move(creation_params), *reporting_proxy_); frame, std::move(creation_params), *reporting_proxy_);
} }
......
...@@ -59,7 +59,6 @@ ...@@ -59,7 +59,6 @@
#include "third_party/blink/renderer/core/workers/parent_execution_context_task_runners.h" #include "third_party/blink/renderer/core/workers/parent_execution_context_task_runners.h"
#include "third_party/blink/renderer/core/workers/worker_backing_thread_startup_data.h" #include "third_party/blink/renderer/core/workers/worker_backing_thread_startup_data.h"
#include "third_party/blink/renderer/core/workers/worker_classic_script_loader.h" #include "third_party/blink/renderer/core/workers/worker_classic_script_loader.h"
#include "third_party/blink/renderer/core/workers/worker_content_settings_client.h"
#include "third_party/blink/renderer/core/workers/worker_global_scope.h" #include "third_party/blink/renderer/core/workers/worker_global_scope.h"
#include "third_party/blink/renderer/modules/indexeddb/indexed_db_client.h" #include "third_party/blink/renderer/modules/indexeddb/indexed_db_client.h"
#include "third_party/blink/renderer/modules/service_worker/service_worker_global_scope_proxy.h" #include "third_party/blink/renderer/modules/service_worker/service_worker_global_scope_proxy.h"
...@@ -389,9 +388,6 @@ void WebEmbeddedWorkerImpl::StartWorkerThread() { ...@@ -389,9 +388,6 @@ void WebEmbeddedWorkerImpl::StartWorkerThread() {
ProvideIndexedDBClientToWorker( ProvideIndexedDBClientToWorker(
worker_clients, MakeGarbageCollected<IndexedDBClient>(*worker_clients)); worker_clients, MakeGarbageCollected<IndexedDBClient>(*worker_clients));
ProvideContentSettingsClientToWorker(worker_clients,
std::move(content_settings_client_));
scoped_refptr<WebWorkerFetchContext> web_worker_fetch_context; scoped_refptr<WebWorkerFetchContext> web_worker_fetch_context;
if (base::FeatureList::IsEnabled( if (base::FeatureList::IsEnabled(
features::kOffMainThreadServiceWorkerScriptFetch)) { features::kOffMainThreadServiceWorkerScriptFetch)) {
...@@ -454,12 +450,15 @@ void WebEmbeddedWorkerImpl::StartWorkerThread() { ...@@ -454,12 +450,15 @@ void WebEmbeddedWorkerImpl::StartWorkerThread() {
: Vector<CSPHeaderAndType>(), : Vector<CSPHeaderAndType>(),
referrer_policy, starter_origin.get(), starter_secure_context, referrer_policy, starter_origin.get(), starter_secure_context,
starter_https_state, worker_clients, starter_https_state, worker_clients,
std::move(content_settings_client_),
main_script_loader_->ResponseAddressSpace(), main_script_loader_->ResponseAddressSpace(),
main_script_loader_->OriginTrialTokens(), devtools_worker_token_, main_script_loader_->OriginTrialTokens(), devtools_worker_token_,
std::move(worker_settings), std::move(worker_settings),
static_cast<V8CacheOptions>(worker_start_data_.v8_cache_options), static_cast<V8CacheOptions>(worker_start_data_.v8_cache_options),
nullptr /* worklet_module_respones_map */, nullptr /* worklet_module_respones_map */,
std::move(interface_provider_info_)); std::move(interface_provider_info_), BeginFrameProviderParams(),
nullptr /* parent_feature_policy */,
base::UnguessableToken() /* agent_cluster_id */);
source_code = main_script_loader_->SourceText(); source_code = main_script_loader_->SourceText();
cached_meta_data = main_script_loader_->ReleaseCachedMetadata(); cached_meta_data = main_script_loader_->ReleaseCachedMetadata();
main_script_loader_ = nullptr; main_script_loader_ = nullptr;
...@@ -472,12 +471,15 @@ void WebEmbeddedWorkerImpl::StartWorkerThread() { ...@@ -472,12 +471,15 @@ void WebEmbeddedWorkerImpl::StartWorkerThread() {
worker_start_data_.user_agent, std::move(web_worker_fetch_context), worker_start_data_.user_agent, std::move(web_worker_fetch_context),
Vector<CSPHeaderAndType>(), network::mojom::ReferrerPolicy::kDefault, Vector<CSPHeaderAndType>(), network::mojom::ReferrerPolicy::kDefault,
starter_origin.get(), starter_secure_context, starter_https_state, starter_origin.get(), starter_secure_context, starter_https_state,
worker_clients, base::nullopt /* response_address_space */, worker_clients, std::move(content_settings_client_),
base::nullopt /* response_address_space */,
nullptr /* OriginTrialTokens */, devtools_worker_token_, nullptr /* OriginTrialTokens */, devtools_worker_token_,
std::move(worker_settings), std::move(worker_settings),
static_cast<V8CacheOptions>(worker_start_data_.v8_cache_options), static_cast<V8CacheOptions>(worker_start_data_.v8_cache_options),
nullptr /* worklet_module_respones_map */, nullptr /* worklet_module_respones_map */,
std::move(interface_provider_info_)); std::move(interface_provider_info_), BeginFrameProviderParams(),
nullptr /* parent_feature_policy */,
base::UnguessableToken() /* agent_cluster_id */);
} }
// Generate the full code cache in the first execution of the script. // Generate the full code cache in the first execution of the script.
......
...@@ -37,7 +37,6 @@ ...@@ -37,7 +37,6 @@
#include "third_party/blink/public/platform/web_content_settings_client.h" #include "third_party/blink/public/platform/web_content_settings_client.h"
#include "third_party/blink/renderer/core/dom/document.h" #include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/frame/local_frame.h" #include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/workers/worker_content_settings_client.h"
#include "third_party/blink/renderer/core/workers/worker_global_scope.h" #include "third_party/blink/renderer/core/workers/worker_global_scope.h"
#include "third_party/blink/renderer/platform/weborigin/security_origin.h" #include "third_party/blink/renderer/platform/weborigin/security_origin.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
...@@ -55,8 +54,11 @@ bool LocalFileSystemClient::RequestFileSystemAccessSync( ...@@ -55,8 +54,11 @@ bool LocalFileSystemClient::RequestFileSystemAccessSync(
return false; return false;
} }
return WorkerContentSettingsClient::From(*To<WorkerGlobalScope>(context)) WebContentSettingsClient* content_settings_client =
->RequestFileSystemAccessSync(); To<WorkerGlobalScope>(context)->ContentSettingsClient();
if (!content_settings_client)
return true;
return content_settings_client->RequestFileSystemAccessSync();
} }
void LocalFileSystemClient::RequestFileSystemAccessAsync( void LocalFileSystemClient::RequestFileSystemAccessAsync(
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include "third_party/blink/renderer/core/execution_context/execution_context.h" #include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/frame/local_frame.h" #include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/workers/worker_clients.h" #include "third_party/blink/renderer/core/workers/worker_clients.h"
#include "third_party/blink/renderer/core/workers/worker_content_settings_client.h"
#include "third_party/blink/renderer/core/workers/worker_global_scope.h" #include "third_party/blink/renderer/core/workers/worker_global_scope.h"
#include "third_party/blink/renderer/platform/weborigin/security_origin.h" #include "third_party/blink/renderer/platform/weborigin/security_origin.h"
...@@ -48,9 +47,11 @@ bool IndexedDBClient::AllowIndexedDB(ExecutionContext* context) { ...@@ -48,9 +47,11 @@ bool IndexedDBClient::AllowIndexedDB(ExecutionContext* context) {
return true; return true;
} }
WorkerGlobalScope& worker_global_scope = *To<WorkerGlobalScope>(context); WebContentSettingsClient* content_settings_client =
return WorkerContentSettingsClient::From(worker_global_scope) To<WorkerGlobalScope>(context)->ContentSettingsClient();
->AllowIndexedDB(); if (!content_settings_client)
return true;
return content_settings_client->AllowIndexedDB(WebSecurityOrigin());
} }
// static // static
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
#include "third_party/blink/renderer/core/page/chrome_client.h" #include "third_party/blink/renderer/core/page/chrome_client.h"
#include "third_party/blink/renderer/core/page/page.h" #include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/core/workers/worker_clients.h" #include "third_party/blink/renderer/core/workers/worker_clients.h"
#include "third_party/blink/renderer/core/workers/worker_content_settings_client.h"
#include "third_party/blink/renderer/modules/accessibility/ax_object_cache_impl.h" #include "third_party/blink/renderer/modules/accessibility/ax_object_cache_impl.h"
#include "third_party/blink/renderer/modules/accessibility/inspector_accessibility_agent.h" #include "third_party/blink/renderer/modules/accessibility/inspector_accessibility_agent.h"
#include "third_party/blink/renderer/modules/app_banner/app_banner_controller.h" #include "third_party/blink/renderer/modules/app_banner/app_banner_controller.h"
......
...@@ -73,7 +73,7 @@ class AudioWorkletGlobalScopeTest : public PageTestBase { ...@@ -73,7 +73,7 @@ class AudioWorkletGlobalScopeTest : public PageTestBase {
Vector<CSPHeaderAndType>(), document->GetReferrerPolicy(), Vector<CSPHeaderAndType>(), document->GetReferrerPolicy(),
document->GetSecurityOrigin(), document->IsSecureContext(), document->GetSecurityOrigin(), document->IsSecureContext(),
document->GetHttpsState(), nullptr /* worker_clients */, document->GetHttpsState(), nullptr /* worker_clients */,
document->AddressSpace(), nullptr /* content_settings_client */, document->AddressSpace(),
OriginTrialContext::GetTokens(document).get(), OriginTrialContext::GetTokens(document).get(),
base::UnguessableToken::Create(), nullptr /* worker_settings */, base::UnguessableToken::Create(), nullptr /* worker_settings */,
kV8CacheOptionsDefault, kV8CacheOptionsDefault,
......
...@@ -55,7 +55,7 @@ class AudioWorkletThreadTest : public PageTestBase { ...@@ -55,7 +55,7 @@ class AudioWorkletThreadTest : public PageTestBase {
Vector<CSPHeaderAndType>(), document->GetReferrerPolicy(), Vector<CSPHeaderAndType>(), document->GetReferrerPolicy(),
document->GetSecurityOrigin(), document->IsSecureContext(), document->GetSecurityOrigin(), document->IsSecureContext(),
document->GetHttpsState(), nullptr /* worker_clients */, document->GetHttpsState(), nullptr /* worker_clients */,
document->AddressSpace(), nullptr /* content_settings_client */, document->AddressSpace(),
OriginTrialContext::GetTokens(document).get(), OriginTrialContext::GetTokens(document).get(),
base::UnguessableToken::Create(), nullptr /* worker_settings */, base::UnguessableToken::Create(), nullptr /* worker_settings */,
kV8CacheOptionsDefault, kV8CacheOptionsDefault,
......
...@@ -33,7 +33,8 @@ CreateAnimationAndPaintWorkletThread( ...@@ -33,7 +33,8 @@ CreateAnimationAndPaintWorkletThread(
document->UserAgent(), nullptr /* web_worker_fetch_context */, document->UserAgent(), nullptr /* web_worker_fetch_context */,
Vector<CSPHeaderAndType>(), document->GetReferrerPolicy(), Vector<CSPHeaderAndType>(), document->GetReferrerPolicy(),
document->GetSecurityOrigin(), document->IsSecureContext(), document->GetSecurityOrigin(), document->IsSecureContext(),
document->GetHttpsState(), clients, document->AddressSpace(), document->GetHttpsState(), clients,
nullptr /* content_settings_client */, document->AddressSpace(),
OriginTrialContext::GetTokens(document).get(), OriginTrialContext::GetTokens(document).get(),
base::UnguessableToken::Create(), nullptr /* worker_settings */, base::UnguessableToken::Create(), nullptr /* worker_settings */,
kV8CacheOptionsDefault, kV8CacheOptionsDefault,
......
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