Chromium Code Reviews| Index: chrome/browser/signin/cross_device_promo_factory.cc |
| diff --git a/chrome/browser/signin/cross_device_promo_factory.cc b/chrome/browser/signin/cross_device_promo_factory.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ef2e8136a66059e229e02d0fe04dfa031c0a845b |
| --- /dev/null |
| +++ b/chrome/browser/signin/cross_device_promo_factory.cc |
| @@ -0,0 +1,72 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/signin/cross_device_promo_factory.h" |
| + |
| +#include "base/prefs/pref_service.h" |
| +#include "chrome/browser/prefs/pref_service_syncable.h" |
| +#include "chrome/browser/profiles/profile.h" |
| +#include "chrome/browser/signin/chrome_signin_client_factory.h" |
| +#include "chrome/browser/signin/cross_device_promo.h" |
| +#include "chrome/browser/signin/gaia_cookie_manager_service_factory.h" |
| +#include "chrome/browser/signin/signin_manager_factory.h" |
| +#include "chrome/common/pref_names.h" |
| +#include "components/keyed_service/content/browser_context_dependency_manager.h" |
| +#include "components/pref_registry/pref_registry_syncable.h" |
| +#include "components/signin/core/browser/signin_manager.h" |
| +#include "google_apis/gaia/gaia_constants.h" |
| + |
| +CrossDevicePromoFactory::CrossDevicePromoFactory() |
| + : BrowserContextKeyedServiceFactory( |
| + "CrossDevicePromo", |
| + BrowserContextDependencyManager::GetInstance()) { |
| + DependsOn(ChromeSigninClientFactory::GetInstance()); |
| + DependsOn(GaiaCookieManagerServiceFactory::GetInstance()); |
| + DependsOn(SigninManagerFactory::GetInstance()); |
| +} |
| + |
| +CrossDevicePromoFactory::~CrossDevicePromoFactory() {} |
| + |
| +// static |
| +CrossDevicePromo* CrossDevicePromoFactory::GetForProfile(Profile* profile) { |
| + return static_cast<CrossDevicePromo*>( |
| + GetInstance()->GetServiceForBrowserContext(profile, true)); |
| +} |
| + |
| +// static |
| +CrossDevicePromoFactory* CrossDevicePromoFactory::GetInstance() { |
| + return Singleton<CrossDevicePromoFactory>::get(); |
| +} |
| + |
| +void CrossDevicePromoFactory::RegisterProfilePrefs( |
| + user_prefs::PrefRegistrySyncable* user_prefs) { |
| +#if !defined(OS_CHROMEOS) && !defined(OS_IOS) && !defined(OS_ANDROID) |
| + user_prefs->RegisterBooleanPref(prefs::kCrossDevicePromoOptedOut, false); |
| + user_prefs->RegisterBooleanPref(prefs::kCrossDevicePromoActive, false); |
| + user_prefs->RegisterInt64Pref( |
| + prefs::kCrossDevicePromoObservedSingleAccountCookie, |
| + base::Time::Time().ToInternalValue()); |
| + user_prefs->RegisterInt64Pref( |
| + prefs::kCrossDevicePromoNextFetchListDevicesTime, |
| + base::Time::Time().ToInternalValue()); |
| + user_prefs->RegisterIntegerPref(prefs::kCrossDevicePromoNumDevices, 0); |
| + user_prefs->RegisterInt64Pref(prefs::kCrossDevicePromoLastDeviceActiveTime, |
| + base::Time::Time().ToInternalValue()); |
| +#endif |
| +} |
| + |
| +KeyedService* CrossDevicePromoFactory::BuildServiceInstanceFor( |
| + content::BrowserContext* context) const { |
| +#if !defined(OS_CHROMEOS) && !defined(OS_IOS) && !defined(OS_ANDROID) |
|
anthonyvd
2015/05/14 18:24:20
In the ProfileManager, the call to CrossDeviceProm
Mike Lerman
2015/05/14 20:25:33
That profilemanager call is within a larger !defin
|
| + Profile* profile = Profile::FromBrowserContext(context); |
| + CrossDevicePromo* service = new CrossDevicePromo( |
| + SigninManagerFactory::GetForProfile(profile), |
| + GaiaCookieManagerServiceFactory::GetForProfile(profile), |
| + ChromeSigninClientFactory::GetForProfile(profile), |
| + profile->GetPrefs()); |
| + return service; |
| +#else |
| + return nullptr; |
| +#endif |
| +} |