Roll src/third_party/WebKit f298044:aa8346d (svn 202628:202629)
[chromium-blink-merge.git] / chrome / browser / custom_handlers / protocol_handler_registry_factory.h
blobfc38b59a487b9151b96b9d96eb58a1f9c036bc85
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"
12 class Profile;
13 class ProtocolHandlerRegistry;
15 namespace base {
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 {
24 public:
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);
33 protected:
34 // BrowserContextKeyedServiceFactory implementation.
35 bool ServiceIsCreatedWithBrowserContext() const override;
36 content::BrowserContext* GetBrowserContextToUse(
37 content::BrowserContext* context) const override;
38 bool ServiceIsNULLWhileTesting() const override;
40 private:
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_