| Index: content/child/feature_policy/feature_policy_platform.cc
|
| diff --git a/content/child/feature_policy/feature_policy_platform.cc b/content/child/feature_policy/feature_policy_platform.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..4e81effc61713c2948b4daf648b1da5e8bd4df83
|
| --- /dev/null
|
| +++ b/content/child/feature_policy/feature_policy_platform.cc
|
| @@ -0,0 +1,48 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "content/child/feature_policy/feature_policy_platform.h"
|
| +
|
| +#include "base/macros.h"
|
| +#include "base/memory/ptr_util.h"
|
| +
|
| +namespace content {
|
| +
|
| +FeaturePolicyHeader FeaturePolicyHeaderFromWeb(
|
| + const blink::WebParsedFeaturePolicyHeader& web_feature_policy_header) {
|
| + FeaturePolicyHeader result;
|
| + for (const blink::WebParsedFeaturePolicyDeclaration& web_declaration :
|
| + web_feature_policy_header) {
|
| + FeaturePolicyParsedDeclaration declaration;
|
| + declaration.feature_name = web_declaration.featureName.utf8();
|
| + declaration.matches_all_origins =
|
| + web_declaration.whitelist.matchesAllOrigins;
|
| + for (const blink::WebSecurityOrigin& web_origin :
|
| + web_declaration.whitelist.origins)
|
| + declaration.origins.push_back(web_origin);
|
| + result.push_back(declaration);
|
| + }
|
| + return result;
|
| +}
|
| +
|
| +blink::WebParsedFeaturePolicyHeader FeaturePolicyHeaderToWeb(
|
| + const FeaturePolicyHeader& feature_policy_header) {
|
| + std::vector<blink::WebParsedFeaturePolicyDeclaration> result;
|
| + for (const FeaturePolicyParsedDeclaration& declaration :
|
| + feature_policy_header) {
|
| + blink::WebParsedFeaturePolicyDeclaration web_declaration;
|
| + web_declaration.featureName =
|
| + blink::WebString::fromUTF8(declaration.feature_name);
|
| + web_declaration.whitelist.matchesAllOrigins =
|
| + declaration.matches_all_origins;
|
| + std::vector<blink::WebSecurityOrigin> web_origins;
|
| + for (const url::Origin& origin : declaration.origins)
|
| + web_origins.push_back(origin);
|
| + web_declaration.whitelist.origins = web_origins;
|
| + result.push_back(web_declaration);
|
| + }
|
| + return result;
|
| +}
|
| +
|
| +} // namespace content
|
|
|