| 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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 // TODO(jar): Remove this failsafe conservative hack which is more restrictive | 165 // TODO(jar): Remove this failsafe conservative hack which is more restrictive |
| 166 // than current SDCH spec when needed, and justified by security audit. | 166 // than current SDCH spec when needed, and justified by security audit. |
| 167 if (!referring_url.SchemeIs("http")) { | 167 if (!referring_url.SchemeIs("http")) { |
| 168 SdchErrorRecovery(DICTIONARY_SELECTED_FROM_NON_HTTP); | 168 SdchErrorRecovery(DICTIONARY_SELECTED_FROM_NON_HTTP); |
| 169 return false; | 169 return false; |
| 170 } | 170 } |
| 171 | 171 |
| 172 return true; | 172 return true; |
| 173 } | 173 } |
| 174 | 174 |
| 175 void SdchManager::FetchDictionary(const GURL& dictionary_url) { | 175 void SdchManager::FetchDictionary(const GURL& request_url, |
| 176 if (fetcher_.get()) | 176 const GURL& dictionary_url) { |
| 177 if (SdchManager::Global()->CanFetchDictionary(request_url, dictionary_url) && |
| 178 fetcher_.get()) |
| 177 fetcher_->Schedule(dictionary_url); | 179 fetcher_->Schedule(dictionary_url); |
| 178 } | 180 } |
| 179 | 181 |
| 180 bool SdchManager::AddSdchDictionary(const std::string& dictionary_text, | 182 bool SdchManager::AddSdchDictionary(const std::string& dictionary_text, |
| 181 const GURL& dictionary_url) { | 183 const GURL& dictionary_url) { |
| 182 std::string client_hash; | 184 std::string client_hash; |
| 183 std::string server_hash; | 185 std::string server_hash; |
| 184 GenerateHash(dictionary_text, &client_hash, &server_hash); | 186 GenerateHash(dictionary_text, &client_hash, &server_hash); |
| 185 if (dictionaries_.find(server_hash) != dictionaries_.end()) { | 187 if (dictionaries_.find(server_hash) != dictionaries_.end()) { |
| 186 SdchErrorRecovery(DICTIONARY_ALREADY_LOADED); | 188 SdchErrorRecovery(DICTIONARY_ALREADY_LOADED); |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 return false; | 500 return false; |
| 499 return restriction[prefix_length - 1] == '/' || path[prefix_length] == '/'; | 501 return restriction[prefix_length - 1] == '/' || path[prefix_length] == '/'; |
| 500 } | 502 } |
| 501 | 503 |
| 502 // static | 504 // static |
| 503 bool SdchManager::Dictionary::DomainMatch(const GURL& gurl, | 505 bool SdchManager::Dictionary::DomainMatch(const GURL& gurl, |
| 504 const std::string& restriction) { | 506 const std::string& restriction) { |
| 505 // TODO(jar): This is not precisely a domain match definition. | 507 // TODO(jar): This is not precisely a domain match definition. |
| 506 return gurl.DomainIs(restriction.data(), restriction.size()); | 508 return gurl.DomainIs(restriction.data(), restriction.size()); |
| 507 } | 509 } |
| OLD | NEW |