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

Side by Side Diff: chrome/browser/net/predictor.cc

Issue 2022963003: [predictor] Apply HSTS redirects when learning referrers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add comment Created 4 years, 6 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
« no previous file with comments | « no previous file | chrome/browser/net/predictor_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "chrome/browser/net/predictor.h" 5 #include "chrome/browser/net/predictor.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <set> 9 #include <set>
10 #include <sstream> 10 #include <sstream>
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 void Predictor::LearnFromNavigation(const GURL& referring_url, 465 void Predictor::LearnFromNavigation(const GURL& referring_url,
466 const GURL& target_url) { 466 const GURL& target_url) {
467 DCHECK_CURRENTLY_ON(BrowserThread::IO); 467 DCHECK_CURRENTLY_ON(BrowserThread::IO);
468 if (!predictor_enabled_ || !CanPreresolveAndPreconnect()) 468 if (!predictor_enabled_ || !CanPreresolveAndPreconnect())
469 return; 469 return;
470 DCHECK_EQ(referring_url, Predictor::CanonicalizeUrl(referring_url)); 470 DCHECK_EQ(referring_url, Predictor::CanonicalizeUrl(referring_url));
471 DCHECK_NE(referring_url, GURL::EmptyGURL()); 471 DCHECK_NE(referring_url, GURL::EmptyGURL());
472 DCHECK_EQ(target_url, Predictor::CanonicalizeUrl(target_url)); 472 DCHECK_EQ(target_url, Predictor::CanonicalizeUrl(target_url));
473 DCHECK_NE(target_url, GURL::EmptyGURL()); 473 DCHECK_NE(target_url, GURL::EmptyGURL());
474 474
475 // Skip HSTS redirects to learn the true referrer.
476 GURL referring_url_with_hsts = GetHSTSRedirectOnIOThread(referring_url);
477
475 if (observer_) 478 if (observer_)
476 observer_->OnLearnFromNavigation(referring_url, target_url); 479 observer_->OnLearnFromNavigation(referring_url_with_hsts, target_url);
477 referrers_[referring_url].SuggestHost(target_url); 480 referrers_[referring_url_with_hsts].SuggestHost(target_url);
478 // Possibly do some referrer trimming. 481 // Possibly do some referrer trimming.
479 TrimReferrers(); 482 TrimReferrers();
480 } 483 }
481 484
482 //----------------------------------------------------------------------------- 485 //-----------------------------------------------------------------------------
483 // This section supports the about:dns page. 486 // This section supports the about:dns page.
484 487
485 void Predictor::PredictorGetHtmlInfo(Predictor* predictor, 488 void Predictor::PredictorGetHtmlInfo(Predictor* predictor,
486 std::string* output) { 489 std::string* output) {
487 DCHECK_CURRENTLY_ON(BrowserThread::IO); 490 DCHECK_CURRENTLY_ON(BrowserThread::IO);
(...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after
1361 } 1364 }
1362 1365
1363 void SimplePredictor::ShutdownOnUIThread() { 1366 void SimplePredictor::ShutdownOnUIThread() {
1364 SetShutdown(true); 1367 SetShutdown(true);
1365 } 1368 }
1366 1369
1367 bool SimplePredictor::CanPrefetchAndPrerender() const { return true; } 1370 bool SimplePredictor::CanPrefetchAndPrerender() const { return true; }
1368 bool SimplePredictor::CanPreresolveAndPreconnect() const { return true; } 1371 bool SimplePredictor::CanPreresolveAndPreconnect() const { return true; }
1369 1372
1370 } // namespace chrome_browser_net 1373 } // namespace chrome_browser_net
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/net/predictor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698