| 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" |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 SSLCertRequestInfo* cert_request_info) { | 116 SSLCertRequestInfo* cert_request_info) { |
| 117 request->Cancel(); | 117 request->Cancel(); |
| 118 } | 118 } |
| 119 | 119 |
| 120 void URLRequest::Delegate::OnSSLCertificateError(URLRequest* request, | 120 void URLRequest::Delegate::OnSSLCertificateError(URLRequest* request, |
| 121 const SSLInfo& ssl_info, | 121 const SSLInfo& ssl_info, |
| 122 bool is_hsts_ok) { | 122 bool is_hsts_ok) { |
| 123 request->Cancel(); | 123 request->Cancel(); |
| 124 } | 124 } |
| 125 | 125 |
| 126 bool URLRequest::Delegate::CanGetCookies(const URLRequest* request, | |
| 127 const CookieList& cookie_list) const { | |
| 128 return true; | |
| 129 } | |
| 130 | |
| 131 bool URLRequest::Delegate::CanSetCookie(const URLRequest* request, | |
| 132 const std::string& cookie_line, | |
| 133 CookieOptions* options) const { | |
| 134 return true; | |
| 135 } | |
| 136 | |
| 137 /////////////////////////////////////////////////////////////////////////////// | 126 /////////////////////////////////////////////////////////////////////////////// |
| 138 // URLRequest | 127 // URLRequest |
| 139 | 128 |
| 140 URLRequest::URLRequest(const GURL& url, Delegate* delegate) | 129 URLRequest::URLRequest(const GURL& url, Delegate* delegate) |
| 141 : url_chain_(1, url), | 130 : url_chain_(1, url), |
| 142 method_("GET"), | 131 method_("GET"), |
| 143 load_flags_(LOAD_NORMAL), | 132 load_flags_(LOAD_NORMAL), |
| 144 delegate_(delegate), | 133 delegate_(delegate), |
| 145 is_pending_(false), | 134 is_pending_(false), |
| 146 redirect_limit_(kMaxRedirects), | 135 redirect_limit_(kMaxRedirects), |
| (...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 830 delegate_->OnCertificateRequested(this, cert_request_info); | 819 delegate_->OnCertificateRequested(this, cert_request_info); |
| 831 } | 820 } |
| 832 | 821 |
| 833 void URLRequest::NotifySSLCertificateError(const SSLInfo& ssl_info, | 822 void URLRequest::NotifySSLCertificateError(const SSLInfo& ssl_info, |
| 834 bool fatal) { | 823 bool fatal) { |
| 835 if (delegate_) | 824 if (delegate_) |
| 836 delegate_->OnSSLCertificateError(this, ssl_info, fatal); | 825 delegate_->OnSSLCertificateError(this, ssl_info, fatal); |
| 837 } | 826 } |
| 838 | 827 |
| 839 bool URLRequest::CanGetCookies(const CookieList& cookie_list) const { | 828 bool URLRequest::CanGetCookies(const CookieList& cookie_list) const { |
| 840 if (delegate_) | 829 DCHECK(!(load_flags_ & LOAD_DO_NOT_SEND_COOKIES)); |
| 841 return delegate_->CanGetCookies(this, cookie_list); | 830 if (context_ && context_->network_delegate()) { |
| 831 return context_->network_delegate()->NotifyReadingCookies(this, |
| 832 cookie_list); |
| 833 } |
| 842 return false; | 834 return false; |
| 843 } | 835 } |
| 844 | 836 |
| 845 bool URLRequest::CanSetCookie(const std::string& cookie_line, | 837 bool URLRequest::CanSetCookie(const std::string& cookie_line, |
| 846 CookieOptions* options) const { | 838 CookieOptions* options) const { |
| 847 if (delegate_) | 839 DCHECK(!(load_flags_ & LOAD_DO_NOT_SAVE_COOKIES)); |
| 848 return delegate_->CanSetCookie(this, cookie_line, options); | 840 if (context_ && context_->network_delegate()) { |
| 841 return context_->network_delegate()->NotifySettingCookie(this, |
| 842 cookie_line, |
| 843 options); |
| 844 } |
| 849 return false; | 845 return false; |
| 850 } | 846 } |
| 851 | 847 |
| 852 | 848 |
| 853 void URLRequest::NotifyReadCompleted(int bytes_read) { | 849 void URLRequest::NotifyReadCompleted(int bytes_read) { |
| 854 // Notify in case the entire URL Request has been finished. | 850 // Notify in case the entire URL Request has been finished. |
| 855 if (bytes_read <= 0) | 851 if (bytes_read <= 0) |
| 856 NotifyRequestCompleted(); | 852 NotifyRequestCompleted(); |
| 857 | 853 |
| 858 if (delegate_) | 854 if (delegate_) |
| (...skipping 21 matching lines...) Expand all Loading... |
| 880 | 876 |
| 881 void URLRequest::SetUnblockedOnDelegate() { | 877 void URLRequest::SetUnblockedOnDelegate() { |
| 882 if (!blocked_on_delegate_) | 878 if (!blocked_on_delegate_) |
| 883 return; | 879 return; |
| 884 blocked_on_delegate_ = false; | 880 blocked_on_delegate_ = false; |
| 885 load_state_param_.clear(); | 881 load_state_param_.clear(); |
| 886 net_log_.EndEvent(NetLog::TYPE_URL_REQUEST_BLOCKED_ON_DELEGATE, NULL); | 882 net_log_.EndEvent(NetLog::TYPE_URL_REQUEST_BLOCKED_ON_DELEGATE, NULL); |
| 887 } | 883 } |
| 888 | 884 |
| 889 } // namespace net | 885 } // namespace net |
| OLD | NEW |