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 9b34e0ffcfb6d74f50b31fea2d377a344909514d..1b90f39c1c8ceffc713462ad4fd5c4920b86d757 100644 |
--- a/third_party/WebKit/Source/core/loader/FrameLoader.cpp |
+++ b/third_party/WebKit/Source/core/loader/FrameLoader.cpp |
@@ -87,6 +87,7 @@ |
#include "platform/PluginScriptForbiddenScope.h" |
#include "platform/ScriptForbiddenScope.h" |
#include "platform/UserGestureIndicator.h" |
+#include "platform/feature_policy/FeaturePolicy.h" |
#include "platform/network/HTTPParsers.h" |
#include "platform/network/ResourceRequest.h" |
#include "platform/scroll/ScrollAnimatorBase.h" |
@@ -581,6 +582,24 @@ void FrameLoader::didBeginDocument() { |
OriginTrialContext::addTokensFromHeader( |
m_frame->document(), |
m_documentLoader->response().httpHeaderField(HTTPNames::Origin_Trial)); |
+ if (RuntimeEnabledFeatures::featurePolicyEnabled()) { |
+ FeaturePolicy* featurePolicy = FeaturePolicy::createFromParentPolicy( |
+ (isLoadingMainFrame() |
+ ? nullptr |
+ : m_frame->client()->parent()->getFeaturePolicy()), |
+ m_frame->securityContext()->getSecurityOrigin()); |
+ Vector<String> messages; |
+ featurePolicy->setHeaderPolicy( |
+ m_documentLoader->response().httpHeaderField( |
+ HTTPNames::Feature_Policy), |
+ messages); |
+ for (auto& message : messages) { |
+ m_frame->document()->addConsoleMessage(ConsoleMessage::create( |
+ OtherMessageSource, ErrorMessageLevel, |
+ "Error with Feature-Policy header: " + message)); |
+ } |
+ m_frame->setFeaturePolicy(featurePolicy); |
+ } |
} |
if (m_documentLoader) { |