Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(207)

Side by Side Diff: extensions/common/permissions/socket_permission_entry.cc

Issue 296593003: Make various string_util functions take StringPieces instead of char[]. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Resync Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « components/webdata/common/web_database_migration_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « components/webdata/common/web_database_migration_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698