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

Side by Side Diff: content/child/feature_policy/feature_policy_platform.cc

Issue 2727803004: Replace string by enum in WebParsedFeaturePolicyDeclaration#feature (Closed)
Patch Set: Set upstream Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/child/feature_policy/feature_policy_platform.h" 5 #include "content/child/feature_policy/feature_policy_platform.h"
6 6
7 namespace content { 7 namespace content {
8 8
9 ParsedFeaturePolicyHeader FeaturePolicyHeaderFromWeb( 9 ParsedFeaturePolicyHeader FeaturePolicyHeaderFromWeb(
10 const blink::WebParsedFeaturePolicyHeader& web_feature_policy_header) { 10 const blink::WebParsedFeaturePolicyHeader& web_feature_policy_header) {
11 ParsedFeaturePolicyHeader result; 11 ParsedFeaturePolicyHeader result;
12 for (const blink::WebParsedFeaturePolicyDeclaration& web_declaration : 12 for (const blink::WebParsedFeaturePolicyDeclaration& web_declaration :
13 web_feature_policy_header) { 13 web_feature_policy_header) {
14 ParsedFeaturePolicyDeclaration declaration; 14 ParsedFeaturePolicyDeclaration declaration;
15 declaration.feature_name = web_declaration.featureName.utf8(); 15 declaration.feature = web_declaration.feature;
16 declaration.matches_all_origins = web_declaration.matchesAllOrigins; 16 declaration.matches_all_origins = web_declaration.matchesAllOrigins;
17 for (const blink::WebSecurityOrigin& web_origin : web_declaration.origins) 17 for (const blink::WebSecurityOrigin& web_origin : web_declaration.origins)
18 declaration.origins.push_back(web_origin); 18 declaration.origins.push_back(web_origin);
19 result.push_back(declaration); 19 result.push_back(declaration);
20 } 20 }
21 return result; 21 return result;
22 } 22 }
23 23
24 blink::WebParsedFeaturePolicyHeader FeaturePolicyHeaderToWeb( 24 blink::WebParsedFeaturePolicyHeader FeaturePolicyHeaderToWeb(
25 const ParsedFeaturePolicyHeader& feature_policy_header) { 25 const ParsedFeaturePolicyHeader& feature_policy_header) {
26 std::vector<blink::WebParsedFeaturePolicyDeclaration> result; 26 std::vector<blink::WebParsedFeaturePolicyDeclaration> result;
27 for (const ParsedFeaturePolicyDeclaration& declaration : 27 for (const ParsedFeaturePolicyDeclaration& declaration :
28 feature_policy_header) { 28 feature_policy_header) {
29 blink::WebParsedFeaturePolicyDeclaration web_declaration; 29 blink::WebParsedFeaturePolicyDeclaration web_declaration;
30 web_declaration.featureName = 30 web_declaration.feature = declaration.feature;
31 blink::WebString::fromUTF8(declaration.feature_name);
32 web_declaration.matchesAllOrigins = declaration.matches_all_origins; 31 web_declaration.matchesAllOrigins = declaration.matches_all_origins;
33 std::vector<blink::WebSecurityOrigin> web_origins; 32 std::vector<blink::WebSecurityOrigin> web_origins;
34 for (const url::Origin& origin : declaration.origins) 33 for (const url::Origin& origin : declaration.origins)
35 web_origins.push_back(origin); 34 web_origins.push_back(origin);
36 web_declaration.origins = web_origins; 35 web_declaration.origins = web_origins;
37 result.push_back(web_declaration); 36 result.push_back(web_declaration);
38 } 37 }
39 return result; 38 return result;
40 } 39 }
41 40
42 } // namespace content 41 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698