Commit f2e77cb5 authored by Ehsan Karamad's avatar Ehsan Karamad Committed by Commit Bot

[ refactor ] Remove alias SandboxFlag(s) from core/

The actual data type was removed in https://crrev.com/c/1555075. This CL removes
the aliases SandboxFlag and SandboxFlags and uses WebSandboxFlags everywhere.

This is purely mechanical and should not change any code behavior.

TBR=haraken@chromium.org

Bug: None
Change-Id: Ia8f43ecbd4508ff2da2b8883e0f52f0de412bba9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1565180Reviewed-by: default avatarEhsan Karamad <ekaramad@chromium.org>
Commit-Queue: Ehsan Karamad <ekaramad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#650533}
parent 5e033130
......@@ -1098,7 +1098,7 @@ class CORE_EXPORT Document : public ContainerNode,
const String& context_url,
const WTF::OrdinalNumber& context_line);
void EnforceSandboxFlags(SandboxFlags mask) override;
void EnforceSandboxFlags(WebSandboxFlags mask) override;
void StatePopped(scoped_refptr<SerializedScriptValue>);
......
......@@ -93,10 +93,10 @@ DocumentLoader* DocumentInit::MasterDocumentLoader() const {
return nullptr;
}
SandboxFlags DocumentInit::GetSandboxFlags() const {
WebSandboxFlags DocumentInit::GetSandboxFlags() const {
DCHECK(MasterDocumentLoader());
DocumentLoader* loader = MasterDocumentLoader();
SandboxFlags flags = loader->GetFrame()->Loader().EffectiveSandboxFlags();
WebSandboxFlags flags = loader->GetFrame()->Loader().EffectiveSandboxFlags();
// If the load was blocked by CSP, force the Document's origin to be unique,
// so that the blocked document appears to be a normal cross-origin document's
......
......@@ -74,7 +74,7 @@ class CORE_EXPORT DocumentInit final {
bool HasSecurityContext() const { return MasterDocumentLoader(); }
bool IsSrcdocDocument() const;
bool ShouldSetURL() const;
SandboxFlags GetSandboxFlags() const;
WebSandboxFlags GetSandboxFlags() const;
bool IsHostedInReservedIPRange() const;
WebInsecureRequestPolicy GetInsecureRequestPolicy() const;
SecurityContext::InsecureNavigationsSet* InsecureNavigationsToUpgrade() const;
......
......@@ -90,9 +90,9 @@ class CORE_EXPORT SecurityContext : public GarbageCollectedMixin {
void SetSecurityOrigin(scoped_refptr<SecurityOrigin>);
virtual void DidUpdateSecurityOrigin() = 0;
SandboxFlags GetSandboxFlags() const { return sandbox_flags_; }
bool IsSandboxed(SandboxFlag mask) const;
virtual void EnforceSandboxFlags(SandboxFlags mask);
WebSandboxFlags GetSandboxFlags() const { return sandbox_flags_; }
bool IsSandboxed(WebSandboxFlags mask) const;
virtual void EnforceSandboxFlags(WebSandboxFlags mask);
void SetAddressSpace(mojom::IPAddressSpace space) { address_space_ = space; }
mojom::IPAddressSpace AddressSpace() const { return address_space_; }
......@@ -181,7 +181,7 @@ class CORE_EXPORT SecurityContext : public GarbageCollectedMixin {
// Apply the sandbox flag. In addition, if the origin is not already opaque,
// the origin is updated to a newly created unique opaque origin, setting the
// potentially trustworthy bit from |is_potentially_trustworthy|.
void ApplySandboxFlags(SandboxFlags mask,
void ApplySandboxFlags(WebSandboxFlags mask,
bool is_potentially_trustworthy = false);
protected:
......@@ -195,7 +195,7 @@ class CORE_EXPORT SecurityContext : public GarbageCollectedMixin {
// default value ignoring container, header, and inherited policies.
virtual bool HasCustomizedFeaturePolicy() const { return true; }
SandboxFlags sandbox_flags_;
WebSandboxFlags sandbox_flags_;
private:
scoped_refptr<SecurityOrigin> security_origin_;
......
......@@ -939,7 +939,7 @@ void LocalFrameClientImpl::DidChangeFramePolicy(
}
void LocalFrameClientImpl::DidSetFramePolicyHeaders(
SandboxFlags sandbox_flags,
WebSandboxFlags sandbox_flags,
const ParsedFeaturePolicy& parsed_header) {
if (web_frame_->Client()) {
web_frame_->Client()->DidSetFramePolicyHeaders(
......
......@@ -208,7 +208,7 @@ class LocalFrameClientImpl final : public LocalFrameClient {
void DidEnforceInsecureNavigationsSet(const std::vector<unsigned>&) override;
void DidChangeFramePolicy(Frame* child_frame, const FramePolicy&) override;
void DidSetFramePolicyHeaders(
SandboxFlags,
WebSandboxFlags,
const ParsedFeaturePolicy& parsed_header) override;
void DidAddContentSecurityPolicies(
const blink::WebVector<WebContentSecurityPolicy>&) override;
......
......@@ -345,7 +345,7 @@ class CORE_EXPORT LocalFrameClient : public FrameClient {
virtual void DidChangeFramePolicy(Frame* child_frame, const FramePolicy&) {}
virtual void DidSetFramePolicyHeaders(
SandboxFlags,
WebSandboxFlags,
const ParsedFeaturePolicy& parsed_header) {}
// Called when a set of new Content Security Policies is added to the frame's
......
......@@ -41,7 +41,7 @@ namespace blink {
// FeaturePolicies that implement them. Eventually almost all sandbox flags
// should be converted to feature policies (https://crbug.com/812381).
using SandboxFlagFeaturePolicyPairs =
Vector<std::pair<SandboxFlags, mojom::FeaturePolicyFeature>>;
Vector<std::pair<WebSandboxFlags, mojom::FeaturePolicyFeature>>;
const SandboxFlagFeaturePolicyPairs& SandboxFlagsWithFeaturePolicies() {
DEFINE_STATIC_LOCAL(
SandboxFlagFeaturePolicyPairs, array,
......@@ -64,8 +64,8 @@ const SandboxFlagFeaturePolicyPairs& SandboxFlagsWithFeaturePolicies() {
// corresponding feature policies. With FeaturePolicyForSandbox, these flags
// are always removed from the set of sandbox flags set for a sandboxed
// <iframe> (those sandbox flags are now contained in the |ContainerPolicy|).
SandboxFlags SandboxFlagsImplementedByFeaturePolicy() {
DEFINE_STATIC_LOCAL(SandboxFlags, mask, (WebSandboxFlags::kNone));
WebSandboxFlags SandboxFlagsImplementedByFeaturePolicy() {
DEFINE_STATIC_LOCAL(WebSandboxFlags, mask, (WebSandboxFlags::kNone));
if (mask == WebSandboxFlags::kNone) {
for (const auto& pair : SandboxFlagsWithFeaturePolicies())
mask |= pair.first;
......@@ -73,11 +73,11 @@ SandboxFlags SandboxFlagsImplementedByFeaturePolicy() {
return mask;
}
SandboxFlags ParseSandboxPolicy(const SpaceSplitString& policy,
String& invalid_tokens_error_message) {
WebSandboxFlags ParseSandboxPolicy(const SpaceSplitString& policy,
String& invalid_tokens_error_message) {
// http://www.w3.org/TR/html5/the-iframe-element.html#attr-iframe-sandbox
// Parse the unordered set of unique space-separated tokens.
SandboxFlags flags = WebSandboxFlags::kAll;
WebSandboxFlags flags = WebSandboxFlags::kAll;
unsigned length = policy.size();
unsigned number_of_token_errors = 0;
StringBuilder token_errors;
......@@ -134,14 +134,14 @@ SandboxFlags ParseSandboxPolicy(const SpaceSplitString& policy,
// Removes a certain set of flags from |sandbox_flags| for which we have feature
// policies implemented.
SandboxFlags GetSandboxFlagsNotImplementedAsFeaturePolicy(
SandboxFlags sandbox_flags) {
WebSandboxFlags GetSandboxFlagsNotImplementedAsFeaturePolicy(
WebSandboxFlags sandbox_flags) {
// Punch all the sandbox flags which are converted to feature policy.
return sandbox_flags & ~SandboxFlagsImplementedByFeaturePolicy();
}
void ApplySandboxFlagsToParsedFeaturePolicy(
SandboxFlags sandbox_flags,
WebSandboxFlags sandbox_flags,
ParsedFeaturePolicy& parsed_feature_policy) {
for (const auto& pair : SandboxFlagsWithFeaturePolicies()) {
if ((sandbox_flags & pair.first) != WebSandboxFlags::kNone)
......
......@@ -36,22 +36,19 @@
namespace blink {
// TODO(ekaramad): Get rid of these.
using SandboxFlag = WebSandboxFlags;
using SandboxFlags = WebSandboxFlags;
SandboxFlags ParseSandboxPolicy(const SpaceSplitString& policy,
String& invalid_tokens_error_message);
WebSandboxFlags ParseSandboxPolicy(const SpaceSplitString& policy,
String& invalid_tokens_error_message);
// With FeaturePolicyForSandbox most sandbox flags will be represented with
// features. This method returns the part of sandbox flags which were not mapped
// to corresponding features.
SandboxFlags GetSandboxFlagsNotImplementedAsFeaturePolicy(SandboxFlags);
WebSandboxFlags GetSandboxFlagsNotImplementedAsFeaturePolicy(WebSandboxFlags);
// Applies the sandbox flags as parsed feature policies; If a flag is present
// both in the provided flags and in the parsed feature as a feature policy,
// the parsed policy takes precedence.
void ApplySandboxFlagsToParsedFeaturePolicy(SandboxFlags, ParsedFeaturePolicy&);
void ApplySandboxFlagsToParsedFeaturePolicy(WebSandboxFlags,
ParsedFeaturePolicy&);
} // namespace blink
......
......@@ -244,7 +244,7 @@ DOMWindow* HTMLFrameOwnerElement::contentWindow() const {
return content_frame_ ? content_frame_->DomWindow() : nullptr;
}
void HTMLFrameOwnerElement::SetSandboxFlags(SandboxFlags flags) {
void HTMLFrameOwnerElement::SetSandboxFlags(WebSandboxFlags flags) {
frame_policy_.sandbox_flags = flags;
// Recalculate the container policy in case the allow-same-origin flag has
// changed.
......
......@@ -133,7 +133,7 @@ class CORE_EXPORT HTMLFrameOwnerElement : public HTMLElement,
protected:
HTMLFrameOwnerElement(const QualifiedName& tag_name, Document&);
void SetSandboxFlags(SandboxFlags);
void SetSandboxFlags(WebSandboxFlags);
bool LoadOrRedirectSubframe(const KURL&,
const AtomicString& frame_name,
......
......@@ -150,7 +150,7 @@ void HTMLIFrameElement::ParseAttribute(
String invalid_tokens;
bool feature_policy_for_sandbox =
RuntimeEnabledFeatures::FeaturePolicyForSandboxEnabled();
SandboxFlags current_flags =
WebSandboxFlags current_flags =
value.IsNull()
? WebSandboxFlags::kNone
: ParseSandboxPolicy(sandbox_->TokenSet(), invalid_tokens);
......@@ -158,7 +158,7 @@ void HTMLIFrameElement::ParseAttribute(
// the container policies. However, not all sandbox flags are yet converted
// and for now the residue will stay around in the stored flags.
// (see https://crbug.com/812381).
SandboxFlags sandbox_to_set = current_flags;
WebSandboxFlags sandbox_to_set = current_flags;
sandbox_flags_converted_to_feature_policies_ = WebSandboxFlags::kNone;
if (feature_policy_for_sandbox && current_flags != WebSandboxFlags::kNone) {
// The part of sandbox which will be mapped to feature policies.
......
......@@ -97,7 +97,7 @@ class CORE_EXPORT HTMLIFrameElement final
// This represents a subset of sandbox flags set through 'sandbox' attribute
// that will be converted to feature policies as part of the container
// policies.
SandboxFlags sandbox_flags_converted_to_feature_policies_ =
WebSandboxFlags sandbox_flags_converted_to_feature_policies_ =
WebSandboxFlags::kNone;
network::mojom::ReferrerPolicy referrer_policy_;
......
......@@ -135,7 +135,7 @@ class CORE_EXPORT EmptyChromeClient : public ChromeClient {
Page* CreateWindowDelegate(LocalFrame*,
const FrameLoadRequest&,
const WebWindowFeatures&,
SandboxFlags,
WebSandboxFlags,
const FeaturePolicy::FeatureState&,
const SessionStorageNamespaceId&) override {
return nullptr;
......
......@@ -166,8 +166,10 @@ class CORE_EXPORT FrameLoader final {
// The following sandbox flags will be forced, regardless of changes to the
// sandbox attribute of any parent frames.
void ForceSandboxFlags(SandboxFlags flags) { forced_sandbox_flags_ |= flags; }
SandboxFlags EffectiveSandboxFlags() const;
void ForceSandboxFlags(WebSandboxFlags flags) {
forced_sandbox_flags_ |= flags;
}
WebSandboxFlags EffectiveSandboxFlags() const;
void ModifyRequestForCSP(ResourceRequest&,
Document*,
......@@ -294,7 +296,7 @@ class CORE_EXPORT FrameLoader final {
bool in_restore_scroll_;
SandboxFlags forced_sandbox_flags_;
WebSandboxFlags forced_sandbox_flags_;
bool dispatching_did_clear_window_object_in_main_world_;
bool detached_;
......
......@@ -103,7 +103,7 @@ Page* ChromeClient::CreateWindow(
LocalFrame* frame,
const FrameLoadRequest& r,
const WebWindowFeatures& features,
SandboxFlags sandbox_flags,
WebSandboxFlags sandbox_flags,
const FeaturePolicy::FeatureState& opener_feature_state,
const SessionStorageNamespaceId& session_storage_namespace_id) {
if (!CanOpenUIElementIfDuringPageDismissal(
......
......@@ -160,7 +160,7 @@ class CORE_EXPORT ChromeClient
Page* CreateWindow(LocalFrame*,
const FrameLoadRequest&,
const WebWindowFeatures&,
SandboxFlags,
WebSandboxFlags,
const FeaturePolicy::FeatureState&,
const SessionStorageNamespaceId&);
virtual void Show(NavigationPolicy) = 0;
......@@ -424,7 +424,7 @@ class CORE_EXPORT ChromeClient
virtual Page* CreateWindowDelegate(LocalFrame*,
const FrameLoadRequest&,
const WebWindowFeatures&,
SandboxFlags,
WebSandboxFlags,
const FeaturePolicy::FeatureState&,
const SessionStorageNamespaceId&) = 0;
......
......@@ -252,7 +252,7 @@ Page* ChromeClientImpl::CreateWindowDelegate(
LocalFrame* frame,
const FrameLoadRequest& r,
const WebWindowFeatures& features,
SandboxFlags sandbox_flags,
WebSandboxFlags sandbox_flags,
const FeaturePolicy::FeatureState& opener_feature_state,
const SessionStorageNamespaceId& session_storage_namespace_id) {
if (!web_view_->Client())
......
......@@ -80,7 +80,7 @@ class CORE_EXPORT ChromeClientImpl final : public ChromeClient {
Page* CreateWindowDelegate(LocalFrame*,
const FrameLoadRequest&,
const WebWindowFeatures&,
SandboxFlags,
WebSandboxFlags,
const FeaturePolicy::FeatureState&,
const SessionStorageNamespaceId&) override;
void Show(NavigationPolicy) override;
......
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