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

Side by Side Diff: chrome/browser/custom_handlers/protocol_handler_registry_factory.cc

Issue 15517005: Remove references to Profile from browser_context_keyed_service. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" 5 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h"
6 6
7 #include "base/memory/singleton.h" 7 #include "base/memory/singleton.h"
8 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" 8 #include "chrome/browser/custom_handlers/protocol_handler_registry.h"
9 #include "chrome/browser/extensions/extension_system_factory.h" 9 #include "chrome/browser/extensions/extension_system_factory.h"
10 #include "chrome/browser/profiles/incognito_helpers.h" 10 #include "chrome/browser/profiles/incognito_helpers.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "components/browser_context_keyed_service/browser_context_dependency_ma nager.h" 12 #include "components/browser_context_keyed_service/browser_context_dependency_ma nager.h"
13 13
14 // static 14 // static
15 ProtocolHandlerRegistryFactory* ProtocolHandlerRegistryFactory::GetInstance() { 15 ProtocolHandlerRegistryFactory* ProtocolHandlerRegistryFactory::GetInstance() {
16 return Singleton<ProtocolHandlerRegistryFactory>::get(); 16 return Singleton<ProtocolHandlerRegistryFactory>::get();
17 } 17 }
18 18
19 // static 19 // static
20 ProtocolHandlerRegistry* ProtocolHandlerRegistryFactory::GetForProfile( 20 ProtocolHandlerRegistry* ProtocolHandlerRegistryFactory::GetForProfile(
21 Profile* profile) { 21 Profile* profile) {
22 return static_cast<ProtocolHandlerRegistry*>( 22 return static_cast<ProtocolHandlerRegistry*>(
23 GetInstance()->GetServiceForProfile(profile, true)); 23 GetInstance()->GetServiceForBrowserContext(profile, true));
24 } 24 }
25 25
26 ProtocolHandlerRegistryFactory::ProtocolHandlerRegistryFactory() 26 ProtocolHandlerRegistryFactory::ProtocolHandlerRegistryFactory()
27 : ProfileKeyedServiceFactory("ProtocolHandlerRegistry", 27 : BrowserContextKeyedServiceFactory("ProtocolHandlerRegistry",
28 ProfileDependencyManager::GetInstance()) { 28 BrowserContextDependencyManager::GetInstance()) {
29 } 29 }
30 30
31 ProtocolHandlerRegistryFactory::~ProtocolHandlerRegistryFactory() { 31 ProtocolHandlerRegistryFactory::~ProtocolHandlerRegistryFactory() {
32 } 32 }
33 33
34 // Will be created when initializing profile_io_data, so we might 34 // Will be created when initializing profile_io_data, so we might
35 // as well have the framework create this along with other 35 // as well have the framework create this along with other
36 // PKSs to preserve orderly civic conduct :) 36 // PKSs to preserve orderly civic conduct :)
37 bool ProtocolHandlerRegistryFactory::ServiceIsCreatedWithProfile() const { 37 bool ProtocolHandlerRegistryFactory::ServiceIsCreatedWithBrowserContext() const {
38 return true; 38 return true;
39 } 39 }
40 40
41 // Allows the produced registry to be used in incognito mode. 41 // Allows the produced registry to be used in incognito mode.
42 content::BrowserContext* ProtocolHandlerRegistryFactory::GetBrowserContextToUse( 42 content::BrowserContext* ProtocolHandlerRegistryFactory::GetBrowserContextToUse(
43 content::BrowserContext* context) const { 43 content::BrowserContext* context) const {
44 return chrome::GetBrowserContextRedirectedInIncognito(context); 44 return chrome::GetBrowserContextRedirectedInIncognito(context);
45 } 45 }
46 46
47 // Do not create this service for tests. MANY tests will fail 47 // Do not create this service for tests. MANY tests will fail
48 // due to the threading requirements of this service. ALSO, 48 // due to the threading requirements of this service. ALSO,
49 // not creating this increases test isolation (which is GOOD!) 49 // not creating this increases test isolation (which is GOOD!)
50 bool ProtocolHandlerRegistryFactory::ServiceIsNULLWhileTesting() const { 50 bool ProtocolHandlerRegistryFactory::ServiceIsNULLWhileTesting() const {
51 return true; 51 return true;
52 } 52 }
53 53
54 ProfileKeyedService* ProtocolHandlerRegistryFactory::BuildServiceInstanceFor( 54 BrowserContextKeyedService* ProtocolHandlerRegistryFactory::BuildServiceInstance For(
55 content::BrowserContext* profile) const { 55 content::BrowserContext* profile) const {
56 ProtocolHandlerRegistry* registry = new ProtocolHandlerRegistry( 56 ProtocolHandlerRegistry* registry = new ProtocolHandlerRegistry(
57 static_cast<Profile*>(profile), new ProtocolHandlerRegistry::Delegate()); 57 static_cast<Profile*>(profile), new ProtocolHandlerRegistry::Delegate());
58 58
59 #if defined(OS_CHROMEOS) 59 #if defined(OS_CHROMEOS)
60 // If installing defaults, they must be installed prior calling 60 // If installing defaults, they must be installed prior calling
61 // InitProtocolSettings 61 // InitProtocolSettings
62 registry->InstallDefaultsForChromeOS(); 62 registry->InstallDefaultsForChromeOS();
63 #endif 63 #endif
64 64
65 // Must be called as a part of the creation process. 65 // Must be called as a part of the creation process.
66 registry->InitProtocolSettings(); 66 registry->InitProtocolSettings();
67 67
68 return registry; 68 return registry;
69 } 69 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698