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

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

Issue 9572001: Do cookie checks in NetworkDelegate instead of the URLRequest::Delegate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: TestShellNetworkDelegate Created 8 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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 if (context_ && context_->network_delegate()) {
cbentzel 2012/03/05 12:56:12 Would it make sense to DCHECK that LOAD_DO_NOT_SEN
willchan no longer on Chromium 2012/03/06 02:59:01 Agreed.
jochen (gone - plz use gerrit) 2012/03/08 13:00:02 Done.
841 return delegate_->CanGetCookies(this, cookie_list); 830 return context_->network_delegate()->NotifyReadingCookies(this,
831 cookie_list);
832 }
842 return false; 833 return false;
843 } 834 }
844 835
845 bool URLRequest::CanSetCookie(const std::string& cookie_line, 836 bool URLRequest::CanSetCookie(const std::string& cookie_line,
846 CookieOptions* options) const { 837 CookieOptions* options) const {
847 if (delegate_) 838 if (context_ && context_->network_delegate()) {
cbentzel 2012/03/05 12:56:12 Similar DCHECK for LOAD_DO_NOT_SAVE_COOKIES
willchan no longer on Chromium 2012/03/06 02:59:01 Agreed.
jochen (gone - plz use gerrit) 2012/03/08 13:00:02 Done.
848 return delegate_->CanSetCookie(this, cookie_line, options); 839 return context_->network_delegate()->NotifySettingCookie(this,
840 cookie_line,
841 options);
842 }
849 return false; 843 return false;
850 } 844 }
851 845
852 846
853 void URLRequest::NotifyReadCompleted(int bytes_read) { 847 void URLRequest::NotifyReadCompleted(int bytes_read) {
854 // Notify in case the entire URL Request has been finished. 848 // Notify in case the entire URL Request has been finished.
855 if (bytes_read <= 0) 849 if (bytes_read <= 0)
856 NotifyRequestCompleted(); 850 NotifyRequestCompleted();
857 851
858 if (delegate_) 852 if (delegate_)
(...skipping 21 matching lines...) Expand all
880 874
881 void URLRequest::SetUnblockedOnDelegate() { 875 void URLRequest::SetUnblockedOnDelegate() {
882 if (!blocked_on_delegate_) 876 if (!blocked_on_delegate_)
883 return; 877 return;
884 blocked_on_delegate_ = false; 878 blocked_on_delegate_ = false;
885 load_state_param_.clear(); 879 load_state_param_.clear();
886 net_log_.EndEvent(NetLog::TYPE_URL_REQUEST_BLOCKED_ON_DELEGATE, NULL); 880 net_log_.EndEvent(NetLog::TYPE_URL_REQUEST_BLOCKED_ON_DELEGATE, NULL);
887 } 881 }
888 882
889 } // namespace net 883 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698