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. 4 5 #include "chrome/browser/profiles/gaia_info_update_service_factory.h" 6 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" 12 13 GAIAInfoUpdateServiceFactory::GAIAInfoUpdateServiceFactory() 14 : BrowserContextKeyedServiceFactory( 15 "GAIAInfoUpdateService", 16 BrowserContextDependencyManager::GetInstance()) { 17 } 18 19 GAIAInfoUpdateServiceFactory::~GAIAInfoUpdateServiceFactory() {} 20 21 // static 22 GAIAInfoUpdateService* GAIAInfoUpdateServiceFactory::GetForProfile( 23 Profile* profile) { 24 return static_cast<GAIAInfoUpdateService*>( 25 GetInstance()->GetServiceForBrowserContext(profile, true)); 26 } 27 28 // static 29 GAIAInfoUpdateServiceFactory* GAIAInfoUpdateServiceFactory::GetInstance() { 30 return Singleton<GAIAInfoUpdateServiceFactory>::get(); 31 } 32 33 BrowserContextKeyedService* 34 GAIAInfoUpdateServiceFactory::BuildServiceInstanceFor( 35 content::BrowserContext* context) const { 36 Profile* profile = static_cast<Profile*>(context); 37 if (!GAIAInfoUpdateService::ShouldUseGAIAProfileInfo(profile)) 38 return NULL; 39 return new GAIAInfoUpdateService(profile); 40 } 41 42 void GAIAInfoUpdateServiceFactory::RegisterProfilePrefs( 43 user_prefs::PrefRegistrySyncable* prefs) { 44 prefs->RegisterInt64Pref(prefs::kProfileGAIAInfoUpdateTime, 45 0, 46 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 47 prefs->RegisterStringPref(prefs::kProfileGAIAInfoPictureURL, 48 std::string(), 49 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 50 } 51 52 bool GAIAInfoUpdateServiceFactory::ServiceIsNULLWhileTesting() const { 53 return true; 54 } 55