| 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 BSDstyle license that can be | 2 // Use of this source code is governed by a BSDstyle license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/html/HTMLIFrameElementPermissions.h" | 5 #include "core/html/HTMLIFrameElementPermissions.h" |
| 6 | 6 |
| 7 #include "core/html/HTMLIFrameElement.h" | 7 #include "core/html/HTMLIFrameElement.h" |
| 8 #include "wtf/HashMap.h" | 8 #include "wtf/HashMap.h" |
| 9 #include "wtf/text/StringBuilder.h" | 9 #include "wtf/text/StringBuilder.h" |
| 10 | 10 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 Vector<blink::mojom::blink::PermissionName> permissions; | 56 Vector<blink::mojom::blink::PermissionName> permissions; |
| 57 unsigned numTokenErrors = 0; | 57 unsigned numTokenErrors = 0; |
| 58 StringBuilder tokenErrors; | 58 StringBuilder tokenErrors; |
| 59 const SpaceSplitString& tokens = this->tokens(); | 59 const SpaceSplitString& tokens = this->tokens(); |
| 60 | 60 |
| 61 for (size_t i = 0; i < tokens.size(); ++i) { | 61 for (size_t i = 0; i < tokens.size(); ++i) { |
| 62 blink::mojom::blink::PermissionName type; | 62 blink::mojom::blink::PermissionName type; |
| 63 if (getPermissionType(tokens[i], &type)) { | 63 if (getPermissionType(tokens[i], &type)) { |
| 64 permissions.push_back(type); | 64 permissions.push_back(type); |
| 65 } else { | 65 } else { |
| 66 if (numTokenErrors) | 66 HTMLIFrameElement::addTokenError(tokenErrors, tokens[i]); |
| 67 tokenErrors.append(", '"); | |
| 68 else | |
| 69 tokenErrors.append('\''); | |
| 70 tokenErrors.append(tokens[i]); | |
| 71 tokenErrors.append('\''); | |
| 72 ++numTokenErrors; | 67 ++numTokenErrors; |
| 73 } | 68 } |
| 74 } | 69 } |
| 75 | 70 |
| 76 if (numTokenErrors) { | 71 if (numTokenErrors) { |
| 77 if (numTokenErrors > 1) | 72 tokenErrors.append(numTokenErrors > 1 ? " are invalid permissions flags." |
| 78 tokenErrors.append(" are invalid permissions flags."); | 73 : " is an invalid permissions flag."); |
| 79 else | |
| 80 tokenErrors.append(" is an invalid permissions flag."); | |
| 81 invalidTokensErrorMessage = tokenErrors.toString(); | 74 invalidTokensErrorMessage = tokenErrors.toString(); |
| 82 } | 75 } |
| 83 | 76 |
| 84 return permissions; | 77 return permissions; |
| 85 } | 78 } |
| 86 | 79 |
| 87 bool HTMLIFrameElementPermissions::validateTokenValue( | 80 bool HTMLIFrameElementPermissions::validateTokenValue( |
| 88 const AtomicString& tokenValue, | 81 const AtomicString& tokenValue, |
| 89 ExceptionState&) const { | 82 ExceptionState&) const { |
| 90 mojom::blink::PermissionName unused; | 83 mojom::blink::PermissionName unused; |
| 91 return getPermissionType(tokenValue, &unused); | 84 return getPermissionType(tokenValue, &unused); |
| 92 } | 85 } |
| 93 | 86 |
| 94 void HTMLIFrameElementPermissions::valueWasSet() { | 87 void HTMLIFrameElementPermissions::valueWasSet() { |
| 95 if (m_element) | 88 if (m_element) |
| 96 m_element->permissionsValueWasSet(); | 89 m_element->permissionsValueWasSet(); |
| 97 } | 90 } |
| 98 | 91 |
| 99 } // namespace blink | 92 } // namespace blink |
| OLD | NEW |