Index: chrome/browser/chromeos/login/quick_unlock/fingerprint_unlock_factory.cc |
diff --git a/chrome/browser/chromeos/login/quick_unlock/fingerprint_unlock_factory.cc b/chrome/browser/chromeos/login/quick_unlock/fingerprint_unlock_factory.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..651a95a9ac674463cab2355dc67edae54f40e0a1 |
--- /dev/null |
+++ b/chrome/browser/chromeos/login/quick_unlock/fingerprint_unlock_factory.cc |
@@ -0,0 +1,63 @@ |
+// Copyright 2017 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/chromeos/login/quick_unlock/fingerprint_unlock_factory.h" |
+ |
+#include "chrome/browser/chromeos/login/quick_unlock/fingerprint_unlock.h" |
+#include "chrome/browser/chromeos/profiles/profile_helper.h" |
+#include "chrome/browser/profiles/profile.h" |
+#include "components/keyed_service/content/browser_context_dependency_manager.h" |
+#include "components/user_manager/user.h" |
+#include "components/user_manager/user_manager.h" |
+ |
+namespace chromeos { |
+namespace quick_unlock { |
+ |
+// static |
+FingerprintUnlock* FingerprintUnlockFactory::GetForProfile(Profile* profile) { |
+ return static_cast<FingerprintUnlock*>( |
+ GetInstance()->GetServiceForBrowserContext(profile, true)); |
+} |
+ |
+// static |
+FingerprintUnlock* FingerprintUnlockFactory::GetForUser( |
+ const user_manager::User* user) { |
+ Profile* profile = ProfileHelper::Get()->GetProfileByUser(user); |
+ if (!profile) |
+ return nullptr; |
+ |
+ return GetForProfile(profile); |
+} |
+ |
+// static |
+FingerprintUnlock* FingerprintUnlockFactory::GetForAccountId( |
+ const AccountId& account_id) { |
+ const user_manager::User* user = |
+ user_manager::UserManager::Get()->FindUser(account_id); |
+ if (!user) |
+ return nullptr; |
+ |
+ return GetForUser(user); |
+} |
+ |
+// static |
+FingerprintUnlockFactory* FingerprintUnlockFactory::GetInstance() { |
+ return base::Singleton<FingerprintUnlockFactory>::get(); |
+} |
+ |
+FingerprintUnlockFactory::FingerprintUnlockFactory() |
+ : BrowserContextKeyedServiceFactory( |
+ "FingerprintUnlockFactory", |
+ BrowserContextDependencyManager::GetInstance()) {} |
+ |
+FingerprintUnlockFactory::~FingerprintUnlockFactory() {} |
+ |
+KeyedService* FingerprintUnlockFactory::BuildServiceInstanceFor( |
+ content::BrowserContext* context) const { |
+ return new FingerprintUnlock( |
+ Profile::FromBrowserContext(context)->GetPrefs()); |
+} |
+ |
+} // namespace quick_unlock |
+} // namespace chromeos |