gaia_info_update_service_factory.cc revision 7dbb3d5cf0c15f500944d211057644d6a2f37371
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 13GAIAInfoUpdateServiceFactory::GAIAInfoUpdateServiceFactory() 14 : BrowserContextKeyedServiceFactory( 15 "GAIAInfoUpdateService", 16 BrowserContextDependencyManager::GetInstance()) { 17} 18 19GAIAInfoUpdateServiceFactory::~GAIAInfoUpdateServiceFactory() {} 20 21// static 22GAIAInfoUpdateService* GAIAInfoUpdateServiceFactory::GetForProfile( 23 Profile* profile) { 24 return static_cast<GAIAInfoUpdateService*>( 25 GetInstance()->GetServiceForBrowserContext(profile, true)); 26} 27 28// static 29GAIAInfoUpdateServiceFactory* GAIAInfoUpdateServiceFactory::GetInstance() { 30 return Singleton<GAIAInfoUpdateServiceFactory>::get(); 31} 32 33BrowserContextKeyedService* 34GAIAInfoUpdateServiceFactory::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 42void 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 52bool GAIAInfoUpdateServiceFactory::ServiceIsNULLWhileTesting() const { 53 return true; 54} 55