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..4ff53b36818a6500e8fa539eb276c7ee8f851fab |
--- /dev/null |
+++ b/chrome/browser/signin/cross_device_promo_factory.cc |
@@ -0,0 +1,66 @@ |
+// 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) { |
+ 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()); |
+} |
+ |
+KeyedService* CrossDevicePromoFactory::BuildServiceInstanceFor( |
+ content::BrowserContext* context) const { |
+ Profile* profile = Profile::FromBrowserContext(context); |
+ CrossDevicePromo* service = new CrossDevicePromo( |
+ SigninManagerFactory::GetForProfile(profile), |
+ GaiaCookieManagerServiceFactory::GetForProfile(profile), |
+ ChromeSigninClientFactory::GetForProfile(profile), profile->GetPrefs()); |
+ return service; |
+} |