| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/common/extensions/url_pattern.h" | 5 #include "chrome/common/extensions/url_pattern.h" |
| 6 | 6 |
| 7 #include "base/string_piece.h" | 7 #include "base/string_piece.h" |
| 8 #include "base/string_split.h" | 8 #include "base/string_split.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "chrome/common/url_constants.h" | 10 #include "chrome/common/url_constants.h" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 path_start_pos = host_start_pos; | 105 path_start_pos = host_start_pos; |
| 106 } else { | 106 } else { |
| 107 size_t host_end_pos = pattern.find(kPathSeparator, host_start_pos); | 107 size_t host_end_pos = pattern.find(kPathSeparator, host_start_pos); |
| 108 if (host_end_pos == std::string::npos) | 108 if (host_end_pos == std::string::npos) |
| 109 return false; | 109 return false; |
| 110 | 110 |
| 111 host_ = pattern.substr(host_start_pos, host_end_pos - host_start_pos); | 111 host_ = pattern.substr(host_start_pos, host_end_pos - host_start_pos); |
| 112 | 112 |
| 113 // The first component can optionally be '*' to match all subdomains. | 113 // The first component can optionally be '*' to match all subdomains. |
| 114 std::vector<std::string> host_components; | 114 std::vector<std::string> host_components; |
| 115 SplitString(host_, '.', &host_components); | 115 base::SplitString(host_, '.', &host_components); |
| 116 if (host_components[0] == "*") { | 116 if (host_components[0] == "*") { |
| 117 match_subdomains_ = true; | 117 match_subdomains_ = true; |
| 118 host_components.erase(host_components.begin(), | 118 host_components.erase(host_components.begin(), |
| 119 host_components.begin() + 1); | 119 host_components.begin() + 1); |
| 120 } | 120 } |
| 121 host_ = JoinString(host_components, '.'); | 121 host_ = JoinString(host_components, '.'); |
| 122 | 122 |
| 123 // No other '*' can occur in the host, though. This isn't necessary, but is | 123 // No other '*' can occur in the host, though. This isn't necessary, but is |
| 124 // done as a convenience to developers who might otherwise be confused and | 124 // done as a convenience to developers who might otherwise be confused and |
| 125 // think '*' works as a glob in the host. | 125 // think '*' works as a glob in the host. |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 if (MatchesScheme(kValidSchemes[i])) { | 291 if (MatchesScheme(kValidSchemes[i])) { |
| 292 URLPattern temp = *this; | 292 URLPattern temp = *this; |
| 293 temp.SetScheme(kValidSchemes[i]); | 293 temp.SetScheme(kValidSchemes[i]); |
| 294 temp.set_match_all_urls(false); | 294 temp.set_match_all_urls(false); |
| 295 result.push_back(temp); | 295 result.push_back(temp); |
| 296 } | 296 } |
| 297 } | 297 } |
| 298 | 298 |
| 299 return result; | 299 return result; |
| 300 } | 300 } |
| OLD | NEW |