OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | |
Peter Beverloo
2015/02/25 23:55:05
nit: no more (c)
kbalazs
2015/02/27 22:40:36
Done.
| |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/push_messaging/push_messaging_service_factory.h" | |
6 | |
7 #include "chrome/browser/profiles/incognito_helpers.h" | |
8 #include "chrome/browser/profiles/profile.h" | |
9 #include "chrome/browser/push_messaging/push_messaging_service_impl.h" | |
10 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" | |
11 #include "components/keyed_service/content/browser_context_dependency_manager.h" | |
12 | |
13 // static | |
14 content::PushMessagingService* PushMessagingServiceFactory::GetForProfile( | |
15 content::BrowserContext* profile) { | |
16 // GCM is not supported in incognito mode and thus push api is neither. | |
Peter Beverloo
2015/02/25 23:55:05
I don't think GCM cares anymore about incognito mo
kbalazs
2015/02/27 22:40:36
Done.
| |
17 if (profile->IsOffTheRecord()) | |
18 return NULL; | |
19 | |
20 return static_cast<PushMessagingServiceImpl*>( | |
21 GetInstance()->GetServiceForBrowserContext(profile, true)); | |
22 } | |
23 | |
24 // static | |
25 PushMessagingServiceFactory* PushMessagingServiceFactory::GetInstance() { | |
26 return Singleton<PushMessagingServiceFactory>::get(); | |
27 } | |
28 | |
29 PushMessagingServiceFactory::PushMessagingServiceFactory() | |
30 : BrowserContextKeyedServiceFactory( | |
31 "PushMessagingProfileService", | |
Peter Beverloo
2015/02/25 23:55:05
nit: two more spaces of indent here.
kbalazs
2015/02/27 22:40:36
Done.
| |
32 BrowserContextDependencyManager::GetInstance()) { | |
33 DependsOn(gcm::GCMProfileServiceFactory::GetInstance()); | |
34 } | |
35 | |
36 PushMessagingServiceFactory::~PushMessagingServiceFactory() { | |
37 } | |
38 | |
39 KeyedService* PushMessagingServiceFactory::BuildServiceInstanceFor( | |
40 content::BrowserContext* context) const { | |
41 Profile* profile = Profile::FromBrowserContext(context); | |
42 CHECK(!profile->IsOffTheRecord()); | |
43 return new PushMessagingServiceImpl(profile); | |
44 } | |
45 | |
46 content::BrowserContext* PushMessagingServiceFactory::GetBrowserContextToUse( | |
47 content::BrowserContext* context) const { | |
48 return chrome::GetBrowserContextOwnInstanceInIncognito(context); | |
49 } | |
OLD | NEW |