| 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 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 // static | 329 // static |
| 330 bool URLRequest::IsHandledURL(const GURL& url) { | 330 bool URLRequest::IsHandledURL(const GURL& url) { |
| 331 if (!url.is_valid()) { | 331 if (!url.is_valid()) { |
| 332 // We handle error cases. | 332 // We handle error cases. |
| 333 return true; | 333 return true; |
| 334 } | 334 } |
| 335 | 335 |
| 336 return IsHandledProtocol(url.scheme()); | 336 return IsHandledProtocol(url.scheme()); |
| 337 } | 337 } |
| 338 | 338 |
| 339 // static | |
| 340 void URLRequest::AllowFileAccess() { | |
| 341 URLRequestJobManager::GetInstance()->set_enable_file_access(true); | |
| 342 } | |
| 343 | |
| 344 // static | |
| 345 bool URLRequest::IsFileAccessAllowed() { | |
| 346 return URLRequestJobManager::GetInstance()->enable_file_access(); | |
| 347 } | |
| 348 | |
| 349 void URLRequest::set_first_party_for_cookies( | 339 void URLRequest::set_first_party_for_cookies( |
| 350 const GURL& first_party_for_cookies) { | 340 const GURL& first_party_for_cookies) { |
| 351 first_party_for_cookies_ = first_party_for_cookies; | 341 first_party_for_cookies_ = first_party_for_cookies; |
| 352 } | 342 } |
| 353 | 343 |
| 354 void URLRequest::set_method(const std::string& method) { | 344 void URLRequest::set_method(const std::string& method) { |
| 355 DCHECK(!is_pending_); | 345 DCHECK(!is_pending_); |
| 356 method_ = method; | 346 method_ = method; |
| 357 } | 347 } |
| 358 | 348 |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 821 | 811 |
| 822 void URLRequest::NotifySSLCertificateError(const SSLInfo& ssl_info, | 812 void URLRequest::NotifySSLCertificateError(const SSLInfo& ssl_info, |
| 823 bool fatal) { | 813 bool fatal) { |
| 824 if (delegate_) | 814 if (delegate_) |
| 825 delegate_->OnSSLCertificateError(this, ssl_info, fatal); | 815 delegate_->OnSSLCertificateError(this, ssl_info, fatal); |
| 826 } | 816 } |
| 827 | 817 |
| 828 bool URLRequest::CanGetCookies(const CookieList& cookie_list) const { | 818 bool URLRequest::CanGetCookies(const CookieList& cookie_list) const { |
| 829 DCHECK(!(load_flags_ & LOAD_DO_NOT_SEND_COOKIES)); | 819 DCHECK(!(load_flags_ & LOAD_DO_NOT_SEND_COOKIES)); |
| 830 if (context_ && context_->network_delegate()) { | 820 if (context_ && context_->network_delegate()) { |
| 831 return context_->network_delegate()->NotifyReadingCookies(this, | 821 return context_->network_delegate()->NotifyReadingCookies(*this, |
| 832 cookie_list); | 822 cookie_list); |
| 833 } | 823 } |
| 834 return false; | 824 return false; |
| 835 } | 825 } |
| 836 | 826 |
| 837 bool URLRequest::CanSetCookie(const std::string& cookie_line, | 827 bool URLRequest::CanSetCookie(const std::string& cookie_line, |
| 838 CookieOptions* options) const { | 828 CookieOptions* options) const { |
| 839 DCHECK(!(load_flags_ & LOAD_DO_NOT_SAVE_COOKIES)); | 829 DCHECK(!(load_flags_ & LOAD_DO_NOT_SAVE_COOKIES)); |
| 840 if (context_ && context_->network_delegate()) { | 830 if (context_ && context_->network_delegate()) { |
| 841 return context_->network_delegate()->NotifySettingCookie(this, | 831 return context_->network_delegate()->NotifySettingCookie(*this, |
| 842 cookie_line, | 832 cookie_line, |
| 843 options); | 833 options); |
| 844 } | 834 } |
| 845 return false; | 835 return false; |
| 846 } | 836 } |
| 847 | 837 |
| 848 | 838 |
| 849 void URLRequest::NotifyReadCompleted(int bytes_read) { | 839 void URLRequest::NotifyReadCompleted(int bytes_read) { |
| 850 // Notify in case the entire URL Request has been finished. | 840 // Notify in case the entire URL Request has been finished. |
| 851 if (bytes_read <= 0) | 841 if (bytes_read <= 0) |
| (...skipping 24 matching lines...) Expand all Loading... |
| 876 | 866 |
| 877 void URLRequest::SetUnblockedOnDelegate() { | 867 void URLRequest::SetUnblockedOnDelegate() { |
| 878 if (!blocked_on_delegate_) | 868 if (!blocked_on_delegate_) |
| 879 return; | 869 return; |
| 880 blocked_on_delegate_ = false; | 870 blocked_on_delegate_ = false; |
| 881 load_state_param_.clear(); | 871 load_state_param_.clear(); |
| 882 net_log_.EndEvent(NetLog::TYPE_URL_REQUEST_BLOCKED_ON_DELEGATE, NULL); | 872 net_log_.EndEvent(NetLog::TYPE_URL_REQUEST_BLOCKED_ON_DELEGATE, NULL); |
| 883 } | 873 } |
| 884 | 874 |
| 885 } // namespace net | 875 } // namespace net |
| OLD | NEW |