OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "extensions/common/permissions/socket_permission_data.h" | 5 #include "extensions/common/permissions/socket_permission_data.h" |
6 | 6 |
7 #include <cstdlib> | 7 #include <cstdlib> |
8 #include <sstream> | 8 #include <sstream> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 SocketPermissionEntry& SocketPermissionData::entry() { | 117 SocketPermissionEntry& SocketPermissionData::entry() { |
118 // Clear the spec because the caller could mutate |this|. | 118 // Clear the spec because the caller could mutate |this|. |
119 spec_.clear(); | 119 spec_.clear(); |
120 return entry_; | 120 return entry_; |
121 } | 121 } |
122 | 122 |
123 // TODO(reillyg): Rewrite this method to support IPv6. | 123 // TODO(reillyg): Rewrite this method to support IPv6. |
124 bool SocketPermissionData::Parse(const std::string& permission) { | 124 bool SocketPermissionData::Parse(const std::string& permission) { |
125 Reset(); | 125 Reset(); |
126 | 126 |
127 std::vector<std::string> tokens; | 127 std::vector<std::string> tokens = |
128 base::SplitStringDontTrim(permission, kColon, &tokens); | 128 base::SplitString(permission, std::string(1, kColon), |
| 129 base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL); |
129 if (tokens.empty()) | 130 if (tokens.empty()) |
130 return false; | 131 return false; |
131 | 132 |
132 SocketPermissionRequest::OperationType type = StringToType(tokens[0]); | 133 SocketPermissionRequest::OperationType type = StringToType(tokens[0]); |
133 if (type == SocketPermissionRequest::NONE) | 134 if (type == SocketPermissionRequest::NONE) |
134 return false; | 135 return false; |
135 | 136 |
136 tokens.erase(tokens.begin()); | 137 tokens.erase(tokens.begin()); |
137 return SocketPermissionEntry::ParseHostPattern(type, tokens, &entry_); | 138 return SocketPermissionEntry::ParseHostPattern(type, tokens, &entry_); |
138 } | 139 } |
(...skipping 10 matching lines...) Expand all Loading... |
149 } | 150 } |
150 return spec_; | 151 return spec_; |
151 } | 152 } |
152 | 153 |
153 void SocketPermissionData::Reset() { | 154 void SocketPermissionData::Reset() { |
154 entry_ = SocketPermissionEntry(); | 155 entry_ = SocketPermissionEntry(); |
155 spec_.clear(); | 156 spec_.clear(); |
156 } | 157 } |
157 | 158 |
158 } // namespace extensions | 159 } // namespace extensions |
OLD | NEW |