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

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

Issue 2254533002: [FeaturePolicy] Initial implementation of Feature Policy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fp-flag
Patch Set: Addressing comments from PS#16 Created 4 years, 2 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/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) {

Powered by Google App Engine
This is Rietveld 408576698