| Index: content/common/content_security_policy/csp_context.cc
|
| diff --git a/content/common/content_security_policy/csp_context.cc b/content/common/content_security_policy/csp_context.cc
|
| index 7d3aebef25f725802028d35f7523ead03853c05d..4fd6b8a24e1befe71d148aeec473f16a65a4b776 100644
|
| --- a/content/common/content_security_policy/csp_context.cc
|
| +++ b/content/common/content_security_policy/csp_context.cc
|
| @@ -26,8 +26,7 @@ bool ShouldCheckPolicy(const ContentSecurityPolicy& policy,
|
|
|
| } // namespace
|
|
|
| -CSPContext::CSPContext() : has_self_(false) {}
|
| -
|
| +CSPContext::CSPContext() {}
|
| CSPContext::~CSPContext() {}
|
|
|
| bool CSPContext::IsAllowedByCsp(CSPDirective::Name directive_name,
|
| @@ -69,40 +68,24 @@ bool CSPContext::ShouldModifyRequestUrlForCsp(
|
| }
|
|
|
| void CSPContext::SetSelf(const url::Origin origin) {
|
| - if (origin.unique()) {
|
| - // TODO(arthursonzogni): Decide what to do with unique origins.
|
| - has_self_ = false;
|
| + self_source_.reset();
|
| +
|
| + // When the origin is unique, no URL should match with 'self'. That's why
|
| + // |self_source_| stays undefined here.
|
| + if (origin.unique())
|
| return;
|
| - }
|
|
|
| if (origin.scheme() == url::kFileScheme) {
|
| - has_self_ = true;
|
| - self_scheme_ = url::kFileScheme;
|
| self_source_ = CSPSource(url::kFileScheme, "", false, url::PORT_UNSPECIFIED,
|
| false, "");
|
| return;
|
| }
|
|
|
| - has_self_ = true;
|
| - self_scheme_ = origin.scheme();
|
| self_source_ = CSPSource(
|
| origin.scheme(), origin.host(), false,
|
| - origin.port() == 0 ? url::PORT_UNSPECIFIED : origin.port(), // port
|
| - false, "");
|
| -}
|
| -
|
| -bool CSPContext::AllowSelf(const GURL& url) {
|
| - return has_self_ && CSPSource::Allow(self_source_, url, this);
|
| -}
|
| -
|
| -bool CSPContext::ProtocolIsSelf(const GURL& url) {
|
| - if (!has_self_)
|
| - return false;
|
| - return url.SchemeIs(self_scheme_);
|
| -}
|
| + origin.port() == 0 ? url::PORT_UNSPECIFIED : origin.port(), false, "");
|
|
|
| -const std::string& CSPContext::GetSelfScheme() {
|
| - return self_scheme_;
|
| + DCHECK_NE("", self_source_->scheme);
|
| }
|
|
|
| bool CSPContext::SchemeShouldBypassCSP(const base::StringPiece& scheme) {
|
| @@ -117,12 +100,6 @@ void CSPContext::SanitizeDataForUseInCspViolation(
|
| return;
|
| }
|
|
|
| -bool CSPContext::SelfSchemeShouldBypassCsp() {
|
| - if (!has_self_)
|
| - return false;
|
| - return SchemeShouldBypassCSP(self_scheme_);
|
| -}
|
| -
|
| void CSPContext::ReportContentSecurityPolicyViolation(
|
| const CSPViolationParams& violation_params) {
|
| return;
|
|
|