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..4f17b7376f3a982d7772ee63b8728366c9c85663 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,52 @@ class ProtocolHandlerRegistry : public ProfileKeyedService { |
| ProtocolHandlerRegistry* registry); |
| }; |
| + // Forward declaration of the internal implementation class. |
| + class Core; |
|
James Hawkins
2013/01/07 18:57:49
nit: Make this class name a bit more descriptive.
pauljensen
2013/01/07 20:48:58
I could rename it IOThreadDelegate? I wanted to c
|
| + |
| + // JobInterceptorFactory intercepts URLRequestJob creation for URLRequests the |
| + // ProtocolHandlerRegistry is registered to handle. When no handler is |
| + // registered the URLRequest is passed along to the chained |
|
James Hawkins
2013/01/07 18:57:49
nit: 'registered, the'
|
| + // URLRequestJobFactory (set with |JobInterceptorFactory::Chain|). |
| + // JobInterceptorFactory's are created via |
| + // |ProtocolHandlerRegistry::CreateJobInterceptorFactory|. |
| + class JobInterceptorFactory : public net::URLRequestJobFactory { |
| + public: |
| + explicit JobInterceptorFactory(Core* core); |
|
James Hawkins
2013/01/07 18:57:49
nit: Document |core|.
|
| + virtual ~JobInterceptorFactory(); |
| + |
| + // Set the URLRequestJobFactory where requests are passed if |
| + // JobInterceptorFactory decides to pass on them. |
| + void Chain(scoped_ptr<net::URLRequestJobFactory> job_factory); |
|
James Hawkins
2013/01/07 18:57:49
nit: Document |job_factory|.
|
| + |
| + // URLRequestJobFactory implementation |
|
James Hawkins
2013/01/07 18:57:49
nit: Add missing period at end of comment.
|
| + virtual bool SetProtocolHandler(const std::string& scheme, |
| + ProtocolHandler* protocol_handler) OVERRIDE; |
| + virtual void AddInterceptor(Interceptor* interceptor) OVERRIDE; |
| + virtual net::URLRequestJob* MaybeCreateJobWithInterceptor( |
|
James Hawkins
2013/01/07 18:57:49
ugh. Methods that have the word 'maybe' in it are
|
| + 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_; |
|
James Hawkins
2013/01/07 18:57:49
nit: Document member variables.
|
| + 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 +140,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 +258,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); |