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 3 // found in the LICENSE file. 4 5 #ifndef NET_URL_REQUEST_PROTOCOL_INTERCEPT_JOB_FACTORY_H_ 6 #define NET_URL_REQUEST_PROTOCOL_INTERCEPT_JOB_FACTORY_H_ 7 8 #include "base/basictypes.h" 9 #include "base/compiler_specific.h" 10 #include "base/memory/scoped_ptr.h" 11 #include "net/base/net_export.h" 12 #include "net/url_request/url_request_job_factory.h" 13 14 class GURL; 15 16 namespace net { 17 18 class URLRequest; 19 class URLRequestJob; 20 21 // This class acts as a wrapper for URLRequestJobFactory. |protocol_handler_| is 22 // given the option of creating a URLRequestJob for each potential URLRequest. 23 // If |protocol_handler_| does not create a job (i.e. MaybeCreateJob() returns 24 // NULL) the URLRequest is forwarded to the |job_factory_| to be handled there. 25 // Only the MaybeCreateJob() member of |protocol_handler_| is called; the 26 // IsSafeRedirectTarget() member is not used. 27 class NET_EXPORT ProtocolInterceptJobFactory : public URLRequestJobFactory { 28 public: 29 ProtocolInterceptJobFactory(scoped_ptr<URLRequestJobFactory> job_factory, 30 scoped_ptr<ProtocolHandler> protocol_handler); 31 virtual ~ProtocolInterceptJobFactory(); 32 33 // URLRequestJobFactory implementation 34 virtual URLRequestJob* MaybeCreateJobWithProtocolHandler( 35 const std::string& scheme, 36 URLRequest* request, 37 NetworkDelegate* network_delegate) const OVERRIDE; 38 virtual bool IsHandledProtocol(const std::string& scheme) const OVERRIDE; 39 virtual bool IsHandledURL(const GURL& url) const OVERRIDE; 40 virtual bool IsSafeRedirectTarget(const GURL& location) const OVERRIDE; 41 42 private: 43 scoped_ptr<URLRequestJobFactory> job_factory_; 44 scoped_ptr<ProtocolHandler> protocol_handler_; 45 46 DISALLOW_COPY_AND_ASSIGN(ProtocolInterceptJobFactory); 47 }; 48 49 } // namespace net 50 51 #endif // NET_URL_REQUEST_PROTOCOL_INTERCEPT_JOB_FACTORY_H_ 52