| 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/RuntimeEnabledFeatures.h" |
| 8 #include "platform/json/JSONValues.h" | 8 #include "platform/json/JSONValues.h" |
| 9 #include "platform/network/HTTPParsers.h" | 9 #include "platform/network/HTTPParsers.h" |
| 10 #include "platform/weborigin/SecurityOrigin.h" | 10 #include "platform/weborigin/SecurityOrigin.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 if (feature == "sync-script") | 39 if (feature == "sync-script") |
| 40 return WebFeaturePolicyFeature::SyncScript; | 40 return WebFeaturePolicyFeature::SyncScript; |
| 41 if (feature == "sync-xhr") | 41 if (feature == "sync-xhr") |
| 42 return WebFeaturePolicyFeature::SyncXHR; | 42 return WebFeaturePolicyFeature::SyncXHR; |
| 43 if (feature == "webrtc") | 43 if (feature == "webrtc") |
| 44 return WebFeaturePolicyFeature::WebRTC; | 44 return WebFeaturePolicyFeature::WebRTC; |
| 45 } | 45 } |
| 46 return WebFeaturePolicyFeature::NotFound; | 46 return WebFeaturePolicyFeature::NotFound; |
| 47 } | 47 } |
| 48 | 48 |
| 49 WebParsedFeaturePolicyHeader parseFeaturePolicy(const String& policy, | 49 WebParsedFeaturePolicy parseFeaturePolicy(const String& policy, |
| 50 RefPtr<SecurityOrigin> origin, | 50 RefPtr<SecurityOrigin> origin, |
| 51 Vector<String>* messages) { | 51 Vector<String>* messages) { |
| 52 Vector<WebParsedFeaturePolicyDeclaration> whitelists; | 52 Vector<WebParsedFeaturePolicyDeclaration> whitelists; |
| 53 | 53 |
| 54 // Use a reasonable parse depth limit; the actual maximum depth is only going | 54 // Use a reasonable parse depth limit; the actual maximum depth is only going |
| 55 // to be 4 for a valid policy, but we'll give the featurePolicyParser a chance | 55 // to be 4 for a valid policy, but we'll give the featurePolicyParser a chance |
| 56 // to report more specific errors, unless the string is really invalid. | 56 // to report more specific errors, unless the string is really invalid. |
| 57 std::unique_ptr<JSONArray> policyItems = parseJSONHeader(policy, 50); | 57 std::unique_ptr<JSONArray> policyItems = parseJSONHeader(policy, 50); |
| 58 if (!policyItems) { | 58 if (!policyItems) { |
| 59 if (messages) | 59 if (messages) |
| 60 messages->push_back("Unable to parse header"); | 60 messages->push_back("Unable to parse header"); |
| 61 return whitelists; | 61 return whitelists; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 } | 102 } |
| 103 } | 103 } |
| 104 whitelist.origins = origins; | 104 whitelist.origins = origins; |
| 105 whitelists.push_back(whitelist); | 105 whitelists.push_back(whitelist); |
| 106 } | 106 } |
| 107 } | 107 } |
| 108 return whitelists; | 108 return whitelists; |
| 109 } | 109 } |
| 110 | 110 |
| 111 } // namespace blink | 111 } // namespace blink |
| OLD | NEW |