| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "base/field_trial.h" | 5 #include "base/field_trial.h" |
| 6 #include "base/histogram.h" | 6 #include "base/histogram.h" |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/sha2.h" | 8 #include "base/sha2.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "net/base/base64.h" | 10 #include "net/base/base64.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 if (!sdch_enabled_ ) | 81 if (!sdch_enabled_ ) |
| 82 return false; | 82 return false; |
| 83 if (!supported_domain_.empty() && | 83 if (!supported_domain_.empty() && |
| 84 !url.DomainIs(supported_domain_.data(), supported_domain_.size())) | 84 !url.DomainIs(supported_domain_.data(), supported_domain_.size())) |
| 85 return false; // It is not the singular supported domain. | 85 return false; // It is not the singular supported domain. |
| 86 | 86 |
| 87 if (blacklisted_domains_.empty()) | 87 if (blacklisted_domains_.empty()) |
| 88 return true; | 88 return true; |
| 89 | 89 |
| 90 std::string domain = StringToLowerASCII(url.host()); | 90 std::string domain = StringToLowerASCII(url.host()); |
| 91 bool was_blacklisted(blacklisted_domains_.end() == | 91 bool was_blacklisted(blacklisted_domains_.end() != |
| 92 blacklisted_domains_.find(domain)); | 92 blacklisted_domains_.find(domain)); |
| 93 if (was_blacklisted) | 93 if (was_blacklisted) |
| 94 SdchErrorRecovery(DOMAIN_BLACKLIST_INCLUDES_TARGET); | 94 SdchErrorRecovery(DOMAIN_BLACKLIST_INCLUDES_TARGET); |
| 95 return was_blacklisted; | 95 return !was_blacklisted; |
| 96 } | 96 } |
| 97 | 97 |
| 98 bool SdchManager::CanFetchDictionary(const GURL& referring_url, | 98 bool SdchManager::CanFetchDictionary(const GURL& referring_url, |
| 99 const GURL& dictionary_url) const { | 99 const GURL& dictionary_url) const { |
| 100 /* The user agent may retrieve a dictionary from the dictionary URL if all of | 100 /* The user agent may retrieve a dictionary from the dictionary URL if all of |
| 101 the following are true: | 101 the following are true: |
| 102 1 The dictionary URL host name matches the referrer URL host name | 102 1 The dictionary URL host name matches the referrer URL host name |
| 103 2 The dictionary URL host name domain matches the parent domain of the | 103 2 The dictionary URL host name domain matches the parent domain of the |
| 104 referrer URL host name | 104 referrer URL host name |
| 105 3 The parent domain of the referrer URL host name is not a top level | 105 3 The parent domain of the referrer URL host name is not a top level |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 return false; | 451 return false; |
| 452 return restriction[prefix_length - 1] == '/' || path[prefix_length] == '/'; | 452 return restriction[prefix_length - 1] == '/' || path[prefix_length] == '/'; |
| 453 } | 453 } |
| 454 | 454 |
| 455 // static | 455 // static |
| 456 bool SdchManager::Dictionary::DomainMatch(const GURL& gurl, | 456 bool SdchManager::Dictionary::DomainMatch(const GURL& gurl, |
| 457 const std::string& restriction) { | 457 const std::string& restriction) { |
| 458 // TODO(jar): This is not precisely a domain match definition. | 458 // TODO(jar): This is not precisely a domain match definition. |
| 459 return gurl.DomainIs(restriction.data(), restriction.size()); | 459 return gurl.DomainIs(restriction.data(), restriction.size()); |
| 460 } | 460 } |
| OLD | NEW |