Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / chrome / browser / push_messaging / push_messaging_service_factory.cc
blob1ed640c43e416088e694be8883530680a3de8100
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.
5 #include "chrome/browser/push_messaging/push_messaging_service_factory.h"
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"
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;
22 return static_cast<PushMessagingServiceImpl*>(
23 GetInstance()->GetServiceForBrowserContext(profile, true));
26 // static
27 PushMessagingServiceFactory* PushMessagingServiceFactory::GetInstance() {
28 return Singleton<PushMessagingServiceFactory>::get();
31 PushMessagingServiceFactory::PushMessagingServiceFactory()
32 : BrowserContextKeyedServiceFactory(
33 "PushMessagingProfileService",
34 BrowserContextDependencyManager::GetInstance()) {
35 DependsOn(gcm::GCMProfileServiceFactory::GetInstance());
38 PushMessagingServiceFactory::~PushMessagingServiceFactory() {
41 KeyedService* PushMessagingServiceFactory::BuildServiceInstanceFor(
42 content::BrowserContext* context) const {
43 Profile* profile = Profile::FromBrowserContext(context);
44 CHECK(!profile->IsOffTheRecord());
45 return new PushMessagingServiceImpl(profile);
48 content::BrowserContext* PushMessagingServiceFactory::GetBrowserContextToUse(
49 content::BrowserContext* context) const {
50 return chrome::GetBrowserContextOwnInstanceInIncognito(context);