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

Side by Side Diff: chrome/browser/chromeos/extensions/quick_unlock_private/quick_unlock_private_api.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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/extensions/quick_unlock_private/quick_unlock_p rivate_api.h" 5 #include "chrome/browser/chromeos/extensions/quick_unlock_private/quick_unlock_p rivate_api.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "chrome/browser/chromeos/login/quick_unlock/pin_storage.h" 8 #include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_factory.h"
9 #include "chrome/browser/chromeos/login/quick_unlock/pin_storage_factory.h" 9 #include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_storage.h"
10 #include "chrome/browser/chromeos/profiles/profile_helper.h" 10 #include "chrome/browser/chromeos/profiles/profile_helper.h"
11 #include "chrome/common/pref_names.h" 11 #include "chrome/common/pref_names.h"
12 #include "chromeos/login/auth/extended_authenticator.h" 12 #include "chromeos/login/auth/extended_authenticator.h"
13 #include "chromeos/login/auth/user_context.h" 13 #include "chromeos/login/auth/user_context.h"
14 #include "components/prefs/pref_service.h" 14 #include "components/prefs/pref_service.h"
15 #include "extensions/browser/event_router.h" 15 #include "extensions/browser/event_router.h"
16 16
17 namespace extensions { 17 namespace extensions {
18 18
19 namespace quick_unlock_private = api::quick_unlock_private; 19 namespace quick_unlock_private = api::quick_unlock_private;
(...skipping 22 matching lines...) Expand all
42 // A list of the most commmonly used PINs, whose digits are not all the same, 42 // A list of the most commmonly used PINs, whose digits are not all the same,
43 // increasing or decreasing. This list is taken from 43 // increasing or decreasing. This list is taken from
44 // www.datagenetics.com/blog/september32012/. 44 // www.datagenetics.com/blog/september32012/.
45 const char* kMostCommonPins[] = {"1212", "1004", "2000", "6969", 45 const char* kMostCommonPins[] = {"1212", "1004", "2000", "6969",
46 "1122", "1313", "2001", "1010"}; 46 "1122", "1313", "2001", "1010"};
47 47
48 // Returns the active set of quick unlock modes. 48 // Returns the active set of quick unlock modes.
49 QuickUnlockModeList ComputeActiveModes(Profile* profile) { 49 QuickUnlockModeList ComputeActiveModes(Profile* profile) {
50 QuickUnlockModeList modes; 50 QuickUnlockModeList modes;
51 51
52 chromeos::quick_unlock::PinStorage* pin_storage = 52 chromeos::quick_unlock::QuickUnlockStorage* quick_unlock_storage =
53 chromeos::quick_unlock::PinStorageFactory::GetForProfile(profile); 53 chromeos::quick_unlock::QuickUnlockFactory::GetForProfile(profile);
54 if (pin_storage && pin_storage->IsPinSet()) 54 if (quick_unlock_storage && quick_unlock_storage->pin_storage()->IsPinSet())
55 modes.push_back(quick_unlock_private::QUICK_UNLOCK_MODE_PIN); 55 modes.push_back(quick_unlock_private::QUICK_UNLOCK_MODE_PIN);
56 56
57 return modes; 57 return modes;
58 } 58 }
59 59
60 // Returns true if |a| and |b| contain the same elements. The elements do not 60 // Returns true if |a| and |b| contain the same elements. The elements do not
61 // need to be in the same order. 61 // need to be in the same order.
62 bool AreModesEqual(const QuickUnlockModeList& a, const QuickUnlockModeList& b) { 62 bool AreModesEqual(const QuickUnlockModeList& a, const QuickUnlockModeList& b) {
63 if (a.size() != b.size()) 63 if (a.size() != b.size())
64 return false; 64 return false;
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 393
394 if (mode == quick_unlock_private::QUICK_UNLOCK_MODE_PIN) { 394 if (mode == quick_unlock_private::QUICK_UNLOCK_MODE_PIN) {
395 update_pin = !credential.empty(); 395 update_pin = !credential.empty();
396 pin_credential = credential; 396 pin_credential = credential;
397 } 397 }
398 } 398 }
399 399
400 // Apply changes. 400 // Apply changes.
401 if (update_pin) { 401 if (update_pin) {
402 Profile* profile = chrome_details_.GetProfile(); 402 Profile* profile = chrome_details_.GetProfile();
403 chromeos::quick_unlock::PinStorage* pin_storage = 403 chromeos::quick_unlock::QuickUnlockStorage* quick_unlock_storage =
404 chromeos::quick_unlock::PinStorageFactory::GetForProfile(profile); 404 chromeos::quick_unlock::QuickUnlockFactory::GetForProfile(profile);
405 405
406 if (pin_credential.empty()) { 406 if (pin_credential.empty()) {
407 pin_storage->RemovePin(); 407 quick_unlock_storage->pin_storage()->RemovePin();
408 } else { 408 } else {
409 pin_storage->SetPin(pin_credential); 409 quick_unlock_storage->pin_storage()->SetPin(pin_credential);
410 pin_storage->MarkStrongAuth(); 410 quick_unlock_storage->MarkStrongAuth();
411 } 411 }
412 } 412 }
413 } 413 }
414 414
415 // Triggers a quickUnlockPrivate.onActiveModesChanged change event. 415 // Triggers a quickUnlockPrivate.onActiveModesChanged change event.
416 void QuickUnlockPrivateSetModesFunction::FireEvent( 416 void QuickUnlockPrivateSetModesFunction::FireEvent(
417 const QuickUnlockModeList& modes) { 417 const QuickUnlockModeList& modes) {
418 // Allow unit tests to override how events are raised/handled. 418 // Allow unit tests to override how events are raised/handled.
419 if (!modes_changed_handler_.is_null()) { 419 if (!modes_changed_handler_.is_null()) {
420 modes_changed_handler_.Run(modes); 420 modes_changed_handler_.Run(modes);
421 return; 421 return;
422 } 422 }
423 423
424 std::unique_ptr<base::ListValue> args = OnActiveModesChanged::Create(modes); 424 std::unique_ptr<base::ListValue> args = OnActiveModesChanged::Create(modes);
425 std::unique_ptr<Event> event( 425 std::unique_ptr<Event> event(
426 new Event(events::QUICK_UNLOCK_PRIVATE_ON_ACTIVE_MODES_CHANGED, 426 new Event(events::QUICK_UNLOCK_PRIVATE_ON_ACTIVE_MODES_CHANGED,
427 OnActiveModesChanged::kEventName, std::move(args))); 427 OnActiveModesChanged::kEventName, std::move(args)));
428 EventRouter::Get(browser_context())->BroadcastEvent(std::move(event)); 428 EventRouter::Get(browser_context())->BroadcastEvent(std::move(event));
429 } 429 }
430 430
431 } // namespace extensions 431 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698