Chromium Code Reviews| 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 "core/html/HTMLIFrameElementSandbox.h" | 5 #include "core/html/HTMLIFrameElementSandbox.h" |
| 6 | 6 |
| 7 namespace blink { | 7 namespace blink { |
| 8 | 8 |
| 9 namespace { | |
| 10 | |
| 11 const char* kSupportedTokens[] = { | |
| 12 "allow-forms", | |
| 13 "allow-modals", | |
| 14 "allow-pointer-lock", | |
| 15 "allow-popups", | |
| 16 "allow-popups-to-escape-sandbox", | |
| 17 "allow-same-origin", | |
| 18 "allow-scripts", | |
| 19 "allow-top-navigation" | |
| 20 }; | |
| 21 | |
| 22 bool IsTokenSupported(const AtomicString& token) | |
|
tkent
2016/06/23 04:57:28
With the current Blink coding style, this should b
raymes
2016/06/27 08:09:50
Done.
| |
| 23 { | |
| 24 for (const char* supportedToken : kSupportedTokens) { | |
| 25 if (token == supportedToken) | |
| 26 return true; | |
| 27 } | |
| 28 return false; | |
| 29 } | |
| 30 | |
| 31 } // namespace | |
| 32 | |
| 9 HTMLIFrameElementSandbox::HTMLIFrameElementSandbox(DOMTokenListObserver* observe r) | 33 HTMLIFrameElementSandbox::HTMLIFrameElementSandbox(DOMTokenListObserver* observe r) |
| 10 : DOMTokenList(observer) | 34 : DOMTokenList(observer) |
| 11 { | 35 { |
| 12 } | 36 } |
| 13 | 37 |
| 14 HTMLIFrameElementSandbox::~HTMLIFrameElementSandbox() | 38 HTMLIFrameElementSandbox::~HTMLIFrameElementSandbox() |
| 15 { | 39 { |
| 16 } | 40 } |
| 17 | 41 |
| 18 using SandboxSupportedTokens = HashSet<AtomicString>; | |
| 19 | |
| 20 static SandboxSupportedTokens& supportedTokens() | |
| 21 { | |
| 22 DEFINE_STATIC_LOCAL(SandboxSupportedTokens, supportedValues, ()); | |
| 23 if (supportedValues.isEmpty()) { | |
| 24 supportedValues.add("allow-forms"); | |
| 25 supportedValues.add("allow-modals"); | |
| 26 supportedValues.add("allow-pointer-lock"); | |
| 27 supportedValues.add("allow-popups"); | |
| 28 supportedValues.add("allow-popups-to-escape-sandbox"); | |
| 29 supportedValues.add("allow-same-origin"); | |
| 30 supportedValues.add("allow-scripts"); | |
| 31 supportedValues.add("allow-top-navigation"); | |
| 32 } | |
| 33 | |
| 34 return supportedValues; | |
| 35 } | |
| 36 | |
| 37 bool HTMLIFrameElementSandbox::validateTokenValue(const AtomicString& tokenValue , ExceptionState&) const | 42 bool HTMLIFrameElementSandbox::validateTokenValue(const AtomicString& tokenValue , ExceptionState&) const |
| 38 { | 43 { |
| 39 return supportedTokens().contains(tokenValue); | 44 return IsTokenSupported(tokenValue); |
| 40 } | 45 } |
| 41 | 46 |
| 42 } // namespace blink | 47 } // namespace blink |
| OLD | NEW |