Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(872)

Unified Diff: chrome/browser/custom_handlers/protocol_handler_registry.h

Issue 10546083: Convert ProtocolHandlerRegistry to be a ProfileKeyedService. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix merge issue (correctly) in PHR test. Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 18f01111eedac6b82a6b48dee98f77de9c5fbccb..1b8ee0854413f94f171f8fcbfb4578f5bcaea7f4 100644
--- a/chrome/browser/custom_handlers/protocol_handler_registry.h
+++ b/chrome/browser/custom_handlers/protocol_handler_registry.h
@@ -21,17 +21,19 @@
#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:
@@ -86,6 +88,11 @@ class ProtocolHandlerRegistry
ProtocolHandlerRegistry(Profile* profile, Delegate* delegate);
+ // 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* CreateIOURLInterceptor();
+
// 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
// or to update an existing handler - the request will succeed. If this
@@ -117,8 +124,8 @@ 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.
+ void InitProtocolSettings();
// Returns the offset in the list of handlers for a protocol of the default
// handler for that protocol.
@@ -156,10 +163,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);
@@ -170,10 +173,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();
@@ -184,7 +183,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);
@@ -202,28 +201,16 @@ class ProtocolHandlerRegistry
friend class ProtocolHandlerRegistryTest;
friend class RegisterProtocolHandlerBrowserTest;
- ~ProtocolHandlerRegistry();
+ // Forward declaration of our internal implementation classes.
+ class Core;
+ class IOURLInterceptor;
willchan no longer on Chromium 2012/06/22 23:15:44 Why does this need to be a private nested class? C
smckay 2012/06/22 23:44:31 Since Core is private I have to declare URLInterce
+
+ virtual ~ProtocolHandlerRegistry();
// 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();
@@ -278,9 +265,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_;
@@ -288,10 +272,9 @@ class ProtocolHandlerRegistry
// AddPredefinedHandler will be rejected.
bool is_loaded_;
- DefaultClientObserverList default_client_observers_;
+ scoped_refptr<Core> core_;
- // 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);
};

Powered by Google App Engine
This is Rietveld 408576698