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
3 // found in the LICENSE file.
5 #include "chrome/browser/profiles/gaia_info_update_service_factory.h"
7 #include "chrome/browser/profiles/gaia_info_update_service.h"
8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/common/pref_names.h"
10 #include "components/browser_context_keyed_service/browser_context_dependency_manager.h"
11 #include "components/user_prefs/pref_registry_syncable.h"
13 GAIAInfoUpdateServiceFactory::GAIAInfoUpdateServiceFactory()
14 : BrowserContextKeyedServiceFactory(
15 "GAIAInfoUpdateService",
16 BrowserContextDependencyManager::GetInstance()) {
19 GAIAInfoUpdateServiceFactory::~GAIAInfoUpdateServiceFactory() {}
22 GAIAInfoUpdateService
* GAIAInfoUpdateServiceFactory::GetForProfile(
24 return static_cast<GAIAInfoUpdateService
*>(
25 GetInstance()->GetServiceForBrowserContext(profile
, true));
29 GAIAInfoUpdateServiceFactory
* GAIAInfoUpdateServiceFactory::GetInstance() {
30 return Singleton
<GAIAInfoUpdateServiceFactory
>::get();
33 BrowserContextKeyedService
*
34 GAIAInfoUpdateServiceFactory::BuildServiceInstanceFor(
35 content::BrowserContext
* context
) const {
36 Profile
* profile
= static_cast<Profile
*>(context
);
37 if (!GAIAInfoUpdateService::ShouldUseGAIAProfileInfo(profile
))
39 return new GAIAInfoUpdateService(profile
);
42 void GAIAInfoUpdateServiceFactory::RegisterProfilePrefs(
43 user_prefs::PrefRegistrySyncable
* prefs
) {
44 prefs
->RegisterInt64Pref(prefs::kProfileGAIAInfoUpdateTime
,
46 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
47 prefs
->RegisterStringPref(prefs::kProfileGAIAInfoPictureURL
,
49 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
52 bool GAIAInfoUpdateServiceFactory::ServiceIsNULLWhileTesting() const {