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

Side by Side 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: address code review comments Created 7 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 | Annotate | Revision Log
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 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 void URLRequest::set_first_party_for_cookies( 419 void URLRequest::set_first_party_for_cookies(
420 const GURL& first_party_for_cookies) { 420 const GURL& first_party_for_cookies) {
421 first_party_for_cookies_ = first_party_for_cookies; 421 first_party_for_cookies_ = first_party_for_cookies;
422 } 422 }
423 423
424 void URLRequest::set_method(const std::string& method) { 424 void URLRequest::set_method(const std::string& method) {
425 DCHECK(!is_pending_); 425 DCHECK(!is_pending_);
426 method_ = method; 426 method_ = method;
427 } 427 }
428 428
429 void URLRequest::set_referrer(const std::string& referrer) { 429 void URLRequest::SetReferrer(const std::string& referrer) {
430 DCHECK(!is_pending_); 430 DCHECK(!is_pending_);
431 referrer_ = referrer; 431 referrer_ = referrer;
432 } 432 // Ensure that we do not send url fragment,
pauljensen 2013/03/15 13:37:45 Please capitalize URL. Can we put "username and p
mef 2013/03/15 16:36:42 Done.
433 433 // username and password fields in the referrer.
434 GURL URLRequest::GetSanitizedReferrer() const { 434 GURL referrer_url(referrer);
435 GURL ret(referrer()); 435 if (referrer_url.is_valid() && (referrer_url.has_ref() ||
436 436 referrer_url.has_username() || referrer_url.has_password())) {
437 // Ensure that we do not send username and password fields in the referrer.
438 if (ret.has_username() || ret.has_password()) {
439 GURL::Replacements referrer_mods; 437 GURL::Replacements referrer_mods;
438 referrer_mods.ClearRef();
440 referrer_mods.ClearUsername(); 439 referrer_mods.ClearUsername();
441 referrer_mods.ClearPassword(); 440 referrer_mods.ClearPassword();
442 ret = ret.ReplaceComponents(referrer_mods); 441 referrer_url = referrer_url.ReplaceComponents(referrer_mods);
442 referrer_ = referrer_url.spec();
443 } 443 }
444
445 return ret;
446 } 444 }
447 445
448 void URLRequest::set_referrer_policy(ReferrerPolicy referrer_policy) { 446 void URLRequest::set_referrer_policy(ReferrerPolicy referrer_policy) {
449 DCHECK(!is_pending_); 447 DCHECK(!is_pending_);
450 referrer_policy_ = referrer_policy; 448 referrer_policy_ = referrer_policy;
451 } 449 }
452 450
453 void URLRequest::set_delegate(Delegate* delegate) { 451 void URLRequest::set_delegate(Delegate* delegate) {
454 delegate_ = delegate; 452 delegate_ = delegate;
455 } 453 }
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 new base::debug::StackTrace(NULL, 0); 996 new base::debug::StackTrace(NULL, 0);
999 *stack_trace_copy = stack_trace; 997 *stack_trace_copy = stack_trace;
1000 stack_trace_.reset(stack_trace_copy); 998 stack_trace_.reset(stack_trace_copy);
1001 } 999 }
1002 1000
1003 const base::debug::StackTrace* URLRequest::stack_trace() const { 1001 const base::debug::StackTrace* URLRequest::stack_trace() const {
1004 return stack_trace_.get(); 1002 return stack_trace_.get();
1005 } 1003 }
1006 1004
1007 } // namespace net 1005 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698