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/json/JSONValues.h" | 7 #include "platform/json/JSONValues.h" |
8 #include "platform/network/HTTPParsers.h" | 8 #include "platform/network/HTTPParsers.h" |
9 #include "platform/weborigin/KURL.h" | 9 #include "platform/weborigin/KURL.h" |
10 #include "platform/weborigin/SecurityOrigin.h" | 10 #include "platform/weborigin/SecurityOrigin.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 "sync-script", FeaturePolicy::FeatureDefault::EnableForAll}; | 52 "sync-script", FeaturePolicy::FeatureDefault::EnableForAll}; |
53 const FeaturePolicy::Feature kSyncXHR{ | 53 const FeaturePolicy::Feature kSyncXHR{ |
54 "sync-xhr", FeaturePolicy::FeatureDefault::EnableForAll}; | 54 "sync-xhr", FeaturePolicy::FeatureDefault::EnableForAll}; |
55 const FeaturePolicy::Feature kUsermedia{ | 55 const FeaturePolicy::Feature kUsermedia{ |
56 "usermedia", FeaturePolicy::FeatureDefault::EnableForAll}; | 56 "usermedia", FeaturePolicy::FeatureDefault::EnableForAll}; |
57 const FeaturePolicy::Feature kVibrateFeature{ | 57 const FeaturePolicy::Feature kVibrateFeature{ |
58 "vibrate", FeaturePolicy::FeatureDefault::EnableForSelf}; | 58 "vibrate", FeaturePolicy::FeatureDefault::EnableForSelf}; |
59 const FeaturePolicy::Feature kWebRTC{ | 59 const FeaturePolicy::Feature kWebRTC{ |
60 "webrtc", FeaturePolicy::FeatureDefault::EnableForAll}; | 60 "webrtc", FeaturePolicy::FeatureDefault::EnableForAll}; |
61 | 61 |
| 62 WebFeaturePolicyFeature FeaturePolicy::getWebFeaturePolicyFeature( |
| 63 const String& feature) { |
| 64 if (feature == "cookie") |
| 65 return WebFeaturePolicyFeature::DocumentCookie; |
| 66 if (feature == "domain") |
| 67 return WebFeaturePolicyFeature::DocumentDomain; |
| 68 if (feature == "docwrite") |
| 69 return WebFeaturePolicyFeature::DocumentWrite; |
| 70 if (feature == "fullscreen") |
| 71 return WebFeaturePolicyFeature::Fullscreen; |
| 72 if (feature == "geolocation") |
| 73 return WebFeaturePolicyFeature::Geolocation; |
| 74 if (feature == "midi") |
| 75 return WebFeaturePolicyFeature::MidiFeature; |
| 76 if (feature == "notifications") |
| 77 return WebFeaturePolicyFeature::Notifications; |
| 78 if (feature == "payment") |
| 79 return WebFeaturePolicyFeature::Payment; |
| 80 if (feature == "push") |
| 81 return WebFeaturePolicyFeature::Push; |
| 82 if (feature == "sync-script") |
| 83 return WebFeaturePolicyFeature::SyncScript; |
| 84 if (feature == "sync-xhr") |
| 85 return WebFeaturePolicyFeature::SyncXHR; |
| 86 if (feature == "usermedia") |
| 87 return WebFeaturePolicyFeature::Usermedia; |
| 88 if (feature == "vibrate") |
| 89 return WebFeaturePolicyFeature::Vibrate; |
| 90 if (feature == "webrtc") |
| 91 return WebFeaturePolicyFeature::WebRTC; |
| 92 return WebFeaturePolicyFeature::NotFound; |
| 93 } |
| 94 |
62 // static | 95 // static |
63 std::unique_ptr<FeaturePolicy::Whitelist> FeaturePolicy::Whitelist::from( | 96 std::unique_ptr<FeaturePolicy::Whitelist> FeaturePolicy::Whitelist::from( |
64 const WebFeaturePolicy::ParsedWhitelist& parsedWhitelist) { | 97 const WebFeaturePolicy::ParsedWhitelist& parsedWhitelist) { |
65 std::unique_ptr<Whitelist> whitelist(new FeaturePolicy::Whitelist); | 98 std::unique_ptr<Whitelist> whitelist(new FeaturePolicy::Whitelist); |
66 if (parsedWhitelist.matchesAllOrigins) { | 99 if (parsedWhitelist.matchesAllOrigins) { |
67 whitelist->addAll(); | 100 whitelist->addAll(); |
68 } else { | 101 } else { |
69 for (const WebSecurityOrigin& origin : parsedWhitelist.origins) | 102 for (const WebSecurityOrigin& origin : parsedWhitelist.origins) |
70 whitelist->add(static_cast<WTF::PassRefPtr<SecurityOrigin>>(origin)); | 103 whitelist->add(static_cast<WTF::PassRefPtr<SecurityOrigin>>(origin)); |
71 } | 104 } |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 sb.append(" "); | 302 sb.append(" "); |
270 sb.append(whitelist.key->featureName); | 303 sb.append(whitelist.key->featureName); |
271 sb.append(": "); | 304 sb.append(": "); |
272 sb.append(whitelist.value->toString()); | 305 sb.append(whitelist.value->toString()); |
273 sb.append("\n"); | 306 sb.append("\n"); |
274 } | 307 } |
275 return sb.toString(); | 308 return sb.toString(); |
276 } | 309 } |
277 | 310 |
278 } // namespace blink | 311 } // namespace blink |
OLD | NEW |