Chromium Code Reviews| Index: chrome/browser/custom_handlers/protocol_handler_registry.h |
| diff --git a/chrome/browser/custom_handlers/protocol_handler_registry.h b/chrome/browser/custom_handlers/protocol_handler_registry.h |
| index e8ae9137b9a29e9ca8f90b36f4626aebff609cf7..147b0e51e5ff01669a5fb8732958d50e94270190 100644 |
| --- a/chrome/browser/custom_handlers/protocol_handler_registry.h |
| +++ b/chrome/browser/custom_handlers/protocol_handler_registry.h |
| @@ -11,6 +11,7 @@ |
| #include "base/basictypes.h" |
| #include "base/memory/ref_counted.h" |
| +#include "base/memory/scoped_ptr.h" |
| #include "base/sequenced_task_runner_helpers.h" |
| #include "base/values.h" |
| #include "chrome/browser/profiles/profile.h" |
| @@ -84,6 +85,46 @@ class ProtocolHandlerRegistry : public ProfileKeyedService { |
| ProtocolHandlerRegistry* registry); |
| }; |
| + // Forward declaration of the internal implementation class. |
| + class Core; |
| + |
| + class JobInterceptorFactory : public net::URLRequestJobFactory { |
|
mmenke
2013/01/03 18:49:38
One other thing...We should have a description of
|
| + public: |
| + explicit JobInterceptorFactory(Core* core); |
| + virtual ~JobInterceptorFactory(); |
| + |
| + // Set the URLRequestJobFactory where requests are passed if JobFactory |
| + // decides to pass on them. |
| + void Chain(scoped_ptr<net::URLRequestJobFactory> job_factory); |
| + |
| + // URLRequestJobFactory implementation |
| + virtual bool SetProtocolHandler(const std::string& scheme, |
| + ProtocolHandler* protocol_handler) OVERRIDE; |
| + virtual void AddInterceptor(Interceptor* interceptor) OVERRIDE; |
| + virtual net::URLRequestJob* MaybeCreateJobWithInterceptor( |
| + net::URLRequest* request, |
| + net::NetworkDelegate* network_delegate) const OVERRIDE; |
| + virtual net::URLRequestJob* MaybeCreateJobWithProtocolHandler( |
| + const std::string& scheme, |
| + net::URLRequest* request, |
| + net::NetworkDelegate* network_delegate) const OVERRIDE; |
| + virtual net::URLRequestJob* MaybeInterceptRedirect( |
| + const GURL& location, |
| + net::URLRequest* request, |
| + net::NetworkDelegate* network_delegate) const OVERRIDE; |
| + virtual net::URLRequestJob* MaybeInterceptResponse( |
| + net::URLRequest* request, |
| + net::NetworkDelegate* network_delegate) const OVERRIDE; |
| + virtual bool IsHandledProtocol(const std::string& scheme) const OVERRIDE; |
| + virtual bool IsHandledURL(const GURL& url) const OVERRIDE; |
| + |
| + private: |
| + scoped_ptr<URLRequestJobFactory> job_factory_; |
| + scoped_refptr<Core> core_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(JobInterceptorFactory); |
| + }; |
| + |
| typedef std::map<std::string, ProtocolHandler> ProtocolHandlerMap; |
| typedef std::vector<ProtocolHandler> ProtocolHandlerList; |
| typedef std::map<std::string, ProtocolHandlerList> ProtocolHandlerMultiMap; |
| @@ -93,10 +134,9 @@ class ProtocolHandlerRegistry : public ProfileKeyedService { |
| ProtocolHandlerRegistry(Profile* profile, Delegate* delegate); |
| virtual ~ProtocolHandlerRegistry(); |
| - // Returns a net::URLRequestJobFactory::Interceptor suitable |
| - // for use on the IO thread, but is initialized on the UI thread. |
| - // Callers assume responsibility for deleting this object. |
| - net::URLRequestJobFactory::Interceptor* CreateURLInterceptor(); |
| + // Returns a net::URLRequestJobFactory suitable for use on the IO thread, but |
| + // is initialized on the UI thread. |
| + scoped_ptr<JobInterceptorFactory> CreateJobInterceptorFactory(); |
| // Called when a site tries to register as a protocol handler. If the request |
| // can be handled silently by the registry - either to ignore the request |
| @@ -212,10 +252,6 @@ class ProtocolHandlerRegistry : public ProfileKeyedService { |
| friend class ProtocolHandlerRegistryTest; |
| friend class RegisterProtocolHandlerBrowserTest; |
| - // Forward declaration of the internal implementation classes. |
| - class Core; |
| - class URLInterceptor; |
| - |
| // Puts the given handler at the top of the list of handlers for its |
| // protocol. |
| void PromoteHandler(const ProtocolHandler& handler); |