Commit e2de0f9a authored by Hiroshige Hayashizaki's avatar Hiroshige Hayashizaki Committed by Commit Bot

Implement FetchClientSettingsObject::GetHttpsState()

Previously, FetchClientSettingsObjectImpl
- Is used as WorkerFetchContext's FetchClientSettingsObject,
- Implements GetHttpsState(), and
- Is used for checking mixed contents on workers.

Issue 880027 will introduce outsideSettings WorkerFetchContext
which will have FetchClientSettingsObjectSnapshot as its
FetchClientSettingsObject [1].

Therefore, this CL switches
- WorkerFetchContext's FetchClientSettingsObject and
- MixedContentChecker::IsMixedContent()
to use FetchClientSettingsObject (not ...Impl), and
implements GetHttpsState() in FetchClientSettingsObject
and FetchClientSettingsObjectSnapshot.

This CL shouldn't change the behavior at this time, because
WorkerFetchContext's FetchClientSettingsObject is still
a FetchClientSettingsObjectImpl object, and thus mixed content
checks is done using already-implemented
FetchClientSettingsObjectImpl::GetHttpsState().

The code path added in this CL will be used in [2].

[1] https://chromium-review.googlesource.com/1328043
[2] https://chromium-review.googlesource.com/1328164

Bug: 880027
Change-Id: I399694bd239c21fe9b5a650fcb689fb2c98572f5
Reviewed-on: https://chromium-review.googlesource.com/c/1328162Reviewed-by: default avatarHiroki Nakagawa <nhiroki@chromium.org>
Reviewed-by: default avatarMike West <mkwst@chromium.org>
Reviewed-by: default avatarYutaka Hirano <yhirano@chromium.org>
Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org>
Cr-Commit-Position: refs/heads/master@{#607860}
parent 16196123
...@@ -204,7 +204,8 @@ String ExecutionContext::OutgoingReferrer() const { ...@@ -204,7 +204,8 @@ String ExecutionContext::OutgoingReferrer() const {
FetchClientSettingsObjectSnapshot* FetchClientSettingsObjectSnapshot*
ExecutionContext::CreateFetchClientSettingsObjectSnapshot() { ExecutionContext::CreateFetchClientSettingsObjectSnapshot() {
return new FetchClientSettingsObjectSnapshot( return new FetchClientSettingsObjectSnapshot(
BaseURL(), GetSecurityOrigin(), GetReferrerPolicy(), OutgoingReferrer()); BaseURL(), GetSecurityOrigin(), GetReferrerPolicy(), OutgoingReferrer(),
GetHttpsState());
} }
void ExecutionContext::ParseAndSetReferrerPolicy(const String& policies, void ExecutionContext::ParseAndSetReferrerPolicy(const String& policies,
......
...@@ -1451,7 +1451,8 @@ FetchContext* FrameFetchContext::Detach() { ...@@ -1451,7 +1451,8 @@ FetchContext* FrameFetchContext::Detach() {
GetClientHintsPreferences(), GetDevicePixelRatio(), GetUserAgent(), GetClientHintsPreferences(), GetDevicePixelRatio(), GetUserAgent(),
IsMainFrame(), IsSVGImageChromeClient()); IsMainFrame(), IsSVGImageChromeClient());
fetch_client_settings_object_ = new FetchClientSettingsObjectSnapshot( fetch_client_settings_object_ = new FetchClientSettingsObjectSnapshot(
NullURL(), nullptr, kReferrerPolicyDefault, String()); NullURL(), nullptr, kReferrerPolicyDefault, String(),
HttpsState::kNone);
} }
// This is needed to break a reference cycle in which off-heap // This is needed to break a reference cycle in which off-heap
......
...@@ -231,7 +231,7 @@ bool MixedContentChecker::IsMixedContent(const SecurityOrigin* security_origin, ...@@ -231,7 +231,7 @@ bool MixedContentChecker::IsMixedContent(const SecurityOrigin* security_origin,
// static // static
bool MixedContentChecker::IsMixedContent( bool MixedContentChecker::IsMixedContent(
const FetchClientSettingsObjectImpl& settings, const FetchClientSettingsObject& settings,
const KURL& url) { const KURL& url) {
switch (settings.GetHttpsState()) { switch (settings.GetHttpsState()) {
case HttpsState::kNone: case HttpsState::kNone:
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
namespace blink { namespace blink {
class ConsoleMessage; class ConsoleMessage;
class FetchClientSettingsObjectImpl; class FetchClientSettingsObject;
class Frame; class Frame;
class FrameFetchContext; class FrameFetchContext;
class LocalFrame; class LocalFrame;
...@@ -87,7 +87,7 @@ class CORE_EXPORT MixedContentChecker final { ...@@ -87,7 +87,7 @@ class CORE_EXPORT MixedContentChecker final {
static bool IsWebSocketAllowed(const WorkerFetchContext&, const KURL&); static bool IsWebSocketAllowed(const WorkerFetchContext&, const KURL&);
static bool IsMixedContent(const SecurityOrigin*, const KURL&); static bool IsMixedContent(const SecurityOrigin*, const KURL&);
static bool IsMixedContent(const FetchClientSettingsObjectImpl&, const KURL&); static bool IsMixedContent(const FetchClientSettingsObject&, const KURL&);
static bool IsMixedFormAction(LocalFrame*, static bool IsMixedFormAction(LocalFrame*,
const KURL&, const KURL&,
SecurityViolationReportingPolicy = SecurityViolationReportingPolicy =
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "third_party/blink/renderer/core/loader/mixed_content_checker.h" #include "third_party/blink/renderer/core/loader/mixed_content_checker.h"
#include "third_party/blink/renderer/core/loader/subresource_filter.h" #include "third_party/blink/renderer/core/loader/subresource_filter.h"
#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/script/fetch_client_settings_object_impl.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_content_settings_client.h"
...@@ -60,7 +61,7 @@ WorkerFetchContext::WorkerFetchContext( ...@@ -60,7 +61,7 @@ WorkerFetchContext::WorkerFetchContext(
DCHECK(web_context_); DCHECK(web_context_);
} }
const FetchClientSettingsObjectImpl* const FetchClientSettingsObject*
WorkerFetchContext::GetFetchClientSettingsObject() const { WorkerFetchContext::GetFetchClientSettingsObject() const {
return fetch_client_settings_object_.Get(); return fetch_client_settings_object_.Get();
} }
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include "third_party/blink/public/mojom/service_worker/service_worker_object.mojom-blink.h" #include "third_party/blink/public/mojom/service_worker/service_worker_object.mojom-blink.h"
#include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/loader/base_fetch_context.h" #include "third_party/blink/renderer/core/loader/base_fetch_context.h"
#include "third_party/blink/renderer/core/script/fetch_client_settings_object_impl.h"
#include "third_party/blink/renderer/platform/wtf/forward.h" #include "third_party/blink/renderer/platform/wtf/forward.h"
namespace blink { namespace blink {
...@@ -35,7 +34,7 @@ class WorkerFetchContext final : public BaseFetchContext { ...@@ -35,7 +34,7 @@ class WorkerFetchContext final : public BaseFetchContext {
~WorkerFetchContext() override; ~WorkerFetchContext() override;
// BaseFetchContext implementation: // BaseFetchContext implementation:
const FetchClientSettingsObjectImpl* GetFetchClientSettingsObject() const FetchClientSettingsObject* GetFetchClientSettingsObject()
const override; const override;
KURL GetSiteForCookies() const override; KURL GetSiteForCookies() const override;
SubresourceFilter* GetSubresourceFilter() const override; SubresourceFilter* GetSubresourceFilter() const override;
...@@ -138,7 +137,7 @@ class WorkerFetchContext final : public BaseFetchContext { ...@@ -138,7 +137,7 @@ class WorkerFetchContext final : public BaseFetchContext {
const scoped_refptr<WebWorkerFetchContext> web_context_; const scoped_refptr<WebWorkerFetchContext> web_context_;
Member<SubresourceFilter> subresource_filter_; Member<SubresourceFilter> subresource_filter_;
const Member<FetchClientSettingsObjectImpl> fetch_client_settings_object_; const Member<FetchClientSettingsObject> fetch_client_settings_object_;
// The value of |save_data_enabled_| is read once per frame from // The value of |save_data_enabled_| is read once per frame from
// NetworkStateNotifier, which is guarded by a mutex lock, and cached locally // NetworkStateNotifier, which is guarded by a mutex lock, and cached locally
......
...@@ -36,7 +36,7 @@ class CORE_EXPORT FetchClientSettingsObjectImpl final ...@@ -36,7 +36,7 @@ class CORE_EXPORT FetchClientSettingsObjectImpl final
ReferrerPolicy GetReferrerPolicy() const override; ReferrerPolicy GetReferrerPolicy() const override;
const String GetOutgoingReferrer() const override; const String GetOutgoingReferrer() const override;
HttpsState GetHttpsState() const; HttpsState GetHttpsState() const override;
void Trace(Visitor* visitor) override; void Trace(Visitor* visitor) override;
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "third_party/blink/renderer/platform/cross_thread_copier.h" #include "third_party/blink/renderer/platform/cross_thread_copier.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h" #include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/heap/heap.h" #include "third_party/blink/renderer/platform/heap/heap.h"
#include "third_party/blink/renderer/platform/loader/fetch/https_state.h"
#include "third_party/blink/renderer/platform/platform_export.h" #include "third_party/blink/renderer/platform/platform_export.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/weborigin/referrer_policy.h" #include "third_party/blink/renderer/platform/weborigin/referrer_policy.h"
...@@ -47,6 +48,9 @@ class PLATFORM_EXPORT FetchClientSettingsObject ...@@ -47,6 +48,9 @@ class PLATFORM_EXPORT FetchClientSettingsObject
// https://w3c.github.io/webappsec-referrer-policy/#determine-requests-referrer // https://w3c.github.io/webappsec-referrer-policy/#determine-requests-referrer
virtual const String GetOutgoingReferrer() const = 0; virtual const String GetOutgoingReferrer() const = 0;
// https://html.spec.whatwg.org/multipage/webappapis.html#https-state
virtual HttpsState GetHttpsState() const = 0;
virtual void Trace(Visitor*) {} virtual void Trace(Visitor*) {}
}; };
......
...@@ -13,16 +13,19 @@ FetchClientSettingsObjectSnapshot::FetchClientSettingsObjectSnapshot( ...@@ -13,16 +13,19 @@ FetchClientSettingsObjectSnapshot::FetchClientSettingsObjectSnapshot(
: FetchClientSettingsObjectSnapshot(data->base_url, : FetchClientSettingsObjectSnapshot(data->base_url,
data->security_origin, data->security_origin,
data->referrer_policy, data->referrer_policy,
data->outgoing_referrer) {} data->outgoing_referrer,
data->https_state) {}
FetchClientSettingsObjectSnapshot::FetchClientSettingsObjectSnapshot( FetchClientSettingsObjectSnapshot::FetchClientSettingsObjectSnapshot(
const KURL& base_url, const KURL& base_url,
const scoped_refptr<const SecurityOrigin> security_origin, const scoped_refptr<const SecurityOrigin> security_origin,
ReferrerPolicy referrer_policy, ReferrerPolicy referrer_policy,
const String& outgoing_referrer) const String& outgoing_referrer,
HttpsState https_state)
: base_url_(base_url), : base_url_(base_url),
security_origin_(std::move(security_origin)), security_origin_(std::move(security_origin)),
referrer_policy_(referrer_policy), referrer_policy_(referrer_policy),
outgoing_referrer_(outgoing_referrer) {} outgoing_referrer_(outgoing_referrer),
https_state_(https_state) {}
} // namespace blink } // namespace blink
...@@ -31,16 +31,19 @@ struct CrossThreadFetchClientSettingsObjectData { ...@@ -31,16 +31,19 @@ struct CrossThreadFetchClientSettingsObjectData {
KURL base_url, KURL base_url,
scoped_refptr<const SecurityOrigin> security_origin, scoped_refptr<const SecurityOrigin> security_origin,
ReferrerPolicy referrer_policy, ReferrerPolicy referrer_policy,
String outgoing_referrer) String outgoing_referrer,
HttpsState https_state)
: base_url(std::move(base_url)), : base_url(std::move(base_url)),
security_origin(std::move(security_origin)), security_origin(std::move(security_origin)),
referrer_policy(referrer_policy), referrer_policy(referrer_policy),
outgoing_referrer(std::move(outgoing_referrer)) {} outgoing_referrer(std::move(outgoing_referrer)),
https_state(https_state) {}
KURL base_url; const KURL base_url;
scoped_refptr<const SecurityOrigin> security_origin; const scoped_refptr<const SecurityOrigin> security_origin;
ReferrerPolicy referrer_policy; const ReferrerPolicy referrer_policy;
String outgoing_referrer; const String outgoing_referrer;
const HttpsState https_state;
}; };
// This takes a partial snapshot of the execution context's states so that an // This takes a partial snapshot of the execution context's states so that an
...@@ -62,7 +65,8 @@ class PLATFORM_EXPORT FetchClientSettingsObjectSnapshot final ...@@ -62,7 +65,8 @@ class PLATFORM_EXPORT FetchClientSettingsObjectSnapshot final
const KURL& base_url, const KURL& base_url,
const scoped_refptr<const SecurityOrigin> security_origin, const scoped_refptr<const SecurityOrigin> security_origin,
ReferrerPolicy referrer_policy, ReferrerPolicy referrer_policy,
const String& outgoing_referrer); const String& outgoing_referrer,
HttpsState https_state);
~FetchClientSettingsObjectSnapshot() override = default; ~FetchClientSettingsObjectSnapshot() override = default;
...@@ -74,12 +78,13 @@ class PLATFORM_EXPORT FetchClientSettingsObjectSnapshot final ...@@ -74,12 +78,13 @@ class PLATFORM_EXPORT FetchClientSettingsObjectSnapshot final
const String GetOutgoingReferrer() const override { const String GetOutgoingReferrer() const override {
return outgoing_referrer_; return outgoing_referrer_;
} }
HttpsState GetHttpsState() const override { return https_state_; }
// Gets a copy of the data suitable for passing to another thread. // Gets a copy of the data suitable for passing to another thread.
std::unique_ptr<CrossThreadFetchClientSettingsObjectData> CopyData() const { std::unique_ptr<CrossThreadFetchClientSettingsObjectData> CopyData() const {
return std::make_unique<CrossThreadFetchClientSettingsObjectData>( return std::make_unique<CrossThreadFetchClientSettingsObjectData>(
base_url_.Copy(), security_origin_->IsolatedCopy(), referrer_policy_, base_url_.Copy(), security_origin_->IsolatedCopy(), referrer_policy_,
outgoing_referrer_.IsolatedCopy()); outgoing_referrer_.IsolatedCopy(), https_state_);
} }
private: private:
...@@ -87,6 +92,7 @@ class PLATFORM_EXPORT FetchClientSettingsObjectSnapshot final ...@@ -87,6 +92,7 @@ class PLATFORM_EXPORT FetchClientSettingsObjectSnapshot final
const scoped_refptr<const SecurityOrigin> security_origin_; const scoped_refptr<const SecurityOrigin> security_origin_;
const ReferrerPolicy referrer_policy_; const ReferrerPolicy referrer_policy_;
const String outgoing_referrer_; const String outgoing_referrer_;
const HttpsState https_state_;
}; };
} // namespace blink } // namespace blink
......
...@@ -48,7 +48,8 @@ class NullFetchContext final : public FetchContext { ...@@ -48,7 +48,8 @@ class NullFetchContext final : public FetchContext {
KURL(), KURL(),
nullptr /* security_origin */, nullptr /* security_origin */,
kReferrerPolicyDefault, kReferrerPolicyDefault,
String())) {} String(),
HttpsState::kNone)) {}
const FetchClientSettingsObject* GetFetchClientSettingsObject() const FetchClientSettingsObject* GetFetchClientSettingsObject()
const override { const override {
......
...@@ -56,8 +56,9 @@ class MockFetchContext : public FetchContext { ...@@ -56,8 +56,9 @@ class MockFetchContext : public FetchContext {
const FetchClientSettingsObject* GetFetchClientSettingsObject() const FetchClientSettingsObject* GetFetchClientSettingsObject()
const override { const override {
return new FetchClientSettingsObjectSnapshot( return new FetchClientSettingsObjectSnapshot(KURL(), security_origin_,
KURL(), security_origin_, kReferrerPolicyDefault, String()); kReferrerPolicyDefault,
String(), HttpsState::kNone);
} }
// The last ResourceRequest passed to DispatchWillSendRequest. // The last ResourceRequest passed to DispatchWillSendRequest.
......
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