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

Side by Side Diff: chrome/browser/invalidation/invalidation_service_factory.cc

Issue 179843002: Make invalidations work for Chrome OS Kiosk Apps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix merge error leading to uninitialized memory access. Created 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/invalidation/invalidation_service_factory.h" 5 #include "chrome/browser/invalidation/invalidation_service_factory.h"
6 6
7 #include "base/prefs/pref_registry.h" 7 #include "base/prefs/pref_registry.h"
8 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/invalidation/fake_invalidation_service.h" 9 #include "chrome/browser/invalidation/fake_invalidation_service.h"
9 #include "chrome/browser/invalidation/invalidation_service.h" 10 #include "chrome/browser/invalidation/invalidation_service.h"
10 #include "chrome/browser/invalidation/invalidation_service_android.h" 11 #include "chrome/browser/invalidation/invalidation_service_android.h"
11 #include "chrome/browser/invalidation/invalidator_storage.h" 12 #include "chrome/browser/invalidation/invalidator_storage.h"
13 #include "chrome/browser/invalidation/profile_invalidation_auth_provider.h"
12 #include "chrome/browser/invalidation/ticl_invalidation_service.h" 14 #include "chrome/browser/invalidation/ticl_invalidation_service.h"
13 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" 16 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h"
15 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 17 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
16 #include "chrome/browser/signin/signin_manager.h" 18 #include "chrome/browser/signin/signin_manager.h"
17 #include "chrome/browser/signin/signin_manager_factory.h" 19 #include "chrome/browser/signin/signin_manager_factory.h"
20 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
18 #include "components/keyed_service/content/browser_context_dependency_manager.h" 21 #include "components/keyed_service/content/browser_context_dependency_manager.h"
19 #include "components/signin/core/profile_oauth2_token_service.h" 22 #include "components/signin/core/profile_oauth2_token_service.h"
20 23
21 #if defined(OS_ANDROID) 24 #if defined(OS_ANDROID)
22 #include "chrome/browser/invalidation/invalidation_controller_android.h" 25 #include "chrome/browser/invalidation/invalidation_controller_android.h"
23 #endif // defined(OS_ANDROID) 26 #endif // defined(OS_ANDROID)
24 27
28 #if defined(OS_CHROMEOS)
29 #include "chrome/browser/chromeos/login/user_manager.h"
30 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
31 #include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h "
32 #include "chrome/browser/invalidation/device_invalidation_auth_provider_chromeos .h"
33 #endif
34
25 namespace invalidation { 35 namespace invalidation {
26 36
27 // static 37 // static
28 InvalidationService* InvalidationServiceFactory::GetForProfile( 38 InvalidationService* InvalidationServiceFactory::GetForProfile(
29 Profile* profile) { 39 Profile* profile) {
30 return static_cast<InvalidationService*>( 40 return static_cast<InvalidationService*>(
31 GetInstance()->GetServiceForBrowserContext(profile, true)); 41 GetInstance()->GetServiceForBrowserContext(profile, true));
32 } 42 }
33 43
34 // static 44 // static
35 InvalidationServiceFactory* InvalidationServiceFactory::GetInstance() { 45 InvalidationServiceFactory* InvalidationServiceFactory::GetInstance() {
36 return Singleton<InvalidationServiceFactory>::get(); 46 return Singleton<InvalidationServiceFactory>::get();
37 } 47 }
38 48
39 InvalidationServiceFactory::InvalidationServiceFactory() 49 InvalidationServiceFactory::InvalidationServiceFactory()
40 : BrowserContextKeyedServiceFactory( 50 : BrowserContextKeyedServiceFactory(
41 "InvalidationService", 51 "InvalidationService",
42 BrowserContextDependencyManager::GetInstance()), 52 BrowserContextDependencyManager::GetInstance()),
43 testing_factory_(NULL) { 53 testing_factory_(NULL) {
44 #if !defined(OS_ANDROID) 54 #if !defined(OS_ANDROID)
45 DependsOn(SigninManagerFactory::GetInstance()); 55 DependsOn(SigninManagerFactory::GetInstance());
46 DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance()); 56 DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance());
47 DependsOn(gcm::GCMProfileServiceFactory::GetInstance()); 57 DependsOn(gcm::GCMProfileServiceFactory::GetInstance());
58 DependsOn(LoginUIServiceFactory::GetInstance());
48 #endif 59 #endif
49 } 60 }
50 61
51 InvalidationServiceFactory::~InvalidationServiceFactory() {} 62 InvalidationServiceFactory::~InvalidationServiceFactory() {}
52 63
53 void InvalidationServiceFactory::RegisterTestingFactory( 64 void InvalidationServiceFactory::RegisterTestingFactory(
54 TestingFactoryFunction testing_factory) { 65 TestingFactoryFunction testing_factory) {
55 testing_factory_ = testing_factory; 66 testing_factory_ = testing_factory;
56 } 67 }
57 68
58 KeyedService* InvalidationServiceFactory::BuildServiceInstanceFor( 69 KeyedService* InvalidationServiceFactory::BuildServiceInstanceFor(
59 content::BrowserContext* context) const { 70 content::BrowserContext* context) const {
60 Profile* profile = static_cast<Profile*>(context); 71 Profile* profile = static_cast<Profile*>(context);
61 72
62 if (testing_factory_) 73 if (testing_factory_)
63 return testing_factory_(context); 74 return testing_factory_(context);
64 75
65 #if defined(OS_ANDROID) 76 #if defined(OS_ANDROID)
66 InvalidationServiceAndroid* service = new InvalidationServiceAndroid( 77 return new InvalidationServiceAndroid(profile,
67 profile, 78 new InvalidationControllerAndroid());
68 new InvalidationControllerAndroid());
69 return service;
70 #else 79 #else
71 SigninManagerBase* signin_manager =
72 SigninManagerFactory::GetForProfile(profile);
73 ProfileOAuth2TokenService* oauth2_token_service =
74 ProfileOAuth2TokenServiceFactory::GetForProfile(profile);
75 80
76 TiclInvalidationService* service = new TiclInvalidationService( 81 scoped_ptr<InvalidationAuthProvider> auth_provider;
77 signin_manager, 82
78 oauth2_token_service, 83 #if defined(OS_CHROMEOS)
79 profile); 84 policy::BrowserPolicyConnectorChromeOS* connector =
85 g_browser_process->platform_part()->browser_policy_connector_chromeos();
86 if (chromeos::UserManager::IsInitialized() &&
87 chromeos::UserManager::Get()->IsLoggedInAsKioskApp() &&
88 connector->IsEnterpriseManaged()) {
89 auth_provider.reset(new DeviceInvalidationAuthProvider(
90 chromeos::DeviceOAuth2TokenServiceFactory::Get()));
91 }
92 #endif
93
94 if (!auth_provider) {
95 auth_provider.reset(new ProfileInvalidationAuthProvider(
96 SigninManagerFactory::GetForProfile(profile),
97 ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
98 LoginUIServiceFactory::GetForProfile(profile)));
99 }
100
101 TiclInvalidationService* service =
102 new TiclInvalidationService(auth_provider.Pass(), profile);
80 service->Init(); 103 service->Init();
81 return service; 104 return service;
82 #endif 105 #endif
83 } 106 }
84 107
85 void InvalidationServiceFactory::RegisterProfilePrefs( 108 void InvalidationServiceFactory::RegisterProfilePrefs(
86 user_prefs::PrefRegistrySyncable* registry) { 109 user_prefs::PrefRegistrySyncable* registry) {
87 InvalidatorStorage::RegisterProfilePrefs(registry); 110 InvalidatorStorage::RegisterProfilePrefs(registry);
88 } 111 }
89 112
90 } // namespace invalidation 113 } // namespace invalidation
OLDNEW
« no previous file with comments | « chrome/browser/invalidation/invalidation_service_android.cc ('k') | chrome/browser/invalidation/p2p_invalidation_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698