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

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 nits 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
« no previous file with comments | « third_party/WebKit/Source/core/frame/Frame.cpp ('k') | third_party/WebKit/Source/platform/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 958f6fb1fe23612787e48a8b5ea5194b40b9d39c..1ae15bc9d26788a95083c3219a836405fc464cc8 100644
--- a/third_party/WebKit/Source/core/loader/FrameLoader.cpp
+++ b/third_party/WebKit/Source/core/loader/FrameLoader.cpp
@@ -88,6 +88,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"
@@ -575,6 +576,25 @@ void FrameLoader::didBeginDocument() {
OriginTrialContext::addTokensFromHeader(
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()->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(std::move(featurePolicy));
+ }
}
if (m_documentLoader) {
« no previous file with comments | « third_party/WebKit/Source/core/frame/Frame.cpp ('k') | third_party/WebKit/Source/platform/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698