OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "net/tools/tld_cleanup/tld_cleanup_util.h" | 5 #include "net/tools/tld_cleanup/tld_cleanup_util.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 domain->find('!', start_offset) != std::string::npos) { | 108 domain->find('!', start_offset) != std::string::npos) { |
109 LOG(WARNING) << "Keeping probably invalid rule: " << *domain; | 109 LOG(WARNING) << "Keeping probably invalid rule: " << *domain; |
110 result = kWarning; | 110 result = kWarning; |
111 } | 111 } |
112 | 112 |
113 // Make a GURL and normalize it, then get the host back out. | 113 // Make a GURL and normalize it, then get the host back out. |
114 std::string url = "http://"; | 114 std::string url = "http://"; |
115 url.append(*domain); | 115 url.append(*domain); |
116 GURL gurl(url); | 116 GURL gurl(url); |
117 const std::string& spec = gurl.possibly_invalid_spec(); | 117 const std::string& spec = gurl.possibly_invalid_spec(); |
118 url_parse::Component host = gurl.parsed_for_possibly_invalid_spec().host; | 118 url::Component host = gurl.parsed_for_possibly_invalid_spec().host; |
119 if (host.len < 0) { | 119 if (host.len < 0) { |
120 LOG(ERROR) << "Ignoring rule that couldn't be normalized: " << *domain; | 120 LOG(ERROR) << "Ignoring rule that couldn't be normalized: " << *domain; |
121 return kError; | 121 return kError; |
122 } | 122 } |
123 if (!gurl.is_valid()) { | 123 if (!gurl.is_valid()) { |
124 LOG(WARNING) << "Keeping rule that GURL says is invalid: " << *domain; | 124 LOG(WARNING) << "Keeping rule that GURL says is invalid: " << *domain; |
125 result = kWarning; | 125 result = kWarning; |
126 } | 126 } |
127 domain->assign(spec.substr(host.begin, host.len)); | 127 domain->assign(spec.substr(host.begin, host.len)); |
128 | 128 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 LOG(ERROR) << "Error(s) writing output file"; | 246 LOG(ERROR) << "Error(s) writing output file"; |
247 result = kError; | 247 result = kError; |
248 } | 248 } |
249 | 249 |
250 return result; | 250 return result; |
251 } | 251 } |
252 | 252 |
253 | 253 |
254 } // namespace tld_cleanup | 254 } // namespace tld_cleanup |
255 } // namespace net | 255 } // namespace net |
OLD | NEW |