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

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
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..7f76e3be19c12a3345fabe09456f65b5984948d0 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_->CanCorrectInvalidReferrerHeader(
mmenke 2014/09/16 15:05:42 I think this function name isn't clear. We only c
jochen (gone - plz use gerrit) 2014/09/16 16:27:57 That's not correct. The transition happens here: U
mmenke 2014/09/16 16:37:15 Ahh... I think that's not at all clear from the s
+ *this, url(), GURL(referrer_))) {
+ referrer_.clear();
+ } else {
+ // We need to clear the referrer anyway to avoid an infinite recursion
+ // when starting the error job.
mmenke 2014/09/16 15:05:42 nit: Don't use "we" in comments.
+ 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().

Powered by Google App Engine
This is Rietveld 408576698