| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/browser/privacy_blacklist/blacklist.h" | 5 #include "chrome/browser/privacy_blacklist/blacklist.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 // static | 36 // static |
| 37 bool Blacklist::Matches(const std::string& pattern, const std::string& url) { | 37 bool Blacklist::Matches(const std::string& pattern, const std::string& url) { |
| 38 if (pattern.size() > url.size()) | 38 if (pattern.size() > url.size()) |
| 39 return false; | 39 return false; |
| 40 | 40 |
| 41 std::string::size_type p = 0; | 41 std::string::size_type p = 0; |
| 42 std::string::size_type u = 0; | 42 std::string::size_type u = 0; |
| 43 | 43 |
| 44 while (pattern[p] != '\0' && url[u] != '\0') { | 44 while (pattern[p] != '\0' && url[u] != '\0') { |
| 45 if (pattern[p] == '@') { | 45 if (pattern[p] == '@') { |
| 46 while (pattern[++p] == '@'); // Consecutive @ are redundant. | 46 while (pattern[++p] == '@') {} // Consecutive @ are redundant. |
| 47 | 47 |
| 48 if (pattern[p] == '\0') | 48 if (pattern[p] == '\0') |
| 49 return true; // Nothing to match after the @. | 49 return true; // Nothing to match after the @. |
| 50 | 50 |
| 51 // Look for another wildcard to determine pattern-chunk. | 51 // Look for another wildcard to determine pattern-chunk. |
| 52 std::string::size_type tp = pattern.find_first_of("@", p); | 52 std::string::size_type tp = pattern.find_first_of("@", p); |
| 53 | 53 |
| 54 // If it must match until the end, compare the last characters. | 54 // If it must match until the end, compare the last characters. |
| 55 if (tp == std::string::npos) { | 55 if (tp == std::string::npos) { |
| 56 std::string::size_type ur = url.size() - u; | 56 std::string::size_type ur = url.size() - u; |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 | 214 |
| 215 // static | 215 // static |
| 216 void Blacklist::RegisterUserPrefs(PrefService* user_prefs) { | 216 void Blacklist::RegisterUserPrefs(PrefService* user_prefs) { |
| 217 user_prefs->RegisterDictionaryPref(prefs::kPrivacyFilterRules); | 217 user_prefs->RegisterDictionaryPref(prefs::kPrivacyFilterRules); |
| 218 } | 218 } |
| 219 | 219 |
| 220 // static | 220 // static |
| 221 std::string Blacklist::StripCookies(const std::string& header) { | 221 std::string Blacklist::StripCookies(const std::string& header) { |
| 222 return net::HttpUtil::StripHeaders(header, cookie_headers, 2); | 222 return net::HttpUtil::StripHeaders(header, cookie_headers, 2); |
| 223 } | 223 } |
| OLD | NEW |