Chromium Code Reviews| 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 "android_webview/browser/net/aw_url_request_job_factory.h" | 5 #include "android_webview/browser/net/aw_url_request_job_factory.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
| 10 #include "net/url_request/url_request_error_job.h" | 10 #include "net/url_request/url_request_error_job.h" |
| 11 #include "net/url_request/url_request_job_factory_impl.h" | 11 #include "net/url_request/url_request_job_factory_impl.h" |
| 12 #include "net/url_request/url_request_job_manager.h" | 12 #include "net/url_request/url_request_job_manager.h" |
| 13 | 13 |
| 14 using net::NetworkDelegate; | 14 using net::NetworkDelegate; |
| 15 using net::URLRequest; | 15 using net::URLRequest; |
| 16 using net::URLRequestJob; | 16 using net::URLRequestJob; |
| 17 | 17 |
| 18 namespace android_webview { | 18 namespace android_webview { |
| 19 | 19 |
| 20 AwURLRequestJobFactory::AwURLRequestJobFactory() | 20 AwURLRequestJobFactory::AwURLRequestJobFactory() |
| 21 : next_factory_(new net::URLRequestJobFactoryImpl()) { | 21 : next_factory_(new net::URLRequestJobFactoryImpl()) { |
| 22 } | 22 } |
| 23 | 23 |
| 24 AwURLRequestJobFactory::~AwURLRequestJobFactory() { | 24 AwURLRequestJobFactory::~AwURLRequestJobFactory() { |
| 25 } | 25 } |
| 26 | 26 |
| 27 bool AwURLRequestJobFactory::IsHandledProtocol( | 27 bool AwURLRequestJobFactory::IsHandledProtocol( |
| 28 const std::string& scheme) const { | 28 const std::string& scheme) const { |
| 29 // This introduces a dependency on the URLRequestJobManager | |
| 30 // implementation. The assumption is that if true is returned from this | |
| 31 // method it is still valid to return NULL from the | |
| 32 // MaybeCreateJobWithProtocolHandler method and in that case the | |
| 33 // URLRequestJobManager will try and create the URLRequestJob by using the | |
| 34 // set of built in handlers. | |
| 35 return true; | 29 return true; |
| 36 } | 30 } |
| 37 | 31 |
| 38 bool AwURLRequestJobFactory::IsHandledURL(const GURL& url) const { | 32 bool AwURLRequestJobFactory::IsHandledURL(const GURL& url) const { |
| 39 return true; | 33 return true; |
| 40 } | 34 } |
| 41 | 35 |
| 42 URLRequestJob* AwURLRequestJobFactory::MaybeCreateJobWithProtocolHandler( | 36 URLRequestJob* AwURLRequestJobFactory::MaybeCreateJobWithProtocolHandler( |
| 43 const std::string& scheme, | 37 const std::string& scheme, |
| 44 URLRequest* request, | 38 URLRequest* request, |
| 45 NetworkDelegate* network_delegate) const { | 39 NetworkDelegate* network_delegate) const { |
| 46 URLRequestJob* job = next_factory_->MaybeCreateJobWithProtocolHandler( | 40 URLRequestJob* job = next_factory_->MaybeCreateJobWithProtocolHandler( |
| 47 scheme, request, network_delegate); | 41 scheme, request, network_delegate); |
| 48 | 42 |
| 49 if (job) | 43 if (job) |
| 50 return job; | 44 return job; |
|
mmenke
2016/04/22 18:37:52
This will switch some failures from ERR_FAILED to
| |
| 51 | 45 |
| 52 // If a URLRequestJobManager built-in factory supports the scheme, NULL should | |
| 53 // be returned from this method. | |
| 54 // In that case the built in handlers will then be used to create the job. | |
| 55 // TODO(mgersh): remove this check once HttpProtocolHandler exists and is | |
| 56 // added to the relevant URLRequestJobFactory. | |
| 57 // NOTE(joth): See the assumption in IsHandledProtocol above. | |
| 58 if (next_factory_->IsHandledProtocol(scheme)) | |
| 59 return NULL; | |
| 60 | |
| 61 return new net::URLRequestErrorJob( | 46 return new net::URLRequestErrorJob( |
| 62 request, network_delegate, net::ERR_UNKNOWN_URL_SCHEME); | 47 request, network_delegate, net::ERR_UNKNOWN_URL_SCHEME); |
| 63 } | 48 } |
| 64 | 49 |
| 65 net::URLRequestJob* AwURLRequestJobFactory::MaybeInterceptRedirect( | 50 net::URLRequestJob* AwURLRequestJobFactory::MaybeInterceptRedirect( |
| 66 net::URLRequest* request, | 51 net::URLRequest* request, |
| 67 net::NetworkDelegate* network_delegate, | 52 net::NetworkDelegate* network_delegate, |
| 68 const GURL& location) const { | 53 const GURL& location) const { |
| 69 return next_factory_->MaybeInterceptRedirect( | 54 return next_factory_->MaybeInterceptRedirect( |
| 70 request, network_delegate, location); | 55 request, network_delegate, location); |
| 71 } | 56 } |
| 72 | 57 |
| 73 net::URLRequestJob* AwURLRequestJobFactory::MaybeInterceptResponse( | 58 net::URLRequestJob* AwURLRequestJobFactory::MaybeInterceptResponse( |
| 74 net::URLRequest* request, | 59 net::URLRequest* request, |
| 75 net::NetworkDelegate* network_delegate) const { | 60 net::NetworkDelegate* network_delegate) const { |
| 76 return next_factory_->MaybeInterceptResponse(request, network_delegate); | 61 return next_factory_->MaybeInterceptResponse(request, network_delegate); |
| 77 } | 62 } |
| 78 | 63 |
| 79 bool AwURLRequestJobFactory::SetProtocolHandler( | 64 bool AwURLRequestJobFactory::SetProtocolHandler( |
| 80 const std::string& scheme, | 65 const std::string& scheme, |
| 81 std::unique_ptr<ProtocolHandler> protocol_handler) { | 66 std::unique_ptr<ProtocolHandler> protocol_handler) { |
| 82 return next_factory_->SetProtocolHandler(scheme, std::move(protocol_handler)); | 67 return next_factory_->SetProtocolHandler(scheme, std::move(protocol_handler)); |
| 83 } | 68 } |
| 84 | 69 |
| 85 bool AwURLRequestJobFactory::IsSafeRedirectTarget(const GURL& location) const { | 70 bool AwURLRequestJobFactory::IsSafeRedirectTarget(const GURL& location) const { |
| 86 return next_factory_->IsSafeRedirectTarget(location); | 71 return next_factory_->IsSafeRedirectTarget(location); |
| 87 } | 72 } |
| 88 | 73 |
| 89 } // namespace android_webview | 74 } // namespace android_webview |
| OLD | NEW |