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 a74a76546cfd94fe1d5bcfbfe7601a9d6e0906dd..7bb0aa97a0ca3da675f89597c842fa8495bcf70a 100644 |
| --- a/chrome/browser/custom_handlers/protocol_handler_registry.h |
| +++ b/chrome/browser/custom_handlers/protocol_handler_registry.h |
| @@ -20,17 +20,18 @@ |
| #include "content/public/browser/notification_service.h" |
| #include "net/url_request/url_request.h" |
| #include "net/url_request/url_request_job.h" |
| +#include "net/url_request/url_request_job_factory.h" |
| // This is where handlers for protocols registered with |
| // navigator.registerProtocolHandler() are registered. Each Profile owns an |
| // instance of this class, which is initialized on browser start through |
| // Profile::InitRegisteredProtocolHandlers(), and they should be the only |
| // instances of this class. |
| +class ProtocolHandlerRegistry : public ProfileKeyedService { |
| -class ProtocolHandlerRegistry |
| - : public base::RefCountedThreadSafe< |
| - ProtocolHandlerRegistry, content::BrowserThread::DeleteOnIOThread> { |
| public: |
| + // Provides notification of when the OS level user agent settings |
| + // are changed. |
| class DefaultClientObserver |
| : public ShellIntegration::DefaultWebClientObserver { |
| public: |
| @@ -59,6 +60,10 @@ class ProtocolHandlerRegistry |
| DISALLOW_COPY_AND_ASSIGN(DefaultClientObserver); |
| }; |
| + // The tersely named |Delegate| class provides an interface for interacting |
|
James Hawkins
2012/07/17 00:45:28
nit: I'd keep subjective terms out of the comments
Steve McKay
2012/07/17 01:12:42
Are you referencing the user of "tersely named"? I
|
| + // asynchronously with the underlying OS for the purposes of registering |
| + // Chrome as the default handler for specific protocols. |
| + // |
| // TODO(koz): Refactor this to eliminate the unnecessary virtuals. All that |
| // should be needed is a way to ensure that the list of websafe protocols is |
| // updated. |
| @@ -84,6 +89,12 @@ class ProtocolHandlerRegistry |
| typedef std::vector<DefaultClientObserver*> DefaultClientObserverList; |
| 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(); |
| // 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 |
| @@ -116,8 +127,10 @@ class ProtocolHandlerRegistry |
| // Returns true if this handler is the default handler for its protocol. |
| bool IsDefault(const ProtocolHandler& handler) const; |
| - // Loads a user's registered protocol handlers. |
| - void Load(); |
| + // Initializes default protocol settings and loads them from prefs. |
| + // This method must be called to complete initialization of the |
| + // registry after creation, and prior to use. |
| + void InitProtocolSettings(); |
| // Returns the offset in the list of handlers for a protocol of the default |
| // handler for that protocol. |
| @@ -155,10 +168,6 @@ class ProtocolHandlerRegistry |
| // Returns true if the protocol has a default protocol handler. |
| bool IsHandledProtocol(const std::string& scheme) const; |
| - // Returns true if the protocol has a default protocol handler. |
| - // Should be called only from the IO thread. |
| - bool IsHandledProtocolIO(const std::string& scheme) const; |
| - |
| // Removes the given protocol handler from the registry. |
| void RemoveHandler(const ProtocolHandler& handler); |
| @@ -169,10 +178,6 @@ class ProtocolHandlerRegistry |
| // exists. |
| const ProtocolHandler& GetHandlerFor(const std::string& scheme) const; |
| - // Creates a URL request job for the given request if there is a matching |
| - // protocol handler, returns NULL otherwise. |
| - net::URLRequestJob* MaybeCreateJob(net::URLRequest* request) const; |
| - |
| // Puts this registry in the enabled state - registered protocol handlers |
| // will handle requests. |
| void Enable(); |
| @@ -183,7 +188,7 @@ class ProtocolHandlerRegistry |
| // This is called by the UI thread when the system is shutting down. This |
| // does finalization which must be done on the UI thread. |
| - void Finalize(); |
| + virtual void Shutdown() OVERRIDE; |
| // Registers the preferences that we store registered protocol handlers in. |
| static void RegisterPrefs(PrefService* prefService); |
| @@ -201,28 +206,14 @@ class ProtocolHandlerRegistry |
| friend class ProtocolHandlerRegistryTest; |
| friend class RegisterProtocolHandlerBrowserTest; |
| - ~ProtocolHandlerRegistry(); |
| + // Forward declaration of our internal implementation classes. |
|
James Hawkins
2012/07/17 00:45:28
nit: s/our/the/
|
| + class Core; |
| + class URLInterceptor; |
| // Puts the given handler at the top of the list of handlers for its |
| // protocol. |
| void PromoteHandler(const ProtocolHandler& handler); |
| - // Clears the default for the provided protocol. |
| - // Should be called only from the IO thread. |
| - void ClearDefaultIO(const std::string& scheme); |
| - |
| - // Makes this ProtocolHandler the default handler for its protocol. |
| - // Should be called only from the IO thread. |
| - void SetDefaultIO(const ProtocolHandler& handler); |
| - |
| - // Indicate that the registry has been enabled in the IO thread's copy of the |
| - // data. |
| - void EnableIO() { enabled_io_ = true; } |
| - |
| - // Indicate that the registry has been disabled in the IO thread's copy of |
| - // the data. |
| - void DisableIO() { enabled_io_ = false; } |
| - |
| // Saves a user's registered protocol handlers. |
| void Save(); |
| @@ -277,9 +268,6 @@ class ProtocolHandlerRegistry |
| // requests. |
| bool enabled_; |
| - // Copy of enabled_ that is only accessed on the IO thread. |
| - bool enabled_io_; |
| - |
| // Whether or not we are loading. |
| bool is_loading_; |
| @@ -287,10 +275,9 @@ class ProtocolHandlerRegistry |
| // AddPredefinedHandler will be rejected. |
| bool is_loaded_; |
| - DefaultClientObserverList default_client_observers_; |
| + scoped_refptr<Core> core_; |
|
James Hawkins
2012/07/17 00:45:28
nit: Document.
Steve McKay
2012/07/17 01:12:42
Done.
|
| - // Copy of default_handlers_ that is only accessed on the IO thread. |
| - ProtocolHandlerMap default_handlers_io_; |
| + DefaultClientObserverList default_client_observers_; |
| DISALLOW_COPY_AND_ASSIGN(ProtocolHandlerRegistry); |
| }; |