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

Unified Diff: third_party/WebKit/Source/core/loader/FrameLoader.cpp

Issue 2483703002: Replicate feature policy headers to remote frames (Closed)
Patch Set: Addressing review comments Created 4 years, 1 month 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/loader/FrameLoader.cpp
diff --git a/third_party/WebKit/Source/core/loader/FrameLoader.cpp b/third_party/WebKit/Source/core/loader/FrameLoader.cpp
index fde5f299ac1e539ba4f62f6f845d6b91866f77a7..007130b587986e9900406f02e011767d1a3da4ab 100644
--- a/third_party/WebKit/Source/core/loader/FrameLoader.cpp
+++ b/third_party/WebKit/Source/core/loader/FrameLoader.cpp
@@ -523,6 +523,7 @@ void FrameLoader::didInstallNewDocument(bool dispatchWindowObjectAvailable) {
void FrameLoader::didBeginDocument() {
DCHECK(m_frame);
+ DCHECK(m_frame->client());
DCHECK(m_frame->document());
DCHECK(m_frame->document()->fetcher());
@@ -577,25 +578,25 @@ void FrameLoader::didBeginDocument() {
m_frame->document(),
m_documentLoader->response().httpHeaderField(HTTPNames::Origin_Trial));
if (RuntimeEnabledFeatures::featurePolicyEnabled()) {
- std::unique_ptr<FeaturePolicy> featurePolicy(
- FeaturePolicy::createFromParentPolicy(
- (isLoadingMainFrame() ? nullptr
- : m_frame->client()
- ->parent()
- ->securityContext()
- ->getFeaturePolicy()),
- m_frame->securityContext()->getSecurityOrigin()));
- Vector<String> messages;
- featurePolicy->setHeaderPolicy(
+ FeaturePolicy* parentFeaturePolicy =
+ (isLoadingMainFrame() ? nullptr
+ : m_frame->client()
+ ->parent()
+ ->securityContext()
+ ->getFeaturePolicy());
+ const String& featurePolicyHeader =
m_documentLoader->response().httpHeaderField(
- HTTPNames::Feature_Policy),
- messages);
+ HTTPNames::Feature_Policy);
+ Vector<String> messages;
+ m_frame->securityContext()->setFeaturePolicyFromHeader(
+ featurePolicyHeader, parentFeaturePolicy, &messages);
for (auto& message : messages) {
m_frame->document()->addConsoleMessage(ConsoleMessage::create(
OtherMessageSource, ErrorMessageLevel,
"Error with Feature-Policy header: " + message));
}
- m_frame->document()->setFeaturePolicy(std::move(featurePolicy));
+ if (!featurePolicyHeader.isEmpty())
+ client()->didSetFeaturePolicyHeader(featurePolicyHeader);
}
}

Powered by Google App Engine
This is Rietveld 408576698