| 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 tokenErrors.append(tokenErrors.isEmpty() ? "'" : ", '"); |
| 67 tokenErrors.append(", '"); | |
| 68 else | |
| 69 tokenErrors.append('\''); | |
| 70 tokenErrors.append(tokens[i]); | 67 tokenErrors.append(tokens[i]); |
| 71 tokenErrors.append('\''); | 68 tokenErrors.append("'"); |
| 72 ++numTokenErrors; | 69 ++numTokenErrors; |
| 73 } | 70 } |
| 74 } | 71 } |
| 75 | 72 |
| 76 if (numTokenErrors) { | 73 if (numTokenErrors) { |
| 77 if (numTokenErrors > 1) | 74 tokenErrors.append(numTokenErrors > 1 ? " are invalid permissions flags." |
| 78 tokenErrors.append(" are invalid permissions flags."); | 75 : " is an invalid permissions flag."); |
| 79 else | |
| 80 tokenErrors.append(" is an invalid permissions flag."); | |
| 81 invalidTokensErrorMessage = tokenErrors.toString(); | 76 invalidTokensErrorMessage = tokenErrors.toString(); |
| 82 } | 77 } |
| 83 | 78 |
| 84 return permissions; | 79 return permissions; |
| 85 } | 80 } |
| 86 | 81 |
| 87 bool HTMLIFrameElementPermissions::validateTokenValue( | 82 bool HTMLIFrameElementPermissions::validateTokenValue( |
| 88 const AtomicString& tokenValue, | 83 const AtomicString& tokenValue, |
| 89 ExceptionState&) const { | 84 ExceptionState&) const { |
| 90 mojom::blink::PermissionName unused; | 85 mojom::blink::PermissionName unused; |
| 91 return getPermissionType(tokenValue, &unused); | 86 return getPermissionType(tokenValue, &unused); |
| 92 } | 87 } |
| 93 | 88 |
| 94 void HTMLIFrameElementPermissions::valueWasSet() { | 89 void HTMLIFrameElementPermissions::valueWasSet() { |
| 95 if (m_element) | 90 if (m_element) |
| 96 m_element->permissionsValueWasSet(); | 91 m_element->permissionsValueWasSet(); |
| 97 } | 92 } |
| 98 | 93 |
| 99 } // namespace blink | 94 } // namespace blink |
| OLD | NEW |