Chromium Code Reviews| Index: third_party/WebKit/Source/core/html/HTMLIFrameElementPermissions.cpp |
| diff --git a/third_party/WebKit/Source/core/html/HTMLIFrameElementPermissions.cpp b/third_party/WebKit/Source/core/html/HTMLIFrameElementPermissions.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..6d901789a1e794d8bf54b29d342f3bce9b3dc4c6 |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/core/html/HTMLIFrameElementPermissions.cpp |
| @@ -0,0 +1,73 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSDstyle license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "core/html/HTMLIFrameElementPermissions.h" |
| + |
| +#include "wtf/HashMap.h" |
| +#include "wtf/text/StringBuilder.h" |
| + |
| +namespace blink { |
| + |
| +HTMLIFrameElementPermissions::HTMLIFrameElementPermissions(DOMTokenListObserver* observer) |
| + : DOMTokenList(observer) |
| +{ |
| +} |
| + |
| +HTMLIFrameElementPermissions::~HTMLIFrameElementPermissions() |
| +{ |
| +} |
| + |
| +using SandboxSupportedTokens = HashMap<AtomicString, WebPermissionType>; |
| + |
| +static SandboxSupportedTokens& supportedTokens() |
| +{ |
| + DEFINE_STATIC_LOCAL(SandboxSupportedTokens, supportedValues, ()); |
| + if (supportedValues.isEmpty()) { |
| + supportedValues.set("geolocation", WebPermissionTypeGeolocation); |
| + supportedValues.set("notifications", WebPermissionTypeNotifications); |
| + 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.
|
| + } |
| + |
| + return supportedValues; |
| +} |
| + |
| +Vector<WebPermissionType> HTMLIFrameElementPermissions::parseDelegatedPermissions(String& invalidTokensErrorMessage) const |
| +{ |
| + Vector<WebPermissionType> permissions; |
| + size_t numTokenErrors = 0; |
|
esprehn
2016/06/01 05:05:57
unsigned
raymes
2016/06/06 06:48:29
Done.
|
| + StringBuilder tokenErrors; |
| + const SpaceSplitString& tokens = tokens(); |
| + |
| + for (size_t i = 0; i < tokens.size(); ++i) { |
| + const auto& it = supportedTokens().find(tokens[i]); |
| + if (it != supportedTokens().end()) { |
| + permissions.append(it->value); |
| + } else { |
| + if (numTokenErrors > 0) |
|
esprehn
2016/06/01 05:05:57
if (numTokenErrors)
raymes
2016/06/06 06:48:29
Done.
|
| + 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.
|
| + else |
| + tokenErrors.append('\''); |
| + tokenErrors.append(tokens[i]); |
| + tokenErrors.append('\''); |
| + ++numTokenErrors; |
| + } |
| + } |
| + |
| + if (numTokenErrors > 0) { |
|
esprehn
2016/06/01 05:05:57
remove >
raymes
2016/06/06 06:48:29
Done.
|
| + if (numTokenErrors > 1) |
| + tokenErrors.appendLiteral(" are invalid permissions flags."); |
| + else |
| + tokenErrors.appendLiteral(" is an invalid permissions flag."); |
| + invalidTokensErrorMessage = tokenErrors.toString(); |
| + } |
| + |
| + return permissions; |
| +} |
| + |
| +bool HTMLIFrameElementPermissions::validateTokenValue(const AtomicString& tokenValue, ExceptionState&) const |
| +{ |
| + return supportedTokens().contains(tokenValue); |
| +} |
| + |
| +} // namespace blink |