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

Unified Diff: content/renderer/render_frame_proxy.cc

Issue 2520223002: Replicate a parsed feature policy representation so it doesn't need to be parsed in the browser pro… (Closed)
Patch Set: Fp2 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: content/renderer/render_frame_proxy.cc
diff --git a/content/renderer/render_frame_proxy.cc b/content/renderer/render_frame_proxy.cc
index 4fde39f8fda4f52d00734d3d22c441259474d699..0a8cf8706fcd1de8d97d37d1123f0b809a8c6003 100644
--- a/content/renderer/render_frame_proxy.cc
+++ b/content/renderer/render_frame_proxy.cc
@@ -29,6 +29,7 @@
#include "content/renderer/render_widget.h"
#include "ipc/ipc_message_macros.h"
#include "third_party/WebKit/public/platform/URLConversion.h"
+#include "third_party/WebKit/public/platform/WebFeaturePolicy.h"
#include "third_party/WebKit/public/platform/WebString.h"
#include "third_party/WebKit/public/web/WebLocalFrame.h"
#include "third_party/WebKit/public/web/WebUserGestureIndicator.h"
@@ -47,6 +48,23 @@ static base::LazyInstance<RoutingIDProxyMap> g_routing_id_proxy_map =
typedef std::map<blink::WebFrame*, RenderFrameProxy*> FrameMap;
base::LazyInstance<FrameMap> g_frame_map = LAZY_INSTANCE_INITIALIZER;
+blink::WebVector<blink::WebFeaturePolicy::ParsedWhitelist>
+ToWebFeaturePolicyParsedWhitelist(
+ const std::vector<FeaturePolicyParsedWhitelist>& parsed_whitelists) {
+ std::vector<blink::WebFeaturePolicy::ParsedWhitelist> result;
+ for (const FeaturePolicyParsedWhitelist& whitelist : parsed_whitelists) {
+ blink::WebFeaturePolicy::ParsedWhitelist web_whitelist;
+ web_whitelist.featureName =
+ blink::WebString::fromUTF8(whitelist.feature_name);
+ web_whitelist.matchesAllOrigins = whitelist.matches_all_origins;
+ std::vector<blink::WebString> web_origins;
+ for (const std::string& origin : whitelist.origins)
+ web_origins.push_back(blink::WebString::fromUTF8(origin));
+ result.push_back(web_whitelist);
+ }
+ return result;
+}
+
} // namespace
// static
@@ -224,7 +242,7 @@ void RenderFrameProxy::SetReplicatedState(const FrameReplicationState& state) {
web_frame_->setReplicatedPotentiallyTrustworthyUniqueOrigin(
state.has_potentially_trustworthy_unique_origin);
web_frame_->setReplicatedFeaturePolicyHeader(
- blink::WebString::fromUTF8(state.feature_policy_header));
+ ToWebFeaturePolicyParsedWhitelist(state.feature_policy_header));
web_frame_->resetReplicatedContentSecurityPolicy();
for (const auto& header : state.accumulated_csp_headers)

Powered by Google App Engine
This is Rietveld 408576698