Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / chromeos / login / saml / saml_offline_signin_limiter_factory.cc
blob76d4addd51f01067b95fe01b63576a7ca436d146
1 // Copyright 2014 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/chromeos/login/saml/saml_offline_signin_limiter_factory.h"
7 #include "base/time/clock.h"
8 #include "chrome/browser/chromeos/login/saml/saml_offline_signin_limiter.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "components/keyed_service/content/browser_context_dependency_manager.h"
11 #include "components/keyed_service/core/keyed_service.h"
12 #include "content/public/browser/browser_context.h"
14 namespace chromeos {
16 base::Clock* SAMLOfflineSigninLimiterFactory::clock_for_testing_ = NULL;
18 // static
19 SAMLOfflineSigninLimiterFactory*
20 SAMLOfflineSigninLimiterFactory::GetInstance() {
21 return base::Singleton<SAMLOfflineSigninLimiterFactory>::get();
24 // static
25 SAMLOfflineSigninLimiter* SAMLOfflineSigninLimiterFactory::GetForProfile(
26 Profile* profile) {
27 return static_cast<SAMLOfflineSigninLimiter*>(
28 GetInstance()->GetServiceForBrowserContext(profile, true));
31 // static
32 void SAMLOfflineSigninLimiterFactory::SetClockForTesting(base::Clock* clock) {
33 clock_for_testing_ = clock;
36 SAMLOfflineSigninLimiterFactory::SAMLOfflineSigninLimiterFactory()
37 : BrowserContextKeyedServiceFactory(
38 "SAMLOfflineSigninLimiter",
39 BrowserContextDependencyManager::GetInstance()) {
42 SAMLOfflineSigninLimiterFactory::~SAMLOfflineSigninLimiterFactory() {
45 KeyedService* SAMLOfflineSigninLimiterFactory::BuildServiceInstanceFor(
46 content::BrowserContext* context) const {
47 return new SAMLOfflineSigninLimiter(static_cast<Profile*>(context),
48 clock_for_testing_);
51 } // namespace chromeos