| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/net/http_intercept_job_factory.h" |
| 6 |
| 7 #include "base/stl_util.h" |
| 8 #include "googleurl/src/gurl.h" |
| 9 #include "net/base/load_flags.h" |
| 10 #include "net/url_request/url_request_job_manager.h" |
| 11 |
| 12 class GURL; |
| 13 |
| 14 namespace net { |
| 15 |
| 16 const char* kHttpScheme = "http"; |
| 17 const char* kHttpsScheme = "https"; |
| 18 |
| 19 HttpInterceptJobFactory::HttpInterceptJobFactory( |
| 20 const URLRequestJobFactory* job_factory, |
| 21 ProtocolHandler* protocol_handler) |
| 22 : job_factory_(job_factory), |
| 23 protocol_handler_(protocol_handler) { |
| 24 } |
| 25 |
| 26 HttpInterceptJobFactory::~HttpInterceptJobFactory() {} |
| 27 |
| 28 bool HttpInterceptJobFactory::SetProtocolHandler( |
| 29 const std::string& scheme, ProtocolHandler* protocol_handler) { |
| 30 NOTREACHED(); |
| 31 return false; |
| 32 } |
| 33 |
| 34 void HttpInterceptJobFactory::AddInterceptor(Interceptor* interceptor) { |
| 35 // Interceptor addition is not allowed. |
| 36 NOTREACHED(); |
| 37 } |
| 38 |
| 39 URLRequestJob* HttpInterceptJobFactory::MaybeCreateJobWithInterceptor( |
| 40 URLRequest* request, NetworkDelegate* network_delegate) const { |
| 41 return job_factory_->MaybeCreateJobWithInterceptor(request, network_delegate); |
| 42 } |
| 43 |
| 44 URLRequestJob* HttpInterceptJobFactory::MaybeCreateJobWithProtocolHandler( |
| 45 const std::string& scheme, |
| 46 URLRequest* request, |
| 47 NetworkDelegate* network_delegate) const { |
| 48 DCHECK(CalledOnValidThread()); |
| 49 if (scheme == kHttpScheme || scheme == kHttpsScheme) |
| 50 return protocol_handler_->MaybeCreateJob(request, network_delegate); |
| 51 return job_factory_->MaybeCreateJobWithProtocolHandler( |
| 52 scheme, request, network_delegate); |
| 53 } |
| 54 |
| 55 URLRequestJob* HttpInterceptJobFactory::MaybeInterceptRedirect( |
| 56 const GURL& location, |
| 57 URLRequest* request, |
| 58 NetworkDelegate* network_delegate) const { |
| 59 return job_factory_->MaybeInterceptRedirect( |
| 60 location, request, network_delegate); |
| 61 } |
| 62 |
| 63 URLRequestJob* HttpInterceptJobFactory::MaybeInterceptResponse( |
| 64 URLRequest* request, NetworkDelegate* network_delegate) const { |
| 65 return job_factory_->MaybeInterceptResponse(request, network_delegate); |
| 66 } |
| 67 |
| 68 bool HttpInterceptJobFactory::IsHandledProtocol( |
| 69 const std::string& scheme) const { |
| 70 DCHECK(CalledOnValidThread()); |
| 71 if (scheme == kHttpScheme || scheme == kHttpsScheme) |
| 72 return true; |
| 73 return job_factory_->IsHandledProtocol(scheme); |
| 74 } |
| 75 |
| 76 bool HttpInterceptJobFactory::IsHandledURL(const GURL& url) const { |
| 77 if (url.scheme() == kHttpScheme || url.scheme() == kHttpsScheme) |
| 78 return true; |
| 79 return job_factory_->IsHandledURL(url); |
| 80 } |
| 81 |
| 82 } // namespace net |
| OLD | NEW |