OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSDstyle license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "core/html/HTMLIFrameElementPermissions.h" | |
6 | |
7 #include "wtf/HashMap.h" | |
8 #include "wtf/text/StringBuilder.h" | |
9 | |
10 namespace blink { | |
11 | |
12 HTMLIFrameElementPermissions::HTMLIFrameElementPermissions(DOMTokenListObserver* observer) | |
13 : DOMTokenList(observer) | |
14 { | |
15 } | |
16 | |
17 HTMLIFrameElementPermissions::~HTMLIFrameElementPermissions() | |
18 { | |
19 } | |
20 | |
21 using SandboxSupportedTokens = HashMap<AtomicString, WebPermissionType>; | |
22 | |
23 static SandboxSupportedTokens& supportedTokens() | |
24 { | |
25 DEFINE_STATIC_LOCAL(SandboxSupportedTokens, supportedValues, ()); | |
26 if (supportedValues.isEmpty()) { | |
27 supportedValues.set("geolocation", WebPermissionTypeGeolocation); | |
28 supportedValues.set("notifications", WebPermissionTypeNotifications); | |
29 supportedValues.set("midi", WebPermissionTypeMidiSysEx); | |
esprehn
2016/06/01 05:05:57
.add(...) not .set().
Also this is large in the b
raymes
2016/06/06 06:48:29
Done.
| |
30 } | |
31 | |
32 return supportedValues; | |
33 } | |
34 | |
35 Vector<WebPermissionType> HTMLIFrameElementPermissions::parseDelegatedPermission s(String& invalidTokensErrorMessage) const | |
36 { | |
37 Vector<WebPermissionType> permissions; | |
38 size_t numTokenErrors = 0; | |
esprehn
2016/06/01 05:05:57
unsigned
raymes
2016/06/06 06:48:29
Done.
| |
39 StringBuilder tokenErrors; | |
40 const SpaceSplitString& tokens = tokens(); | |
41 | |
42 for (size_t i = 0; i < tokens.size(); ++i) { | |
43 const auto& it = supportedTokens().find(tokens[i]); | |
44 if (it != supportedTokens().end()) { | |
45 permissions.append(it->value); | |
46 } else { | |
47 if (numTokenErrors > 0) | |
esprehn
2016/06/01 05:05:57
if (numTokenErrors)
raymes
2016/06/06 06:48:29
Done.
| |
48 tokenErrors.appendLiteral(", '"); | |
esprehn
2016/06/01 05:05:57
appendLiteral is gone, just use append() now:
htt
raymes
2016/06/06 06:48:29
Done.
| |
49 else | |
50 tokenErrors.append('\''); | |
51 tokenErrors.append(tokens[i]); | |
52 tokenErrors.append('\''); | |
53 ++numTokenErrors; | |
54 } | |
55 } | |
56 | |
57 if (numTokenErrors > 0) { | |
esprehn
2016/06/01 05:05:57
remove >
raymes
2016/06/06 06:48:29
Done.
| |
58 if (numTokenErrors > 1) | |
59 tokenErrors.appendLiteral(" are invalid permissions flags."); | |
60 else | |
61 tokenErrors.appendLiteral(" is an invalid permissions flag."); | |
62 invalidTokensErrorMessage = tokenErrors.toString(); | |
63 } | |
64 | |
65 return permissions; | |
66 } | |
67 | |
68 bool HTMLIFrameElementPermissions::validateTokenValue(const AtomicString& tokenV alue, ExceptionState&) const | |
69 { | |
70 return supportedTokens().contains(tokenValue); | |
71 } | |
72 | |
73 } // namespace blink | |
OLD | NEW |