| OLD | NEW |
| 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" |
| 11 #include "base/debug/stack_trace.h" | 11 #include "base/debug/stack_trace.h" |
| 12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
| 13 #include "base/memory/singleton.h" | 13 #include "base/memory/singleton.h" |
| 14 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
| 15 #include "base/metrics/histogram.h" |
| 15 #include "base/metrics/stats_counters.h" | 16 #include "base/metrics/stats_counters.h" |
| 16 #include "base/stl_util.h" | 17 #include "base/stl_util.h" |
| 17 #include "base/synchronization/lock.h" | 18 #include "base/synchronization/lock.h" |
| 18 #include "net/base/auth.h" | 19 #include "net/base/auth.h" |
| 19 #include "net/base/host_port_pair.h" | 20 #include "net/base/host_port_pair.h" |
| 20 #include "net/base/load_flags.h" | 21 #include "net/base/load_flags.h" |
| 21 #include "net/base/load_timing_info.h" | 22 #include "net/base/load_timing_info.h" |
| 22 #include "net/base/net_errors.h" | 23 #include "net/base/net_errors.h" |
| 23 #include "net/base/net_log.h" | 24 #include "net/base/net_log.h" |
| 24 #include "net/base/network_change_notifier.h" | 25 #include "net/base/network_change_notifier.h" |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 void URLRequest::set_first_party_for_cookies( | 482 void URLRequest::set_first_party_for_cookies( |
| 482 const GURL& first_party_for_cookies) { | 483 const GURL& first_party_for_cookies) { |
| 483 first_party_for_cookies_ = first_party_for_cookies; | 484 first_party_for_cookies_ = first_party_for_cookies; |
| 484 } | 485 } |
| 485 | 486 |
| 486 void URLRequest::set_method(const std::string& method) { | 487 void URLRequest::set_method(const std::string& method) { |
| 487 DCHECK(!is_pending_); | 488 DCHECK(!is_pending_); |
| 488 method_ = method; | 489 method_ = method; |
| 489 } | 490 } |
| 490 | 491 |
| 491 void URLRequest::set_referrer(const std::string& referrer) { | 492 void URLRequest::SetReferrer(const std::string& referrer) { |
| 492 DCHECK(!is_pending_); | 493 DCHECK(!is_pending_); |
| 493 referrer_ = referrer; | 494 referrer_ = referrer; |
| 494 } | 495 // Ensure that we do not send URL fragment, username and password |
| 495 | 496 // fields in the referrer. |
| 496 GURL URLRequest::GetSanitizedReferrer() const { | 497 GURL referrer_url(referrer); |
| 497 GURL ret(referrer()); | 498 UMA_HISTOGRAM_BOOLEAN("Net.URLRequest_SetReferrer_IsEmptyOrValid", |
| 498 | 499 referrer_url.is_empty() || referrer_url.is_valid()); |
| 499 // Ensure that we do not send username and password fields in the referrer. | 500 if (referrer_url.is_valid() && (referrer_url.has_ref() || |
| 500 if (ret.has_username() || ret.has_password()) { | 501 referrer_url.has_username() || referrer_url.has_password())) { |
| 501 GURL::Replacements referrer_mods; | 502 GURL::Replacements referrer_mods; |
| 503 referrer_mods.ClearRef(); |
| 502 referrer_mods.ClearUsername(); | 504 referrer_mods.ClearUsername(); |
| 503 referrer_mods.ClearPassword(); | 505 referrer_mods.ClearPassword(); |
| 504 ret = ret.ReplaceComponents(referrer_mods); | 506 referrer_url = referrer_url.ReplaceComponents(referrer_mods); |
| 507 referrer_ = referrer_url.spec(); |
| 505 } | 508 } |
| 506 | |
| 507 return ret; | |
| 508 } | 509 } |
| 509 | 510 |
| 510 void URLRequest::set_referrer_policy(ReferrerPolicy referrer_policy) { | 511 void URLRequest::set_referrer_policy(ReferrerPolicy referrer_policy) { |
| 511 DCHECK(!is_pending_); | 512 DCHECK(!is_pending_); |
| 512 referrer_policy_ = referrer_policy; | 513 referrer_policy_ = referrer_policy; |
| 513 } | 514 } |
| 514 | 515 |
| 515 void URLRequest::set_delegate(Delegate* delegate) { | 516 void URLRequest::set_delegate(Delegate* delegate) { |
| 516 delegate_ = delegate; | 517 delegate_ = delegate; |
| 517 } | 518 } |
| (...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1077 new base::debug::StackTrace(NULL, 0); | 1078 new base::debug::StackTrace(NULL, 0); |
| 1078 *stack_trace_copy = stack_trace; | 1079 *stack_trace_copy = stack_trace; |
| 1079 stack_trace_.reset(stack_trace_copy); | 1080 stack_trace_.reset(stack_trace_copy); |
| 1080 } | 1081 } |
| 1081 | 1082 |
| 1082 const base::debug::StackTrace* URLRequest::stack_trace() const { | 1083 const base::debug::StackTrace* URLRequest::stack_trace() const { |
| 1083 return stack_trace_.get(); | 1084 return stack_trace_.get(); |
| 1084 } | 1085 } |
| 1085 | 1086 |
| 1086 } // namespace net | 1087 } // namespace net |
| OLD | NEW |