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

Unified Diff: third_party/WebKit/Source/core/frame/csp/ContentSecurityPolicy.cpp

Issue 2764993002: CSP: group policies in didAddContentSecurityPolicy. (Closed)
Patch Set: Rebase. Created 3 years, 9 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: third_party/WebKit/Source/core/frame/csp/ContentSecurityPolicy.cpp
diff --git a/third_party/WebKit/Source/core/frame/csp/ContentSecurityPolicy.cpp b/third_party/WebKit/Source/core/frame/csp/ContentSecurityPolicy.cpp
index 913ef17e5fcd05b6ab3034ef5588f3a8eda7ce51..da4e0a75325ce6819838e8841bd956d6f80967d5 100644
--- a/third_party/WebKit/Source/core/frame/csp/ContentSecurityPolicy.cpp
+++ b/third_party/WebKit/Source/core/frame/csp/ContentSecurityPolicy.cpp
@@ -324,11 +324,10 @@ void ContentSecurityPolicy::reportAccumulatedHeaders(
// navigation got committed. See comments in
// addAndReportPolicyFromHeaderValue for more details and context.
DCHECK(client);
- for (const auto& policy : m_policies) {
- client->didAddContentSecurityPolicy(
- policy->header(), policy->headerType(), policy->headerSource(),
- {policy->exposeForNavigationalChecks()});
- }
+ WebVector<WebContentSecurityPolicy> policies(m_policies.size());
+ for (size_t i = 0; i < m_policies.size(); ++i)
+ policies[i] = m_policies[i]->exposeForNavigationalChecks();
+ client->didAddContentSecurityPolicies(policies);
}
void ContentSecurityPolicy::addAndReportPolicyFromHeaderValue(
@@ -345,15 +344,15 @@ void ContentSecurityPolicy::addAndReportPolicyFromHeaderValue(
// 2) enforce CSP in the browser process (long-term - see
// https://crbug.com/376522).
// TODO(arthursonzogni): policies are actually replicated (1) and some of
- // them are (or will) be enforced on the browser process (2). Stop doing (1)
- // when (2) is finished.
-
- // Zero, one or several policies could be produced by only one header.
- std::vector<blink::WebContentSecurityPolicy> policies;
- for (size_t i = previousPolicyCount; i < m_policies.size(); ++i)
- policies.push_back(m_policies[i]->exposeForNavigationalChecks());
- document()->frame()->client()->didAddContentSecurityPolicy(
- header, type, source, policies);
+ // them are enforced on the browser process (2). Stop doing (1) when (2) is
+ // finished.
+ WebVector<WebContentSecurityPolicy> policies(m_policies.size() -
+ previousPolicyCount);
+ for (size_t i = previousPolicyCount; i < m_policies.size(); ++i) {
+ policies[i - previousPolicyCount] =
+ m_policies[i]->exposeForNavigationalChecks();
+ }
+ document()->frame()->client()->didAddContentSecurityPolicies(policies);
}
}
« no previous file with comments | « third_party/WebKit/Source/core/frame/LocalFrameClient.h ('k') | third_party/WebKit/Source/web/LocalFrameClientImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698