| 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_entry.h" | 5 #include "extensions/common/permissions/socket_permission_entry.h" |
| 6 | 6 |
| 7 #include <cstdlib> | 7 #include <cstdlib> |
| 8 #include <sstream> | 8 #include <sstream> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 using content::SocketPermissionRequest; | 22 using content::SocketPermissionRequest; |
| 23 | 23 |
| 24 const char kColon = ':'; | 24 const char kColon = ':'; |
| 25 const char kDot = '.'; | 25 const char kDot = '.'; |
| 26 const char kWildcard[] = "*"; | 26 const char kWildcard[] = "*"; |
| 27 const int kWildcardPortNumber = 0; | 27 const int kWildcardPortNumber = 0; |
| 28 const int kInvalidPort = -1; | 28 const int kInvalidPort = -1; |
| 29 | 29 |
| 30 bool StartsOrEndsWithWhitespace(const std::string& str) { | 30 bool StartsOrEndsWithWhitespace(const std::string& str) { |
| 31 if (str.find_first_not_of(base::kWhitespaceASCII) != 0) | 31 return !str.empty() && |
| 32 return true; | 32 (IsWhitespace(str[0]) || IsWhitespace(str[str.length() - 1])); |
| 33 if (str.find_last_not_of(base::kWhitespaceASCII) != str.length() - 1) | |
| 34 return true; | |
| 35 return false; | |
| 36 } | 33 } |
| 37 | 34 |
| 38 } // namespace | 35 } // namespace |
| 39 | 36 |
| 40 namespace extensions { | 37 namespace extensions { |
| 41 | 38 |
| 42 SocketPermissionEntry::SocketPermissionEntry() | 39 SocketPermissionEntry::SocketPermissionEntry() |
| 43 : pattern_(SocketPermissionRequest::NONE, std::string(), kInvalidPort), | 40 : pattern_(SocketPermissionRequest::NONE, std::string(), kInvalidPort), |
| 44 match_subdomains_(false) {} | 41 match_subdomains_(false) {} |
| 45 | 42 |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 | 214 |
| 218 if (pattern_.port == kWildcardPortNumber) | 215 if (pattern_.port == kWildcardPortNumber) |
| 219 result.append(1, kColon).append(kWildcard); | 216 result.append(1, kColon).append(kWildcard); |
| 220 else | 217 else |
| 221 result.append(1, kColon).append(base::IntToString(pattern_.port)); | 218 result.append(1, kColon).append(base::IntToString(pattern_.port)); |
| 222 | 219 |
| 223 return result; | 220 return result; |
| 224 } | 221 } |
| 225 | 222 |
| 226 } // namespace extensions | 223 } // namespace extensions |
| OLD | NEW |