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

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

Issue 2715823004: Add FingerprintUnlock KeyedService for each profile (Closed)
Patch Set: rebase 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 2016 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/pin_storage_factory.h"
6
7 #include "chrome/browser/chromeos/login/quick_unlock/pin_storage.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 PinStorage* PinStorageFactory::GetForProfile(Profile* profile) {
19 return static_cast<PinStorage*>(
20 GetInstance()->GetServiceForBrowserContext(profile, true));
21 }
22
23 // static
24 PinStorage* PinStorageFactory::GetForUser(const user_manager::User* user) {
25 Profile* profile = ProfileHelper::Get()->GetProfileByUser(user);
26 if (!profile)
27 return nullptr;
28
29 return GetForProfile(profile);
30 }
31
32 // static
33 PinStorage* PinStorageFactory::GetForAccountId(const AccountId& account_id) {
34 const user_manager::User* user =
35 user_manager::UserManager::Get()->FindUser(account_id);
36 if (!user)
37 return nullptr;
38
39 return GetForUser(user);
40 }
41
42 // static
43 PinStorageFactory* PinStorageFactory::GetInstance() {
44 return base::Singleton<PinStorageFactory>::get();
45 }
46
47 PinStorageFactory::PinStorageFactory()
48 : BrowserContextKeyedServiceFactory(
49 "PinStorageFactory",
50 BrowserContextDependencyManager::GetInstance()) {}
51
52 PinStorageFactory::~PinStorageFactory() {}
53
54 KeyedService* PinStorageFactory::BuildServiceInstanceFor(
55 content::BrowserContext* context) const {
56 return new PinStorage(Profile::FromBrowserContext(context)->GetPrefs());
57 }
58
59 } // namespace quick_unlock
60 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698