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

Unified Diff: net/url_request/url_request.cc

Issue 12569007: Remove URL fragment from referrer HTTP header when opening link using "Open Link in New Tab" option. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync up to rev 193385 Created 7 years, 8 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/url_request/url_request.h ('k') | net/url_request/url_request_http_job.cc » ('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 c912c03673f1d8773f0b2cd1b1085b48e102eaf9..8af248c6c0cf18fa8f7045af396b688edde692c7 100644
--- a/net/url_request/url_request.cc
+++ b/net/url_request/url_request.cc
@@ -12,6 +12,7 @@
#include "base/lazy_instance.h"
#include "base/memory/singleton.h"
#include "base/message_loop.h"
+#include "base/metrics/histogram.h"
#include "base/metrics/stats_counters.h"
#include "base/stl_util.h"
#include "base/synchronization/lock.h"
@@ -488,23 +489,23 @@ void URLRequest::set_method(const std::string& method) {
method_ = method;
}
-void URLRequest::set_referrer(const std::string& referrer) {
+void URLRequest::SetReferrer(const std::string& referrer) {
DCHECK(!is_pending_);
referrer_ = referrer;
-}
-
-GURL URLRequest::GetSanitizedReferrer() const {
- GURL ret(referrer());
-
- // Ensure that we do not send username and password fields in the referrer.
- if (ret.has_username() || ret.has_password()) {
+ // Ensure that we do not send URL fragment, username and password
+ // fields in the referrer.
+ GURL referrer_url(referrer);
+ UMA_HISTOGRAM_BOOLEAN("Net.URLRequest_SetReferrer_IsEmptyOrValid",
+ referrer_url.is_empty() || referrer_url.is_valid());
+ if (referrer_url.is_valid() && (referrer_url.has_ref() ||
+ referrer_url.has_username() || referrer_url.has_password())) {
GURL::Replacements referrer_mods;
+ referrer_mods.ClearRef();
referrer_mods.ClearUsername();
referrer_mods.ClearPassword();
- ret = ret.ReplaceComponents(referrer_mods);
+ referrer_url = referrer_url.ReplaceComponents(referrer_mods);
+ referrer_ = referrer_url.spec();
}
-
- return ret;
}
void URLRequest::set_referrer_policy(ReferrerPolicy referrer_policy) {
« no previous file with comments | « net/url_request/url_request.h ('k') | net/url_request/url_request_http_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698