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

Unified Diff: net/url_request/url_request.cc

Issue 572273002: Move handling of invalid referrer to the network delegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updates Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/network_delegate.cc ('k') | net/url_request/url_request_test_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/url_request/url_request.cc
diff --git a/net/url_request/url_request.cc b/net/url_request/url_request.cc
index 15b9ab7d73e9aabb22f8149cc4ee9453acfa5d48..3764488a221fd9dcad0fcf59907b07c54fab50ef 100644
--- a/net/url_request/url_request.cc
+++ b/net/url_request/url_request.cc
@@ -13,7 +13,6 @@
#include "base/memory/singleton.h"
#include "base/message_loop/message_loop.h"
#include "base/metrics/stats_counters.h"
-#include "base/metrics/user_metrics.h"
#include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/synchronization/lock.h"
@@ -691,12 +690,21 @@ void URLRequest::StartJob(URLRequestJob* job) {
if (referrer_policy_ ==
CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE &&
GURL(referrer_).SchemeIsSecure() && !url().SchemeIsSecure()) {
-#if !defined(OFFICIAL_BUILD)
- LOG(FATAL) << "Trying to send secure referrer for insecure load";
-#endif
- referrer_.clear();
- base::RecordAction(
- base::UserMetricsAction("Net.URLRequest_StartJob_InvalidReferrer"));
+ if (!network_delegate_ ||
+ !network_delegate_->CancelURLRequestWithPolicyViolatingReferrerHeader(
+ *this, url(), GURL(referrer_))) {
+ referrer_.clear();
+ } else {
+ // We need to clear the referrer anyway to avoid an infinite recursion
+ // when starting the error job.
+ referrer_.clear();
+ std::string source("delegate");
+ net_log_.AddEvent(NetLog::TYPE_CANCELLED,
+ NetLog::StringCallback("source", &source));
+ RestartWithJob(new URLRequestErrorJob(
+ this, network_delegate_, ERR_BLOCKED_BY_CLIENT));
+ return;
+ }
}
// Don't allow errors to be sent from within Start().
« no previous file with comments | « net/base/network_delegate.cc ('k') | net/url_request/url_request_test_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698