| 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/KURL.h" | 10 #include "platform/weborigin/KURL.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 for (size_t i = 0; i < policyItems->size(); ++i) { | 66 for (size_t i = 0; i < policyItems->size(); ++i) { |
| 67 JSONObject* item = JSONObject::cast(policyItems->at(i)); | 67 JSONObject* item = JSONObject::cast(policyItems->at(i)); |
| 68 if (!item) { | 68 if (!item) { |
| 69 if (messages) | 69 if (messages) |
| 70 messages->push_back("Policy is not an object"); | 70 messages->push_back("Policy is not an object"); |
| 71 continue; // Array element is not an object; skip | 71 continue; // Array element is not an object; skip |
| 72 } | 72 } |
| 73 | 73 |
| 74 for (size_t j = 0; j < item->size(); ++j) { | 74 for (size_t j = 0; j < item->size(); ++j) { |
| 75 JSONObject::Entry entry = item->at(j); | 75 JSONObject::Entry entry = item->at(j); |
| 76 String featureName = entry.first; | 76 WebFeaturePolicyFeature feature = getWebFeaturePolicyFeature(entry.first); |
| 77 JSONArray* targets = JSONArray::cast(entry.second); | 77 JSONArray* targets = JSONArray::cast(entry.second); |
| 78 if (!targets) { | 78 if (!targets) { |
| 79 if (messages) | 79 if (messages) |
| 80 messages->push_back("Whitelist is not an array of strings."); | 80 messages->push_back("Whitelist is not an array of strings."); |
| 81 continue; | 81 continue; |
| 82 } | 82 } |
| 83 | 83 |
| 84 WebParsedFeaturePolicyDeclaration whitelist; | 84 WebParsedFeaturePolicyDeclaration whitelist; |
| 85 whitelist.featureName = featureName; | 85 whitelist.feature = feature; |
| 86 Vector<WebSecurityOrigin> origins; | 86 Vector<WebSecurityOrigin> origins; |
| 87 String targetString; | 87 String targetString; |
| 88 for (size_t j = 0; j < targets->size(); ++j) { | 88 for (size_t j = 0; j < targets->size(); ++j) { |
| 89 if (targets->at(j)->asString(&targetString)) { | 89 if (targets->at(j)->asString(&targetString)) { |
| 90 if (equalIgnoringCase(targetString, "self")) { | 90 if (equalIgnoringCase(targetString, "self")) { |
| 91 if (!origin->isUnique()) | 91 if (!origin->isUnique()) |
| 92 origins.push_back(origin); | 92 origins.push_back(origin); |
| 93 } else if (targetString == "*") { | 93 } else if (targetString == "*") { |
| 94 whitelist.matchesAllOrigins = true; | 94 whitelist.matchesAllOrigins = true; |
| 95 } else { | 95 } else { |
| 96 WebSecurityOrigin targetOrigin = | 96 WebSecurityOrigin targetOrigin = |
| 97 WebSecurityOrigin::createFromString(targetString); | 97 WebSecurityOrigin::createFromString(targetString); |
| 98 if (!targetOrigin.isNull() && !targetOrigin.isUnique()) | 98 if (!targetOrigin.isNull() && !targetOrigin.isUnique()) |
| 99 origins.push_back(targetOrigin); | 99 origins.push_back(targetOrigin); |
| 100 } | 100 } |
| 101 } else { | 101 } else { |
| 102 if (messages) | 102 if (messages) |
| 103 messages->push_back("Whitelist is not an array of strings."); | 103 messages->push_back("Whitelist is not an array of strings."); |
| 104 } | 104 } |
| 105 } | 105 } |
| 106 whitelist.origins = origins; | 106 whitelist.origins = origins; |
| 107 whitelists.push_back(whitelist); | 107 whitelists.push_back(whitelist); |
| 108 } | 108 } |
| 109 } | 109 } |
| 110 return whitelists; | 110 return whitelists; |
| 111 } | 111 } |
| 112 | 112 |
| 113 } // namespace blink | 113 } // namespace blink |
| OLD | NEW |