Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: net/base/sdch_manager.cc

Issue 20254: Fetch SDCH dictionary as soon as current URL fetch completes... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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& referring_url, 175 void SdchManager::FetchDictionary(const GURL& dictionary_url) {
176 const GURL& dictionary_url) {
177 if (!CanFetchDictionary(referring_url, dictionary_url))
178 return;
179 if (fetcher_.get()) 176 if (fetcher_.get())
180 fetcher_->Schedule(dictionary_url); 177 fetcher_->Schedule(dictionary_url);
181 } 178 }
182 179
183 bool SdchManager::AddSdchDictionary(const std::string& dictionary_text, 180 bool SdchManager::AddSdchDictionary(const std::string& dictionary_text,
184 const GURL& dictionary_url) { 181 const GURL& dictionary_url) {
185 std::string client_hash; 182 std::string client_hash;
186 std::string server_hash; 183 std::string server_hash;
187 GenerateHash(dictionary_text, &client_hash, &server_hash); 184 GenerateHash(dictionary_text, &client_hash, &server_hash);
188 if (dictionaries_.find(server_hash) != dictionaries_.end()) { 185 if (dictionaries_.find(server_hash) != dictionaries_.end()) {
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 1. The dictionary has no Domain attribute. 369 1. The dictionary has no Domain attribute.
373 2. The effective host name that derives from the referer URL host name does 370 2. The effective host name that derives from the referer URL host name does
374 not domain-match the Domain attribute. 371 not domain-match the Domain attribute.
375 3. The Domain attribute is a top level domain. 372 3. The Domain attribute is a top level domain.
376 4. The referer URL host is a host domain name (not IP address) and has the 373 4. The referer URL host is a host domain name (not IP address) and has the
377 form HD, where D is the value of the Domain attribute, and H is a string 374 form HD, where D is the value of the Domain attribute, and H is a string
378 that contains one or more dots. 375 that contains one or more dots.
379 5. If the dictionary has a Port attribute and the referer URL's port was not 376 5. If the dictionary has a Port attribute and the referer URL's port was not
380 in the list. 377 in the list.
381 */ 378 */
379
380 // TODO(jar): Redirects in dictionary fetches might plausibly be problematic,
381 // and hence the conservative approach is to not allow any redirects (if there
382 // were any... then don't allow the dictionary to be set).
383
382 if (domain.empty()) { 384 if (domain.empty()) {
383 SdchErrorRecovery(DICTIONARY_MISSING_DOMAIN_SPECIFIER); 385 SdchErrorRecovery(DICTIONARY_MISSING_DOMAIN_SPECIFIER);
384 return false; // Domain is required. 386 return false; // Domain is required.
385 } 387 }
386 if (net::RegistryControlledDomainService::GetDomainAndRegistry(domain).size() 388 if (net::RegistryControlledDomainService::GetDomainAndRegistry(domain).size()
387 == 0) { 389 == 0) {
388 SdchErrorRecovery(DICTIONARY_SPECIFIES_TOP_LEVEL_DOMAIN); 390 SdchErrorRecovery(DICTIONARY_SPECIFIES_TOP_LEVEL_DOMAIN);
389 return false; // domain was a TLD. 391 return false; // domain was a TLD.
390 } 392 }
391 if (!Dictionary::DomainMatch(dictionary_url, domain)) { 393 if (!Dictionary::DomainMatch(dictionary_url, domain)) {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 return false; 498 return false;
497 return restriction[prefix_length - 1] == '/' || path[prefix_length] == '/'; 499 return restriction[prefix_length - 1] == '/' || path[prefix_length] == '/';
498 } 500 }
499 501
500 // static 502 // static
501 bool SdchManager::Dictionary::DomainMatch(const GURL& gurl, 503 bool SdchManager::Dictionary::DomainMatch(const GURL& gurl,
502 const std::string& restriction) { 504 const std::string& restriction) {
503 // TODO(jar): This is not precisely a domain match definition. 505 // TODO(jar): This is not precisely a domain match definition.
504 return gurl.DomainIs(restriction.data(), restriction.size()); 506 return gurl.DomainIs(restriction.data(), restriction.size());
505 } 507 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698