Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLIFrameElementSandbox.cpp

Issue 2011763006: Add an iframe permissions= attribute for implementing permission delegation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@permission-delegation-1-flag
Patch Set: Blink-side Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "core/html/HTMLIFrameElement.h"
8
7 namespace blink { 9 namespace blink {
8 10
9 HTMLIFrameElementSandbox::HTMLIFrameElementSandbox(DOMTokenListObserver* observe r) 11 namespace {
10 : DOMTokenList(observer) 12
13 const char* kSupportedTokens[] = {
14 "allow-forms",
15 "allow-modals",
16 "allow-pointer-lock",
17 "allow-popups",
18 "allow-popups-to-escape-sandbox",
19 "allow-same-origin",
20 "allow-scripts",
21 "allow-top-navigation"
22 };
23
24 bool isTokenSupported(const AtomicString& token)
25 {
26 for (const char* supportedToken : kSupportedTokens) {
27 if (token == supportedToken)
28 return true;
29 }
30 return false;
31 }
32
33 } // namespace
34
35 HTMLIFrameElementSandbox::HTMLIFrameElementSandbox(HTMLIFrameElement* element)
36 : DOMTokenList(this)
37 , m_element(element)
11 { 38 {
12 } 39 }
13 40
14 HTMLIFrameElementSandbox::~HTMLIFrameElementSandbox() 41 HTMLIFrameElementSandbox::~HTMLIFrameElementSandbox()
15 { 42 {
16 } 43 }
17 44
18 using SandboxSupportedTokens = HashSet<AtomicString>; 45 DEFINE_TRACE(HTMLIFrameElementSandbox)
19
20 static SandboxSupportedTokens& supportedTokens()
21 { 46 {
22 DEFINE_STATIC_LOCAL(SandboxSupportedTokens, supportedValues, ()); 47 visitor->trace(m_element);
23 if (supportedValues.isEmpty()) { 48 DOMTokenList::trace(visitor);
24 supportedValues.add("allow-forms"); 49 DOMTokenListObserver::trace(visitor);
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 } 50 }
36 51
37 bool HTMLIFrameElementSandbox::validateTokenValue(const AtomicString& tokenValue , ExceptionState&) const 52 bool HTMLIFrameElementSandbox::validateTokenValue(const AtomicString& tokenValue , ExceptionState&) const
38 { 53 {
39 return supportedTokens().contains(tokenValue); 54 return isTokenSupported(tokenValue);
55 }
56
57 void HTMLIFrameElementSandbox::valueWasSet()
58 {
59 m_element->sandboxValueWasSet();
40 } 60 }
41 61
42 } // namespace blink 62 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698