protocol_handler_registry_factory.h revision a1401311d1ab56c4ed0a474bd38c108f75cb0cd9
15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef CHROME_BROWSER_CUSTOM_HANDLERS_PROTOCOL_HANDLER_REGISTRY_FACTORY_H_
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CHROME_BROWSER_CUSTOM_HANDLERS_PROTOCOL_HANDLER_REGISTRY_FACTORY_H_
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/basictypes.h"
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/compiler_specific.h"
10a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Profile;
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class ProtocolHandlerRegistry;
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)template <typename T> struct DefaultSingletonTraits;
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Singleton that owns all ProtocolHandlerRegistrys and associates them with
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Profiles. Listens for the Profile's destruction notification and cleans up
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// the associated ProtocolHandlerRegistry.
1990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)class ProtocolHandlerRegistryFactory
2090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)    : public BrowserContextKeyedServiceFactory {
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public:
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the singleton instance of the ProtocolHandlerRegistryFactory.
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static ProtocolHandlerRegistryFactory* GetInstance();
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the ProtocolHandlerRegistry that provides intent registration for
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |profile|. Ownership stays with this factory object.
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static ProtocolHandlerRegistry* GetForProfile(Profile* profile);
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) protected:
3090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  // BrowserContextKeyedServiceFactory implementation.
3190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  virtual bool ServiceIsCreatedWithBrowserContext() const OVERRIDE;
32c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  virtual content::BrowserContext* GetBrowserContextToUse(
33c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)      content::BrowserContext* context) const OVERRIDE;
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool ServiceIsNULLWhileTesting() const OVERRIDE;
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private:
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  friend struct DefaultSingletonTraits<ProtocolHandlerRegistryFactory>;
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  ProtocolHandlerRegistryFactory();
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual ~ProtocolHandlerRegistryFactory();
415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  // BrowserContextKeyedServiceFactory implementation.
43a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  virtual KeyedService* BuildServiceInstanceFor(
44c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)      content::BrowserContext* profile) const OVERRIDE;
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(ProtocolHandlerRegistryFactory);
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // CHROME_BROWSER_CUSTOM_HANDLERS_PROTOCOL_HANDLER_REGISTRY_FACTORY_H_
50