| 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 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 // static | 341 // static |
| 342 bool URLRequest::IsHandledURL(const GURL& url) { | 342 bool URLRequest::IsHandledURL(const GURL& url) { |
| 343 if (!url.is_valid()) { | 343 if (!url.is_valid()) { |
| 344 // We handle error cases. | 344 // We handle error cases. |
| 345 return true; | 345 return true; |
| 346 } | 346 } |
| 347 | 347 |
| 348 return IsHandledProtocol(url.scheme()); | 348 return IsHandledProtocol(url.scheme()); |
| 349 } | 349 } |
| 350 | 350 |
| 351 // static | |
| 352 void URLRequest::AllowFileAccess() { | |
| 353 URLRequestJobManager::GetInstance()->set_enable_file_access(true); | |
| 354 } | |
| 355 | |
| 356 // static | |
| 357 bool URLRequest::IsFileAccessAllowed() { | |
| 358 return URLRequestJobManager::GetInstance()->enable_file_access(); | |
| 359 } | |
| 360 | |
| 361 void URLRequest::set_first_party_for_cookies( | 351 void URLRequest::set_first_party_for_cookies( |
| 362 const GURL& first_party_for_cookies) { | 352 const GURL& first_party_for_cookies) { |
| 363 first_party_for_cookies_ = first_party_for_cookies; | 353 first_party_for_cookies_ = first_party_for_cookies; |
| 364 } | 354 } |
| 365 | 355 |
| 366 void URLRequest::set_method(const std::string& method) { | 356 void URLRequest::set_method(const std::string& method) { |
| 367 DCHECK(!is_pending_); | 357 DCHECK(!is_pending_); |
| 368 method_ = method; | 358 method_ = method; |
| 369 } | 359 } |
| 370 | 360 |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 855 | 845 |
| 856 void URLRequest::NotifySSLCertificateError(const SSLInfo& ssl_info, | 846 void URLRequest::NotifySSLCertificateError(const SSLInfo& ssl_info, |
| 857 bool fatal) { | 847 bool fatal) { |
| 858 if (delegate_) | 848 if (delegate_) |
| 859 delegate_->OnSSLCertificateError(this, ssl_info, fatal); | 849 delegate_->OnSSLCertificateError(this, ssl_info, fatal); |
| 860 } | 850 } |
| 861 | 851 |
| 862 bool URLRequest::CanGetCookies(const CookieList& cookie_list) const { | 852 bool URLRequest::CanGetCookies(const CookieList& cookie_list) const { |
| 863 DCHECK(!(load_flags_ & LOAD_DO_NOT_SEND_COOKIES)); | 853 DCHECK(!(load_flags_ & LOAD_DO_NOT_SEND_COOKIES)); |
| 864 if (context_ && context_->network_delegate()) { | 854 if (context_ && context_->network_delegate()) { |
| 865 return context_->network_delegate()->NotifyReadingCookies(this, | 855 return context_->network_delegate()->CanGetCookies(*this, |
| 866 cookie_list); | 856 cookie_list); |
| 867 } | 857 } |
| 868 return g_default_can_use_cookies; | 858 return g_default_can_use_cookies; |
| 869 } | 859 } |
| 870 | 860 |
| 871 bool URLRequest::CanSetCookie(const std::string& cookie_line, | 861 bool URLRequest::CanSetCookie(const std::string& cookie_line, |
| 872 CookieOptions* options) const { | 862 CookieOptions* options) const { |
| 873 DCHECK(!(load_flags_ & LOAD_DO_NOT_SAVE_COOKIES)); | 863 DCHECK(!(load_flags_ & LOAD_DO_NOT_SAVE_COOKIES)); |
| 874 if (context_ && context_->network_delegate()) { | 864 if (context_ && context_->network_delegate()) { |
| 875 return context_->network_delegate()->NotifySettingCookie(this, | 865 return context_->network_delegate()->CanSetCookie(*this, |
| 876 cookie_line, | 866 cookie_line, |
| 877 options); | 867 options); |
| 878 } | 868 } |
| 879 return g_default_can_use_cookies; | 869 return g_default_can_use_cookies; |
| 880 } | 870 } |
| 881 | 871 |
| 882 | 872 |
| 883 void URLRequest::NotifyReadCompleted(int bytes_read) { | 873 void URLRequest::NotifyReadCompleted(int bytes_read) { |
| 884 // Notify in case the entire URL Request has been finished. | 874 // Notify in case the entire URL Request has been finished. |
| 885 if (bytes_read <= 0) | 875 if (bytes_read <= 0) |
| (...skipping 24 matching lines...) Expand all Loading... |
| 910 | 900 |
| 911 void URLRequest::SetUnblockedOnDelegate() { | 901 void URLRequest::SetUnblockedOnDelegate() { |
| 912 if (!blocked_on_delegate_) | 902 if (!blocked_on_delegate_) |
| 913 return; | 903 return; |
| 914 blocked_on_delegate_ = false; | 904 blocked_on_delegate_ = false; |
| 915 load_state_param_.clear(); | 905 load_state_param_.clear(); |
| 916 net_log_.EndEvent(NetLog::TYPE_URL_REQUEST_BLOCKED_ON_DELEGATE, NULL); | 906 net_log_.EndEvent(NetLog::TYPE_URL_REQUEST_BLOCKED_ON_DELEGATE, NULL); |
| 917 } | 907 } |
| 918 | 908 |
| 919 } // namespace net | 909 } // namespace net |
| OLD | NEW |