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

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

Issue 1851423003: Make Web Push use InstanceID tokens instead of GCM registrations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@iid4default
Patch Set: Fix GN/GYP Created 4 years, 8 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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/push_messaging/push_messaging_service_factory.h" 5 #include "chrome/browser/push_messaging/push_messaging_service_factory.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 8 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
9 #include "chrome/browser/permissions/permission_manager_factory.h" 9 #include "chrome/browser/permissions/permission_manager_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 "chrome/browser/push_messaging/push_messaging_service_impl.h" 12 #include "chrome/browser/push_messaging/push_messaging_service_impl.h"
13 #include "chrome/browser/services/gcm/fake_gcm_profile_service.h" 13 #include "chrome/browser/services/gcm/instance_id/instance_id_profile_service.h"
14 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" 14 #include "chrome/browser/services/gcm/instance_id/instance_id_profile_service_fa ctory.h"
15 #include "components/keyed_service/content/browser_context_dependency_manager.h" 15 #include "components/keyed_service/content/browser_context_dependency_manager.h"
16 16
17 // static 17 // static
18 PushMessagingServiceImpl* PushMessagingServiceFactory::GetForProfile( 18 PushMessagingServiceImpl* PushMessagingServiceFactory::GetForProfile(
19 content::BrowserContext* profile) { 19 content::BrowserContext* context) {
20 // The Push API is not currently supported in incognito mode. 20 // The Push API is not currently supported in incognito mode.
21 // See https://crbug.com/401439. 21 // See https://crbug.com/401439.
22 if (profile->IsOffTheRecord()) 22 if (context->IsOffTheRecord())
23 return NULL; 23 return nullptr;
24
25 if (!instance_id::InstanceIDProfileService::IsInstanceIDEnabled(
26 Profile::FromBrowserContext(context))) {
27 return nullptr;
Peter Beverloo 2016/04/11 15:47:56 +LOG(WARNING)?
johnme 2016/04/21 10:58:37 Added a DLOG(WARNING).
28 }
24 29
25 return static_cast<PushMessagingServiceImpl*>( 30 return static_cast<PushMessagingServiceImpl*>(
26 GetInstance()->GetServiceForBrowserContext(profile, true)); 31 GetInstance()->GetServiceForBrowserContext(context, true));
27 } 32 }
28 33
29 // static 34 // static
30 PushMessagingServiceFactory* PushMessagingServiceFactory::GetInstance() { 35 PushMessagingServiceFactory* PushMessagingServiceFactory::GetInstance() {
31 return base::Singleton<PushMessagingServiceFactory>::get(); 36 return base::Singleton<PushMessagingServiceFactory>::get();
32 } 37 }
33 38
34 PushMessagingServiceFactory::PushMessagingServiceFactory() 39 PushMessagingServiceFactory::PushMessagingServiceFactory()
35 : BrowserContextKeyedServiceFactory( 40 : BrowserContextKeyedServiceFactory(
36 "PushMessagingProfileService", 41 "PushMessagingProfileService",
37 BrowserContextDependencyManager::GetInstance()) { 42 BrowserContextDependencyManager::GetInstance()) {
38 DependsOn(gcm::GCMProfileServiceFactory::GetInstance()); 43 DependsOn(instance_id::InstanceIDProfileServiceFactory::GetInstance());
Peter Beverloo 2016/04/11 15:47:56 We still use the GCMProfileServiceFactory in the S
johnme 2016/04/21 10:58:37 Good point. Readded (I guess it was working only b
39 DependsOn(HostContentSettingsMapFactory::GetInstance()); 44 DependsOn(HostContentSettingsMapFactory::GetInstance());
40 DependsOn(PermissionManagerFactory::GetInstance()); 45 DependsOn(PermissionManagerFactory::GetInstance());
41 } 46 }
42 47
43 PushMessagingServiceFactory::~PushMessagingServiceFactory() {} 48 PushMessagingServiceFactory::~PushMessagingServiceFactory() {}
44 49
45 void PushMessagingServiceFactory::RestoreFactoryForTests( 50 void PushMessagingServiceFactory::RestoreFactoryForTests(
46 content::BrowserContext* context) { 51 content::BrowserContext* context) {
47 SetTestingFactory(context, [](content::BrowserContext* context) { 52 SetTestingFactory(context, [](content::BrowserContext* context) {
48 return scoped_ptr<KeyedService>( 53 return scoped_ptr<KeyedService>(
49 GetInstance()->BuildServiceInstanceFor(context)); 54 GetInstance()->BuildServiceInstanceFor(context));
50 }); 55 });
51 } 56 }
52 57
53 KeyedService* PushMessagingServiceFactory::BuildServiceInstanceFor( 58 KeyedService* PushMessagingServiceFactory::BuildServiceInstanceFor(
54 content::BrowserContext* context) const { 59 content::BrowserContext* context) const {
55 Profile* profile = Profile::FromBrowserContext(context); 60 Profile* profile = Profile::FromBrowserContext(context);
56 CHECK(!profile->IsOffTheRecord()); 61 CHECK(!profile->IsOffTheRecord());
57 return new PushMessagingServiceImpl(profile); 62 return new PushMessagingServiceImpl(profile);
58 } 63 }
59 64
60 content::BrowserContext* PushMessagingServiceFactory::GetBrowserContextToUse( 65 content::BrowserContext* PushMessagingServiceFactory::GetBrowserContextToUse(
61 content::BrowserContext* context) const { 66 content::BrowserContext* context) const {
62 return chrome::GetBrowserContextOwnInstanceInIncognito(context); 67 return chrome::GetBrowserContextOwnInstanceInIncognito(context);
63 } 68 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698