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::SplitString(permission, std::string(1, kColon), | 128 base::SplitStringDontTrim(permission, kColon, &tokens); |
129 base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL); | |
130 if (tokens.empty()) | 129 if (tokens.empty()) |
131 return false; | 130 return false; |
132 | 131 |
133 SocketPermissionRequest::OperationType type = StringToType(tokens[0]); | 132 SocketPermissionRequest::OperationType type = StringToType(tokens[0]); |
134 if (type == SocketPermissionRequest::NONE) | 133 if (type == SocketPermissionRequest::NONE) |
135 return false; | 134 return false; |
136 | 135 |
137 tokens.erase(tokens.begin()); | 136 tokens.erase(tokens.begin()); |
138 return SocketPermissionEntry::ParseHostPattern(type, tokens, &entry_); | 137 return SocketPermissionEntry::ParseHostPattern(type, tokens, &entry_); |
139 } | 138 } |
(...skipping 10 matching lines...) Expand all Loading... |
150 } | 149 } |
151 return spec_; | 150 return spec_; |
152 } | 151 } |
153 | 152 |
154 void SocketPermissionData::Reset() { | 153 void SocketPermissionData::Reset() { |
155 entry_ = SocketPermissionEntry(); | 154 entry_ = SocketPermissionEntry(); |
156 spec_.clear(); | 155 spec_.clear(); |
157 } | 156 } |
158 | 157 |
159 } // namespace extensions | 158 } // namespace extensions |
OLD | NEW |