OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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/services/gcm/instance_id/instance_id_profile_service_fa
ctory.h" | 5 #include "chrome/browser/services/gcm/instance_id/instance_id_profile_service_fa
ctory.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "chrome/browser/profiles/incognito_helpers.h" | 8 #include "chrome/browser/profiles/incognito_helpers.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" | 10 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" |
11 #include "chrome/browser/services/gcm/instance_id/instance_id_profile_service.h" | 11 #include "chrome/browser/services/gcm/instance_id/instance_id_profile_service.h" |
12 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 12 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
13 | 13 |
14 namespace instance_id { | 14 namespace instance_id { |
15 | 15 |
16 // static | 16 // static |
17 InstanceIDProfileService* InstanceIDProfileServiceFactory::GetForProfile( | 17 InstanceIDProfileService* InstanceIDProfileServiceFactory::GetForProfile( |
18 content::BrowserContext* profile) { | 18 content::BrowserContext* profile) { |
19 // Instance ID is not supported in incognito mode. | 19 // Instance ID is not supported in incognito mode. |
20 if (profile->IsOffTheRecord()) | 20 if (profile->IsOffTheRecord()) |
21 return NULL; | 21 return NULL; |
22 | 22 |
23 return static_cast<InstanceIDProfileService*>( | 23 return static_cast<InstanceIDProfileService*>( |
24 GetInstance()->GetServiceForBrowserContext(profile, true)); | 24 GetInstance()->GetServiceForBrowserContext(profile, true)); |
25 } | 25 } |
26 | 26 |
27 // static | 27 // static |
28 InstanceIDProfileServiceFactory* | 28 InstanceIDProfileServiceFactory* |
29 InstanceIDProfileServiceFactory::GetInstance() { | 29 InstanceIDProfileServiceFactory::GetInstance() { |
30 return Singleton<InstanceIDProfileServiceFactory>::get(); | 30 return base::Singleton<InstanceIDProfileServiceFactory>::get(); |
31 } | 31 } |
32 | 32 |
33 InstanceIDProfileServiceFactory::InstanceIDProfileServiceFactory() | 33 InstanceIDProfileServiceFactory::InstanceIDProfileServiceFactory() |
34 : BrowserContextKeyedServiceFactory( | 34 : BrowserContextKeyedServiceFactory( |
35 "InstanceIDProfileService", | 35 "InstanceIDProfileService", |
36 BrowserContextDependencyManager::GetInstance()) { | 36 BrowserContextDependencyManager::GetInstance()) { |
37 // GCM is needed for device ID. | 37 // GCM is needed for device ID. |
38 DependsOn(gcm::GCMProfileServiceFactory::GetInstance()); | 38 DependsOn(gcm::GCMProfileServiceFactory::GetInstance()); |
39 } | 39 } |
40 | 40 |
41 InstanceIDProfileServiceFactory::~InstanceIDProfileServiceFactory() { | 41 InstanceIDProfileServiceFactory::~InstanceIDProfileServiceFactory() { |
42 } | 42 } |
43 | 43 |
44 KeyedService* InstanceIDProfileServiceFactory::BuildServiceInstanceFor( | 44 KeyedService* InstanceIDProfileServiceFactory::BuildServiceInstanceFor( |
45 content::BrowserContext* context) const { | 45 content::BrowserContext* context) const { |
46 return new InstanceIDProfileService(Profile::FromBrowserContext(context)); | 46 return new InstanceIDProfileService(Profile::FromBrowserContext(context)); |
47 } | 47 } |
48 | 48 |
49 content::BrowserContext* | 49 content::BrowserContext* |
50 InstanceIDProfileServiceFactory::GetBrowserContextToUse( | 50 InstanceIDProfileServiceFactory::GetBrowserContextToUse( |
51 content::BrowserContext* context) const { | 51 content::BrowserContext* context) const { |
52 return chrome::GetBrowserContextOwnInstanceInIncognito(context); | 52 return chrome::GetBrowserContextOwnInstanceInIncognito(context); |
53 } | 53 } |
54 | 54 |
55 } // namespace instance_id | 55 } // namespace instance_id |
OLD | NEW |