Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: chrome/browser/chromeos/login/quick_unlock/fingerprint_unlock_factory.cc

Issue 2715823004: Add FingerprintUnlock KeyedService for each profile (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 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/chromeos/login/quick_unlock/fingerprint_unlock_factory. h"
6
7 #include "chrome/browser/chromeos/login/quick_unlock/fingerprint_unlock.h"
8 #include "chrome/browser/chromeos/profiles/profile_helper.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "components/keyed_service/content/browser_context_dependency_manager.h"
11 #include "components/user_manager/user.h"
12 #include "components/user_manager/user_manager.h"
13
14 namespace chromeos {
15 namespace quick_unlock {
16
17 // static
18 FingerprintUnlock* FingerprintUnlockFactory::GetForProfile(Profile* profile) {
19 return static_cast<FingerprintUnlock*>(
20 GetInstance()->GetServiceForBrowserContext(profile, true));
21 }
22
23 // static
24 FingerprintUnlock* FingerprintUnlockFactory::GetForUser(
25 const user_manager::User* user) {
26 Profile* profile = ProfileHelper::Get()->GetProfileByUser(user);
27 if (!profile)
28 return nullptr;
29
30 return GetForProfile(profile);
31 }
32
33 // static
34 FingerprintUnlock* FingerprintUnlockFactory::GetForAccountId(
35 const AccountId& account_id) {
36 const user_manager::User* user =
37 user_manager::UserManager::Get()->FindUser(account_id);
38 if (!user)
39 return nullptr;
40
41 return GetForUser(user);
42 }
43
44 // static
45 FingerprintUnlockFactory* FingerprintUnlockFactory::GetInstance() {
46 return base::Singleton<FingerprintUnlockFactory>::get();
47 }
48
49 FingerprintUnlockFactory::FingerprintUnlockFactory()
50 : BrowserContextKeyedServiceFactory(
51 "FingerprintUnlockFactory",
52 BrowserContextDependencyManager::GetInstance()) {}
53
54 FingerprintUnlockFactory::~FingerprintUnlockFactory() {}
55
56 KeyedService* FingerprintUnlockFactory::BuildServiceInstanceFor(
57 content::BrowserContext* context) const {
58 return new FingerprintUnlock(
59 Profile::FromBrowserContext(context)->GetPrefs());
60 }
61
62 } // namespace quick_unlock
63 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698