Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(940)

Unified Diff: content/common/content_security_policy/csp_context.cc

Issue 2937503002: CSP, PlzNavigate: make clear what happens with unique origins. (Closed)
Patch Set: Add web platform tests. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
« no previous file with comments | « content/common/content_security_policy/csp_context.h ('k') | content/common/content_security_policy/csp_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698