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

Side by Side Diff: chrome/browser/push_messaging/push_messaging_service_factory.cc

Issue 955673004: Move gcm-independent parts of push messaging out of gcm namespace and directory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove redundant cast Created 5 years, 9 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
OLDNEW
(Empty)
1 // Copyright 2015 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.
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/fake_gcm_profile_service.h"
11 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h"
12 #include "components/keyed_service/content/browser_context_dependency_manager.h"
13
14 // static
15 PushMessagingServiceImpl* PushMessagingServiceFactory::GetForProfile(
16 content::BrowserContext* profile) {
17 // The Push API is not currently supported in incognito mode.
18 // See https://crbug.com/401439.
19 if (profile->IsOffTheRecord())
20 return NULL;
21
22 return static_cast<PushMessagingServiceImpl*>(
23 GetInstance()->GetServiceForBrowserContext(profile, true));
24 }
25
26 // static
27 PushMessagingServiceFactory* PushMessagingServiceFactory::GetInstance() {
28 return Singleton<PushMessagingServiceFactory>::get();
29 }
30
31 PushMessagingServiceFactory::PushMessagingServiceFactory()
32 : BrowserContextKeyedServiceFactory(
33 "PushMessagingProfileService",
34 BrowserContextDependencyManager::GetInstance()) {
35 DependsOn(gcm::GCMProfileServiceFactory::GetInstance());
36 }
37
38 PushMessagingServiceFactory::~PushMessagingServiceFactory() {
39 }
40
41 KeyedService* PushMessagingServiceFactory::BuildServiceInstanceFor(
42 content::BrowserContext* context) const {
43 Profile* profile = Profile::FromBrowserContext(context);
44 CHECK(!profile->IsOffTheRecord());
45 return new PushMessagingServiceImpl(profile);
46 }
47
48 content::BrowserContext* PushMessagingServiceFactory::GetBrowserContextToUse(
49 content::BrowserContext* context) const {
50 return chrome::GetBrowserContextOwnInstanceInIncognito(context);
51 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698