OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/strings/utf_string_conversions.h" |
5 #include "content/common/frame_replication_state.h" | 6 #include "content/common/frame_replication_state.h" |
6 #include "third_party/WebKit/public/web/WebSandboxFlags.h" | 7 #include "third_party/WebKit/public/web/WebSandboxFlags.h" |
7 #include "third_party/WebKit/public/web/WebTreeScopeType.h" | 8 #include "third_party/WebKit/public/web/WebTreeScopeType.h" |
8 | 9 |
9 namespace content { | 10 namespace content { |
10 | 11 |
| 12 // static |
| 13 std::vector<FeaturePolicyParsedWhitelist> |
| 14 FeaturePolicyParsedWhitelist::fromWebFeaturePolicyParsedWhitelist( |
| 15 const blink::WebVector<blink::WebFeaturePolicy::ParsedWhitelist>& |
| 16 web_parsed_whitelists) { |
| 17 std::vector<FeaturePolicyParsedWhitelist> result; |
| 18 for (const blink::WebFeaturePolicy::ParsedWhitelist& web_whitelist : |
| 19 web_parsed_whitelists) { |
| 20 FeaturePolicyParsedWhitelist whitelist; |
| 21 whitelist.feature_name = |
| 22 base::UTF16ToUTF8(base::StringPiece16(web_whitelist.featureName)); |
| 23 whitelist.matches_all_origins = web_whitelist.matchesAllOrigins; |
| 24 for (const blink::WebString& web_origin : web_whitelist.origins) |
| 25 whitelist.origins.push_back( |
| 26 base::UTF16ToUTF8(base::StringPiece16(web_origin))); |
| 27 result.push_back(whitelist); |
| 28 } |
| 29 return result; |
| 30 } |
| 31 |
| 32 // static |
| 33 blink::WebVector<blink::WebFeaturePolicy::ParsedWhitelist> |
| 34 FeaturePolicyParsedWhitelist::toWebFeaturePolicyParsedWhitelist( |
| 35 const std::vector<FeaturePolicyParsedWhitelist>& parsed_whitelists) { |
| 36 std::vector<blink::WebFeaturePolicy::ParsedWhitelist> result; |
| 37 for (const FeaturePolicyParsedWhitelist& whitelist : parsed_whitelists) { |
| 38 blink::WebFeaturePolicy::ParsedWhitelist web_whitelist; |
| 39 web_whitelist.featureName = |
| 40 blink::WebString(base::UTF8ToUTF16(whitelist.feature_name)); |
| 41 web_whitelist.matchesAllOrigins = whitelist.matches_all_origins; |
| 42 std::vector<blink::WebString> web_origins; |
| 43 for (const std::string& origin : whitelist.origins) |
| 44 web_origins.push_back(base::UTF8ToUTF16(origin)); |
| 45 result.push_back(web_whitelist); |
| 46 } |
| 47 return result; |
| 48 } |
| 49 |
| 50 FeaturePolicyParsedWhitelist::FeaturePolicyParsedWhitelist() |
| 51 : matches_all_origins(false) {} |
| 52 |
| 53 FeaturePolicyParsedWhitelist::FeaturePolicyParsedWhitelist( |
| 54 const FeaturePolicyParsedWhitelist& fpw) = default; |
| 55 |
| 56 FeaturePolicyParsedWhitelist::~FeaturePolicyParsedWhitelist() {} |
| 57 |
11 FrameReplicationState::FrameReplicationState() | 58 FrameReplicationState::FrameReplicationState() |
12 : sandbox_flags(blink::WebSandboxFlags::None), | 59 : sandbox_flags(blink::WebSandboxFlags::None), |
13 scope(blink::WebTreeScopeType::Document), | 60 scope(blink::WebTreeScopeType::Document), |
14 insecure_request_policy(blink::kLeaveInsecureRequestsAlone), | 61 insecure_request_policy(blink::kLeaveInsecureRequestsAlone), |
15 has_potentially_trustworthy_unique_origin(false) {} | 62 has_potentially_trustworthy_unique_origin(false) {} |
16 | 63 |
17 FrameReplicationState::FrameReplicationState( | 64 FrameReplicationState::FrameReplicationState( |
18 blink::WebTreeScopeType scope, | 65 blink::WebTreeScopeType scope, |
19 const std::string& name, | 66 const std::string& name, |
20 const std::string& unique_name, | 67 const std::string& unique_name, |
21 blink::WebSandboxFlags sandbox_flags, | 68 blink::WebSandboxFlags sandbox_flags, |
22 blink::WebInsecureRequestPolicy insecure_request_policy, | 69 blink::WebInsecureRequestPolicy insecure_request_policy, |
23 bool has_potentially_trustworthy_unique_origin) | 70 bool has_potentially_trustworthy_unique_origin) |
24 : origin(), | 71 : origin(), |
25 sandbox_flags(sandbox_flags), | 72 sandbox_flags(sandbox_flags), |
26 name(name), | 73 name(name), |
27 unique_name(unique_name), | 74 unique_name(unique_name), |
28 scope(scope), | 75 scope(scope), |
29 insecure_request_policy(insecure_request_policy), | 76 insecure_request_policy(insecure_request_policy), |
30 has_potentially_trustworthy_unique_origin( | 77 has_potentially_trustworthy_unique_origin( |
31 has_potentially_trustworthy_unique_origin) {} | 78 has_potentially_trustworthy_unique_origin) {} |
32 | 79 |
33 FrameReplicationState::FrameReplicationState( | 80 FrameReplicationState::FrameReplicationState( |
34 const FrameReplicationState& other) = default; | 81 const FrameReplicationState& other) = default; |
35 | 82 |
36 FrameReplicationState::~FrameReplicationState() { | 83 FrameReplicationState::~FrameReplicationState() { |
37 } | 84 } |
38 | 85 |
39 } // namespace content | 86 } // namespace content |
OLD | NEW |