| 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 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 834 | 824 |
| 835 void URLRequest::NotifySSLCertificateError(const SSLInfo& ssl_info, | 825 void URLRequest::NotifySSLCertificateError(const SSLInfo& ssl_info, |
| 836 bool fatal) { | 826 bool fatal) { |
| 837 if (delegate_) | 827 if (delegate_) |
| 838 delegate_->OnSSLCertificateError(this, ssl_info, fatal); | 828 delegate_->OnSSLCertificateError(this, ssl_info, fatal); |
| 839 } | 829 } |
| 840 | 830 |
| 841 bool URLRequest::CanGetCookies(const CookieList& cookie_list) const { | 831 bool URLRequest::CanGetCookies(const CookieList& cookie_list) const { |
| 842 DCHECK(!(load_flags_ & LOAD_DO_NOT_SEND_COOKIES)); | 832 DCHECK(!(load_flags_ & LOAD_DO_NOT_SEND_COOKIES)); |
| 843 if (context_ && context_->network_delegate()) { | 833 if (context_ && context_->network_delegate()) { |
| 844 return context_->network_delegate()->NotifyReadingCookies(this, | 834 return context_->network_delegate()->CanGetCookies(*this, |
| 845 cookie_list); | 835 cookie_list); |
| 846 } | 836 } |
| 847 return g_default_can_use_cookies; | 837 return g_default_can_use_cookies; |
| 848 } | 838 } |
| 849 | 839 |
| 850 bool URLRequest::CanSetCookie(const std::string& cookie_line, | 840 bool URLRequest::CanSetCookie(const std::string& cookie_line, |
| 851 CookieOptions* options) const { | 841 CookieOptions* options) const { |
| 852 DCHECK(!(load_flags_ & LOAD_DO_NOT_SAVE_COOKIES)); | 842 DCHECK(!(load_flags_ & LOAD_DO_NOT_SAVE_COOKIES)); |
| 853 if (context_ && context_->network_delegate()) { | 843 if (context_ && context_->network_delegate()) { |
| 854 return context_->network_delegate()->NotifySettingCookie(this, | 844 return context_->network_delegate()->CanSetCookie(*this, |
| 855 cookie_line, | 845 cookie_line, |
| 856 options); | 846 options); |
| 857 } | 847 } |
| 858 return g_default_can_use_cookies; | 848 return g_default_can_use_cookies; |
| 859 } | 849 } |
| 860 | 850 |
| 861 | 851 |
| 862 void URLRequest::NotifyReadCompleted(int bytes_read) { | 852 void URLRequest::NotifyReadCompleted(int bytes_read) { |
| 863 // Notify in case the entire URL Request has been finished. | 853 // Notify in case the entire URL Request has been finished. |
| 864 if (bytes_read <= 0) | 854 if (bytes_read <= 0) |
| (...skipping 24 matching lines...) Expand all Loading... |
| 889 | 879 |
| 890 void URLRequest::SetUnblockedOnDelegate() { | 880 void URLRequest::SetUnblockedOnDelegate() { |
| 891 if (!blocked_on_delegate_) | 881 if (!blocked_on_delegate_) |
| 892 return; | 882 return; |
| 893 blocked_on_delegate_ = false; | 883 blocked_on_delegate_ = false; |
| 894 load_state_param_.clear(); | 884 load_state_param_.clear(); |
| 895 net_log_.EndEvent(NetLog::TYPE_URL_REQUEST_BLOCKED_ON_DELEGATE, NULL); | 885 net_log_.EndEvent(NetLog::TYPE_URL_REQUEST_BLOCKED_ON_DELEGATE, NULL); |
| 896 } | 886 } |
| 897 | 887 |
| 898 } // namespace net | 888 } // namespace net |
| OLD | NEW |