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

Side by Side Diff: net/url_request/url_request.cc

Issue 185133005: Move referrer stripping into GURL::GetAsReferrer(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Switch over the Android ContextMenuHelper. Created 6 years, 9 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 | « chrome/browser/ui/android/context_menu_helper.cc ('k') | url/gurl.h » ('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 "net/url_request/url_request.h" 5 #include "net/url_request/url_request.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 if ((http_status_code == 303 && method != "HEAD") || 601 if ((http_status_code == 303 && method != "HEAD") ||
602 ((http_status_code == 301 || http_status_code == 302) && 602 ((http_status_code == 301 || http_status_code == 302) &&
603 method == "POST")) { 603 method == "POST")) {
604 return "GET"; 604 return "GET";
605 } 605 }
606 return method; 606 return method;
607 } 607 }
608 608
609 void URLRequest::SetReferrer(const std::string& referrer) { 609 void URLRequest::SetReferrer(const std::string& referrer) {
610 DCHECK(!is_pending_); 610 DCHECK(!is_pending_);
611 referrer_ = referrer;
612 // Ensure that we do not send URL fragment, username and password 611 // Ensure that we do not send URL fragment, username and password
gavinp 2014/03/17 10:51:35 This comment is now subsumed by the definition of
ppi 2014/03/20 10:50:56 Done.
613 // fields in the referrer. 612 // fields in the referrer.
614 GURL referrer_url(referrer); 613 GURL referrer_url(referrer);
615 UMA_HISTOGRAM_BOOLEAN("Net.URLRequest_SetReferrer_IsEmptyOrValid", 614 UMA_HISTOGRAM_BOOLEAN("Net.URLRequest_SetReferrer_IsEmptyOrValid",
616 referrer_url.is_empty() || referrer_url.is_valid()); 615 referrer_url.is_empty() || referrer_url.is_valid());
617 if (referrer_url.is_valid() && (referrer_url.has_ref() || 616 referrer_ = referrer_url.GetAsReferrer().spec();
618 referrer_url.has_username() || referrer_url.has_password())) {
619 GURL::Replacements referrer_mods;
620 referrer_mods.ClearRef();
621 referrer_mods.ClearUsername();
622 referrer_mods.ClearPassword();
623 referrer_url = referrer_url.ReplaceComponents(referrer_mods);
624 referrer_ = referrer_url.spec();
625 }
626 } 617 }
627 618
628 void URLRequest::set_referrer_policy(ReferrerPolicy referrer_policy) { 619 void URLRequest::set_referrer_policy(ReferrerPolicy referrer_policy) {
629 DCHECK(!is_pending_); 620 DCHECK(!is_pending_);
630 referrer_policy_ = referrer_policy; 621 referrer_policy_ = referrer_policy;
631 } 622 }
632 623
633 void URLRequest::set_delegate(Delegate* delegate) { 624 void URLRequest::set_delegate(Delegate* delegate) {
634 delegate_ = delegate; 625 delegate_ = delegate;
635 } 626 }
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
1256 new base::debug::StackTrace(NULL, 0); 1247 new base::debug::StackTrace(NULL, 0);
1257 *stack_trace_copy = stack_trace; 1248 *stack_trace_copy = stack_trace;
1258 stack_trace_.reset(stack_trace_copy); 1249 stack_trace_.reset(stack_trace_copy);
1259 } 1250 }
1260 1251
1261 const base::debug::StackTrace* URLRequest::stack_trace() const { 1252 const base::debug::StackTrace* URLRequest::stack_trace() const {
1262 return stack_trace_.get(); 1253 return stack_trace_.get();
1263 } 1254 }
1264 1255
1265 } // namespace net 1256 } // namespace net
OLDNEW
« no previous file with comments | « chrome/browser/ui/android/context_menu_helper.cc ('k') | url/gurl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698