OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/sync/profile_sync_service_factory.h" | 5 #include "chrome/browser/sync/profile_sync_service_factory.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/memory/singleton.h" | 8 #include "base/memory/singleton.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 10 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 BrowserContextKeyedService* ProfileSyncServiceFactory::BuildServiceInstanceFor( | 88 BrowserContextKeyedService* ProfileSyncServiceFactory::BuildServiceInstanceFor( |
89 content::BrowserContext* context) const { | 89 content::BrowserContext* context) const { |
90 Profile* profile = static_cast<Profile*>(context); | 90 Profile* profile = static_cast<Profile*>(context); |
91 | 91 |
92 ProfileSyncService::StartBehavior behavior = | 92 ProfileSyncService::StartBehavior behavior = |
93 browser_defaults::kSyncAutoStarts ? ProfileSyncService::AUTO_START | 93 browser_defaults::kSyncAutoStarts ? ProfileSyncService::AUTO_START |
94 : ProfileSyncService::MANUAL_START; | 94 : ProfileSyncService::MANUAL_START; |
95 | 95 |
96 SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile); | 96 SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile); |
97 | 97 |
98 // Automatically load the GCMProfileService if the enabled state has been | 98 // Always create the GCMProfileService instance such that we can listen to |
99 // explicitly set. | 99 // the profile notifications and purge the GCM store when the profile is |
100 const base::Value* gcm_enabled_value = | 100 // being signed out. |
101 profile->GetPrefs()->GetUserPrefValue(prefs::kGCMChannelEnabled); | 101 gcm::GCMProfileServiceFactory::GetForProfile(profile); |
102 bool gcm_enabled = false; | |
103 if (gcm_enabled_value && | |
104 gcm_enabled_value->GetAsBoolean(&gcm_enabled) && | |
105 gcm_enabled) { | |
106 gcm::GCMProfileServiceFactory::GetForProfile(profile); | |
107 } | |
108 | 102 |
109 // TODO(atwilson): Change AboutSigninInternalsFactory to load on startup | 103 // TODO(atwilson): Change AboutSigninInternalsFactory to load on startup |
110 // once http://crbug.com/171406 has been fixed. | 104 // once http://crbug.com/171406 has been fixed. |
111 AboutSigninInternalsFactory::GetForProfile(profile); | 105 AboutSigninInternalsFactory::GetForProfile(profile); |
112 | 106 |
113 // TODO(tim): Currently, AUTO/MANUAL settings refer to the *first* time sync | 107 // TODO(tim): Currently, AUTO/MANUAL settings refer to the *first* time sync |
114 // is set up and *not* a browser restart for a manual-start platform (where | 108 // is set up and *not* a browser restart for a manual-start platform (where |
115 // sync has already been set up, and should be able to start without user | 109 // sync has already been set up, and should be able to start without user |
116 // intervention). We can get rid of the browser_default eventually, but | 110 // intervention). We can get rid of the browser_default eventually, but |
117 // need to take care that ProfileSyncService doesn't get tripped up between | 111 // need to take care that ProfileSyncService doesn't get tripped up between |
118 // those two cases. Bug 88109. | 112 // those two cases. Bug 88109. |
119 ProfileSyncService* pss = new ProfileSyncService( | 113 ProfileSyncService* pss = new ProfileSyncService( |
120 new ProfileSyncComponentsFactoryImpl(profile, | 114 new ProfileSyncComponentsFactoryImpl(profile, |
121 CommandLine::ForCurrentProcess()), | 115 CommandLine::ForCurrentProcess()), |
122 profile, | 116 profile, |
123 new ManagedUserSigninManagerWrapper(signin), | 117 new ManagedUserSigninManagerWrapper(signin), |
124 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), | 118 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), |
125 behavior); | 119 behavior); |
126 | 120 |
127 pss->factory()->RegisterDataTypes(pss); | 121 pss->factory()->RegisterDataTypes(pss); |
128 pss->Initialize(); | 122 pss->Initialize(); |
129 return pss; | 123 return pss; |
130 } | 124 } |
131 | 125 |
132 // static | 126 // static |
133 bool ProfileSyncServiceFactory::HasProfileSyncService(Profile* profile) { | 127 bool ProfileSyncServiceFactory::HasProfileSyncService(Profile* profile) { |
134 return GetInstance()->GetServiceForBrowserContext(profile, false) != NULL; | 128 return GetInstance()->GetServiceForBrowserContext(profile, false) != NULL; |
135 } | 129 } |
OLD | NEW |