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.
5 #ifndef CHROME_BROWSER_CUSTOM_HANDLERS_PROTOCOL_HANDLER_REGISTRY_FACTORY_H_
6 #define CHROME_BROWSER_CUSTOM_HANDLERS_PROTOCOL_HANDLER_REGISTRY_FACTORY_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "components/keyed_service/content/browser_context_keyed_service_factory.h"
13 class ProtocolHandlerRegistry
;
16 template <typename T
> struct DefaultSingletonTraits
;
19 // Singleton that owns all ProtocolHandlerRegistrys and associates them with
20 // Profiles. Listens for the Profile's destruction notification and cleans up
21 // the associated ProtocolHandlerRegistry.
22 class ProtocolHandlerRegistryFactory
23 : public BrowserContextKeyedServiceFactory
{
25 // Returns the singleton instance of the ProtocolHandlerRegistryFactory.
26 static ProtocolHandlerRegistryFactory
* GetInstance();
28 // Returns the ProtocolHandlerRegistry that provides intent registration for
29 // |context|. Ownership stays with this factory object.
30 static ProtocolHandlerRegistry
* GetForBrowserContext(
31 content::BrowserContext
* context
);
34 // BrowserContextKeyedServiceFactory implementation.
35 bool ServiceIsCreatedWithBrowserContext() const override
;
36 content::BrowserContext
* GetBrowserContextToUse(
37 content::BrowserContext
* context
) const override
;
38 bool ServiceIsNULLWhileTesting() const override
;
41 friend struct base::DefaultSingletonTraits
<ProtocolHandlerRegistryFactory
>;
43 ProtocolHandlerRegistryFactory();
44 ~ProtocolHandlerRegistryFactory() override
;
46 // BrowserContextKeyedServiceFactory implementation.
47 KeyedService
* BuildServiceInstanceFor(
48 content::BrowserContext
* profile
) const override
;
50 DISALLOW_COPY_AND_ASSIGN(ProtocolHandlerRegistryFactory
);
53 #endif // CHROME_BROWSER_CUSTOM_HANDLERS_PROTOCOL_HANDLER_REGISTRY_FACTORY_H_