Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "core/html/HTMLIFrameElementAllow.h" | |
| 6 | |
| 7 #include "core/html/HTMLIFrameElement.h" | |
| 8 #include "platform/feature_policy/FeaturePolicy.h" | |
| 9 | |
| 10 using blink::WebFeaturePolicyFeature; | |
| 11 | |
| 12 namespace blink { | |
| 13 | |
| 14 HTMLIFrameElementAllow::HTMLIFrameElementAllow(HTMLIFrameElement* element) | |
| 15 : DOMTokenList(this), m_element(element) {} | |
| 16 | |
| 17 HTMLIFrameElementAllow::~HTMLIFrameElementAllow() {} | |
| 18 | |
| 19 DEFINE_TRACE(HTMLIFrameElementAllow) { | |
| 20 visitor->trace(m_element); | |
| 21 DOMTokenList::trace(visitor); | |
| 22 DOMTokenListObserver::trace(visitor); | |
| 23 } | |
| 24 | |
| 25 HashSet<WebFeaturePolicyFeature> | |
| 26 HTMLIFrameElementAllow::parseAllowedFeatureNames( | |
| 27 String& invalidTokensErrorMessage) const { | |
| 28 HashSet<WebFeaturePolicyFeature> allowedFeatureNames; | |
| 29 unsigned numTokenErrors = 0; | |
| 30 StringBuilder tokenErrors; | |
| 31 const SpaceSplitString& tokens = this->tokens(); | |
| 32 | |
| 33 for (size_t i = 0; i < tokens.size(); ++i) { | |
| 34 WebFeaturePolicyFeature feature = | |
| 35 FeaturePolicy::getWebFeaturePolicyFeature(tokens[i]); | |
| 36 if (feature == WebFeaturePolicyFeature::NotFound) { | |
| 37 tokenErrors.append(numTokenErrors ? ", '" : "\'"); | |
|
Rick Byers
2017/02/09 20:59:59
why escape the single-quote in one place but not t
lunalu1
2017/02/09 23:19:04
Good point! We can have a helper function that pro
| |
| 38 tokenErrors.append(tokens[i]); | |
| 39 tokenErrors.append('\''); | |
| 40 ++numTokenErrors; | |
| 41 } else { | |
| 42 allowedFeatureNames.insert(feature); | |
| 43 } | |
| 44 } | |
| 45 | |
| 46 if (numTokenErrors) { | |
| 47 tokenErrors.append(numTokenErrors > 1 ? " are invalid feature names." | |
| 48 : " is an invalid feature name."); | |
| 49 invalidTokensErrorMessage = tokenErrors.toString(); | |
| 50 } | |
| 51 | |
| 52 return allowedFeatureNames; | |
| 53 } | |
| 54 | |
| 55 bool HTMLIFrameElementAllow::validateTokenValue(const AtomicString& tokenValue, | |
| 56 ExceptionState&) const { | |
| 57 return FeaturePolicy::getWebFeaturePolicyFeature(tokenValue.getString()) != | |
| 58 WebFeaturePolicyFeature::NotFound; | |
| 59 } | |
| 60 | |
| 61 void HTMLIFrameElementAllow::valueWasSet() { | |
| 62 DCHECK(m_element); | |
| 63 m_element->allowValueWasSet(); | |
| 64 } | |
| 65 | |
| 66 } // namespace blink | |
| OLD | NEW |