OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 "platform/feature_policy/FeaturePolicy.h" | 5 #include "platform/feature_policy/FeaturePolicy.h" |
6 | 6 |
| 7 #include "platform/RuntimeEnabledFeatures.h" |
7 #include "platform/json/JSONValues.h" | 8 #include "platform/json/JSONValues.h" |
8 #include "platform/network/HTTPParsers.h" | 9 #include "platform/network/HTTPParsers.h" |
9 #include "platform/weborigin/KURL.h" | 10 #include "platform/weborigin/KURL.h" |
10 #include "platform/weborigin/SecurityOrigin.h" | 11 #include "platform/weborigin/SecurityOrigin.h" |
11 #include "wtf/PtrUtil.h" | 12 #include "wtf/PtrUtil.h" |
12 #include "wtf/text/StringBuilder.h" | 13 #include "wtf/text/StringBuilder.h" |
13 | 14 |
14 namespace blink { | 15 namespace blink { |
15 | 16 |
16 namespace { | 17 namespace { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 "sync-script", FeaturePolicy::FeatureDefault::EnableForAll}; | 53 "sync-script", FeaturePolicy::FeatureDefault::EnableForAll}; |
53 const FeaturePolicy::Feature kSyncXHR{ | 54 const FeaturePolicy::Feature kSyncXHR{ |
54 "sync-xhr", FeaturePolicy::FeatureDefault::EnableForAll}; | 55 "sync-xhr", FeaturePolicy::FeatureDefault::EnableForAll}; |
55 const FeaturePolicy::Feature kUsermedia{ | 56 const FeaturePolicy::Feature kUsermedia{ |
56 "usermedia", FeaturePolicy::FeatureDefault::EnableForAll}; | 57 "usermedia", FeaturePolicy::FeatureDefault::EnableForAll}; |
57 const FeaturePolicy::Feature kVibrateFeature{ | 58 const FeaturePolicy::Feature kVibrateFeature{ |
58 "vibrate", FeaturePolicy::FeatureDefault::EnableForSelf}; | 59 "vibrate", FeaturePolicy::FeatureDefault::EnableForSelf}; |
59 const FeaturePolicy::Feature kWebRTC{ | 60 const FeaturePolicy::Feature kWebRTC{ |
60 "webrtc", FeaturePolicy::FeatureDefault::EnableForAll}; | 61 "webrtc", FeaturePolicy::FeatureDefault::EnableForAll}; |
61 | 62 |
| 63 WebFeaturePolicyFeature FeaturePolicy::getWebFeaturePolicyFeature( |
| 64 const String& feature) { |
| 65 if (feature == "fullscreen") |
| 66 return WebFeaturePolicyFeature::Fullscreen; |
| 67 if (feature == "payment") |
| 68 return WebFeaturePolicyFeature::Payment; |
| 69 if (feature == "vibrate") |
| 70 return WebFeaturePolicyFeature::Vibrate; |
| 71 if (feature == "usermedia") |
| 72 return WebFeaturePolicyFeature::Usermedia; |
| 73 if (RuntimeEnabledFeatures::featurePolicyExperimentalFeaturesEnabled()) { |
| 74 if (feature == "cookie") |
| 75 return WebFeaturePolicyFeature::DocumentCookie; |
| 76 if (feature == "domain") |
| 77 return WebFeaturePolicyFeature::DocumentDomain; |
| 78 if (feature == "docwrite") |
| 79 return WebFeaturePolicyFeature::DocumentWrite; |
| 80 if (feature == "geolocation") |
| 81 return WebFeaturePolicyFeature::Geolocation; |
| 82 if (feature == "midi") |
| 83 return WebFeaturePolicyFeature::MidiFeature; |
| 84 if (feature == "notifications") |
| 85 return WebFeaturePolicyFeature::Notifications; |
| 86 if (feature == "push") |
| 87 return WebFeaturePolicyFeature::Push; |
| 88 if (feature == "sync-script") |
| 89 return WebFeaturePolicyFeature::SyncScript; |
| 90 if (feature == "sync-xhr") |
| 91 return WebFeaturePolicyFeature::SyncXHR; |
| 92 if (feature == "webrtc") |
| 93 return WebFeaturePolicyFeature::WebRTC; |
| 94 } |
| 95 return WebFeaturePolicyFeature::NotFound; |
| 96 } |
| 97 |
62 // static | 98 // static |
63 std::unique_ptr<FeaturePolicy::Whitelist> FeaturePolicy::Whitelist::from( | 99 std::unique_ptr<FeaturePolicy::Whitelist> FeaturePolicy::Whitelist::from( |
64 const WebParsedFeaturePolicyDeclaration& parsedDeclaration) { | 100 const WebParsedFeaturePolicyDeclaration& parsedDeclaration) { |
65 std::unique_ptr<Whitelist> whitelist(new FeaturePolicy::Whitelist); | 101 std::unique_ptr<Whitelist> whitelist(new FeaturePolicy::Whitelist); |
66 if (parsedDeclaration.matchesAllOrigins) { | 102 if (parsedDeclaration.matchesAllOrigins) { |
67 whitelist->addAll(); | 103 whitelist->addAll(); |
68 } else { | 104 } else { |
69 for (const WebSecurityOrigin& origin : parsedDeclaration.origins) | 105 for (const WebSecurityOrigin& origin : parsedDeclaration.origins) |
70 whitelist->add(static_cast<WTF::PassRefPtr<SecurityOrigin>>(origin)); | 106 whitelist->add(static_cast<WTF::PassRefPtr<SecurityOrigin>>(origin)); |
71 } | 107 } |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 sb.append(" "); | 306 sb.append(" "); |
271 sb.append(whitelist.key->featureName); | 307 sb.append(whitelist.key->featureName); |
272 sb.append(": "); | 308 sb.append(": "); |
273 sb.append(whitelist.value->toString()); | 309 sb.append(whitelist.value->toString()); |
274 sb.append("\n"); | 310 sb.append("\n"); |
275 } | 311 } |
276 return sb.toString(); | 312 return sb.toString(); |
277 } | 313 } |
278 | 314 |
279 } // namespace blink | 315 } // namespace blink |
OLD | NEW |