OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/base/sdch_manager.h" | 5 #include "net/base/sdch_manager.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 referrer URL host name | 242 referrer URL host name |
243 3 The parent domain of the referrer URL host name is not a top level | 243 3 The parent domain of the referrer URL host name is not a top level |
244 domain | 244 domain |
245 */ | 245 */ |
246 // Item (1) above implies item (2). Spec should be updated. | 246 // Item (1) above implies item (2). Spec should be updated. |
247 // I take "host name match" to be "is identical to" | 247 // I take "host name match" to be "is identical to" |
248 if (referring_url.host() != dictionary_url.host() || | 248 if (referring_url.host() != dictionary_url.host() || |
249 referring_url.scheme() != dictionary_url.scheme()) | 249 referring_url.scheme() != dictionary_url.scheme()) |
250 return SDCH_DICTIONARY_LOAD_ATTEMPT_FROM_DIFFERENT_HOST; | 250 return SDCH_DICTIONARY_LOAD_ATTEMPT_FROM_DIFFERENT_HOST; |
251 | 251 |
252 if (!secure_scheme_supported() && referring_url.SchemeIsSecure()) | 252 if (!secure_scheme_supported() && referring_url.SchemeIsCryptographic()) |
253 return SDCH_DICTIONARY_SELECTED_FOR_SSL; | 253 return SDCH_DICTIONARY_SELECTED_FOR_SSL; |
254 | 254 |
255 // TODO(jar): Remove this failsafe conservative hack which is more restrictive | 255 // TODO(jar): Remove this failsafe conservative hack which is more restrictive |
256 // than current SDCH spec when needed, and justified by security audit. | 256 // than current SDCH spec when needed, and justified by security audit. |
257 if (!referring_url.SchemeIsHTTPOrHTTPS()) | 257 if (!referring_url.SchemeIsHTTPOrHTTPS()) |
258 return SDCH_DICTIONARY_SELECTED_FROM_NON_HTTP; | 258 return SDCH_DICTIONARY_SELECTED_FROM_NON_HTTP; |
259 | 259 |
260 return SDCH_OK; | 260 return SDCH_OK; |
261 } | 261 } |
262 | 262 |
(...skipping 28 matching lines...) Expand all Loading... |
291 const GURL& target_url, | 291 const GURL& target_url, |
292 const std::string& server_hash, | 292 const std::string& server_hash, |
293 SdchProblemCode* problem_code) { | 293 SdchProblemCode* problem_code) { |
294 scoped_ptr<SdchManager::DictionarySet> result; | 294 scoped_ptr<SdchManager::DictionarySet> result; |
295 | 295 |
296 *problem_code = SDCH_DICTIONARY_HASH_NOT_FOUND; | 296 *problem_code = SDCH_DICTIONARY_HASH_NOT_FOUND; |
297 const auto& it = dictionaries_.find(server_hash); | 297 const auto& it = dictionaries_.find(server_hash); |
298 if (it == dictionaries_.end()) | 298 if (it == dictionaries_.end()) |
299 return result.Pass(); | 299 return result.Pass(); |
300 | 300 |
301 if (!SdchManager::secure_scheme_supported() && target_url.SchemeIsSecure()) { | 301 if (!SdchManager::secure_scheme_supported() && |
| 302 target_url.SchemeIsSecure()) { |
302 *problem_code = SDCH_DICTIONARY_FOUND_HAS_WRONG_SCHEME; | 303 *problem_code = SDCH_DICTIONARY_FOUND_HAS_WRONG_SCHEME; |
303 return result.Pass(); | 304 return result.Pass(); |
304 } | 305 } |
305 | 306 |
306 *problem_code = it->second->data.CanUse(target_url); | 307 *problem_code = it->second->data.CanUse(target_url); |
307 if (*problem_code != SDCH_OK) | 308 if (*problem_code != SDCH_OK) |
308 return result.Pass(); | 309 return result.Pass(); |
309 | 310 |
310 result.reset(new DictionarySet); | 311 result.reset(new DictionarySet); |
311 result->AddDictionary(it->first, it->second); | 312 result->AddDictionary(it->first, it->second); |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 entry_dict->SetInteger("tries", it->second.count); | 517 entry_dict->SetInteger("tries", it->second.count); |
517 entry_dict->SetInteger("reason", it->second.reason); | 518 entry_dict->SetInteger("reason", it->second.reason); |
518 entry_list->Append(entry_dict); | 519 entry_list->Append(entry_dict); |
519 } | 520 } |
520 value->Set("blacklisted", entry_list); | 521 value->Set("blacklisted", entry_list); |
521 | 522 |
522 return value; | 523 return value; |
523 } | 524 } |
524 | 525 |
525 } // namespace net | 526 } // namespace net |
OLD | NEW |