Temporarily re-enabling SizeAfterPrefChange test with traces (this time for Linux...
[chromium-blink-merge.git] / chrome / browser / custom_handlers / protocol_handler_registry_factory.cc
blob7488ce9039d2590da2e35125c2bda474e7b983a0
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 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h"
7 #include "base/memory/singleton.h"
8 #include "chrome/browser/custom_handlers/protocol_handler_registry.h"
9 #include "chrome/browser/profiles/incognito_helpers.h"
10 #include "chrome/browser/profiles/profile.h"
11 #include "components/keyed_service/content/browser_context_dependency_manager.h"
13 // static
14 ProtocolHandlerRegistryFactory* ProtocolHandlerRegistryFactory::GetInstance() {
15 return Singleton<ProtocolHandlerRegistryFactory>::get();
18 // static
19 ProtocolHandlerRegistry* ProtocolHandlerRegistryFactory::GetForProfile(
20 Profile* profile) {
21 return static_cast<ProtocolHandlerRegistry*>(
22 GetInstance()->GetServiceForBrowserContext(profile, true));
25 ProtocolHandlerRegistryFactory::ProtocolHandlerRegistryFactory()
26 : BrowserContextKeyedServiceFactory(
27 "ProtocolHandlerRegistry",
28 BrowserContextDependencyManager::GetInstance()) {
31 ProtocolHandlerRegistryFactory::~ProtocolHandlerRegistryFactory() {
34 // Will be created when initializing profile_io_data, so we might
35 // as well have the framework create this along with other
36 // PKSs to preserve orderly civic conduct :)
37 bool
38 ProtocolHandlerRegistryFactory::ServiceIsCreatedWithBrowserContext() const {
39 return true;
42 // Allows the produced registry to be used in incognito mode.
43 content::BrowserContext* ProtocolHandlerRegistryFactory::GetBrowserContextToUse(
44 content::BrowserContext* context) const {
45 return chrome::GetBrowserContextRedirectedInIncognito(context);
48 // Do not create this service for tests. MANY tests will fail
49 // due to the threading requirements of this service. ALSO,
50 // not creating this increases test isolation (which is GOOD!)
51 bool ProtocolHandlerRegistryFactory::ServiceIsNULLWhileTesting() const {
52 return true;
55 KeyedService* ProtocolHandlerRegistryFactory::BuildServiceInstanceFor(
56 content::BrowserContext* profile) const {
57 ProtocolHandlerRegistry* registry = new ProtocolHandlerRegistry(
58 static_cast<Profile*>(profile), new ProtocolHandlerRegistry::Delegate());
60 #if defined(OS_CHROMEOS)
61 // If installing defaults, they must be installed prior calling
62 // InitProtocolSettings
63 registry->InstallDefaultsForChromeOS();
64 #endif
66 // Must be called as a part of the creation process.
67 registry->InitProtocolSettings();
69 return registry;