OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
iclelland
2017/02/08 15:06:24
2017
lunalu1
2017/02/08 19:50:30
Done.
| |
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 namespace { | |
15 | |
16 bool isTokenSupported(const AtomicString& token) { | |
17 if (FeaturePolicy::getWebFeaturePolicyFeature(token.getString()) == | |
18 WebFeaturePolicyFeature::NotFound) { | |
19 return false; | |
20 } | |
21 return true; | |
22 } | |
23 | |
24 } // namespace | |
25 | |
26 HTMLIFrameElementAllow::HTMLIFrameElementAllow(HTMLIFrameElement* element) | |
27 : DOMTokenList(this), m_element(element) {} | |
28 | |
29 HTMLIFrameElementAllow::~HTMLIFrameElementAllow() {} | |
30 | |
31 DEFINE_TRACE(HTMLIFrameElementAllow) { | |
32 visitor->trace(m_element); | |
33 DOMTokenList::trace(visitor); | |
34 DOMTokenListObserver::trace(visitor); | |
35 } | |
36 | |
37 HashSet<WebFeaturePolicyFeature> | |
38 HTMLIFrameElementAllow::parseAllowedFeatureNames( | |
39 String& invalidTokensErrorMessage) const { | |
40 HashSet<WebFeaturePolicyFeature> allowedFeatureNames; | |
41 unsigned numTokenErrors = 0; | |
42 StringBuilder tokenErrors; | |
43 const SpaceSplitString& tokens = this->tokens(); | |
44 | |
45 for (size_t i = 0; i < tokens.size(); ++i) { | |
46 WebFeaturePolicyFeature feature = | |
47 FeaturePolicy::getWebFeaturePolicyFeature(tokens[i]); | |
48 if (feature == WebFeaturePolicyFeature::NotFound) { | |
49 tokenErrors.append(numTokenErrors ? ", '" : "\'"); | |
50 tokenErrors.append(tokens[i]); | |
51 tokenErrors.append('\''); | |
52 ++numTokenErrors; | |
53 } else { | |
54 allowedFeatureNames.insert(feature); | |
55 } | |
56 } | |
57 | |
58 if (numTokenErrors) { | |
59 tokenErrors.append(numTokenErrors > 1 ? " are invalid feature names." | |
60 : " is an invalid feature name."); | |
61 invalidTokensErrorMessage = tokenErrors.toString(); | |
62 } | |
63 | |
64 return allowedFeatureNames; | |
65 } | |
66 | |
67 bool HTMLIFrameElementAllow::validateTokenValue(const AtomicString& tokenValue, | |
68 ExceptionState&) const { | |
69 return isTokenSupported(tokenValue); | |
iclelland
2017/02/08 15:06:24
Could this just be
return FeaturePolicy::getWebFe
lunalu1
2017/02/08 19:50:30
Done.
| |
70 } | |
71 | |
72 void HTMLIFrameElementAllow::valueWasSet() { | |
73 m_element->allowValueWasSet(); | |
iclelland
2017/02/08 15:06:24
HTMLIframeElementPermissions.cpp has a check -- if
lunalu1
2017/02/08 19:50:30
Done.
| |
74 } | |
75 | |
76 } // namespace blink | |
OLD | NEW |