OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/child/feature_policy/feature_policy_platform.h" |
| 6 |
| 7 #include "base/macros.h" |
| 8 #include "base/memory/ptr_util.h" |
| 9 |
| 10 namespace content { |
| 11 |
| 12 FeaturePolicyHeader FeaturePolicyHeaderFromWeb( |
| 13 const blink::WebParsedFeaturePolicyHeader& web_feature_policy_header) { |
| 14 FeaturePolicyHeader result; |
| 15 for (const blink::WebParsedFeaturePolicyDeclaration& web_declaration : |
| 16 web_feature_policy_header) { |
| 17 FeaturePolicyParsedDeclaration declaration; |
| 18 declaration.feature_name = web_declaration.featureName.utf8(); |
| 19 declaration.matches_all_origins = |
| 20 web_declaration.whitelist.matchesAllOrigins; |
| 21 for (const blink::WebSecurityOrigin& web_origin : |
| 22 web_declaration.whitelist.origins) |
| 23 declaration.origins.push_back(web_origin); |
| 24 result.push_back(declaration); |
| 25 } |
| 26 return result; |
| 27 } |
| 28 |
| 29 blink::WebParsedFeaturePolicyHeader FeaturePolicyHeaderToWeb( |
| 30 const FeaturePolicyHeader& feature_policy_header) { |
| 31 std::vector<blink::WebParsedFeaturePolicyDeclaration> result; |
| 32 for (const FeaturePolicyParsedDeclaration& declaration : |
| 33 feature_policy_header) { |
| 34 blink::WebParsedFeaturePolicyDeclaration web_declaration; |
| 35 web_declaration.featureName = |
| 36 blink::WebString::fromUTF8(declaration.feature_name); |
| 37 web_declaration.whitelist.matchesAllOrigins = |
| 38 declaration.matches_all_origins; |
| 39 std::vector<blink::WebSecurityOrigin> web_origins; |
| 40 for (const url::Origin& origin : declaration.origins) |
| 41 web_origins.push_back(origin); |
| 42 web_declaration.whitelist.origins = web_origins; |
| 43 result.push_back(web_declaration); |
| 44 } |
| 45 return result; |
| 46 } |
| 47 |
| 48 } // namespace content |
OLD | NEW |