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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLIFrameElementPermissions.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: Created 4 years, 6 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
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698