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

Side by Side Diff: chrome/browser/resources/settings/people_page/fingerprint_list.js

Issue 2538303002: md-settings: Added settings for fingerprint unlock. (Closed)
Patch Set: Fixed patch set 22 errors. Created 3 years, 10 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 (function() {
6 'use strict';
7
8 /**
9 * The max number of fingerprints this list can hold.
10 * @const {number}
11 */
12 var MAX_NUMBER_FINGERPRINTS_ALLOWED = 5;
13
14 Polymer({
15 is: 'settings-fingerprint-list',
16
17 behaviors: [
18 I18nBehavior,
19 ],
20
21 properties: {
22 /**
23 * The list of fingerprint objects.
24 * @private {!Array<string>}
25 */
26 fingerprints_: {
27 type: Array,
28 value: function() {
29 return [];
30 }
31 }
32 },
33
34 /**
35 * Adds a fingerprint with a default name.
36 * @private
37 */
38 onAddFingerprint_: function() {
39 // Determines what the newly added fingerprint's name should be.
40 // TODO(sammiequon): Add fingerprint using private API once it is ready.
41
42 var fingerprintName;
43 for (var i = 1; i <= MAX_NUMBER_FINGERPRINTS_ALLOWED; ++i) {
Dan Beam 2017/01/27 23:11:07 i still think this loop is confusing. if i reach
sammiequon 2017/01/27 23:37:37 i should never > MAX_NUMBER_FINGERPRINTS_ALLOWED s
44 fingerprintName = this.i18n('lockScreenFingerprintNewName', i);
45 if (this.fingerprints_.includes(fingerprintName))
46 continue;
47 break;
48 }
49 this.push('fingerprints_', fingerprintName);
50 },
51
52 /**
53 * Deletes a fingerprint from |fingerprints_|.
54 * @private
55 */
56 onFingerprintDelete_: function(e) {
57 // TODO(sammiequon): Remove fingerprint using private API once it is ready.
58 this.splice('fingerprints_', e.model.index, 1);
59 },
60
61 /**
62 * Returns the text to be displayed for the add fingerprint button.
63 * @return {string}
64 * @private
65 */
66 getFingerprintButtonText_: function() {
67 if (this.canAddNewFingerprint_())
68 return this.i18n('lockScreenAddFingerprint');
69
70 return this.i18n('lockScreenCannotAddFingerprint',
71 MAX_NUMBER_FINGERPRINTS_ALLOWED);
72 },
73
74 /**
75 * Checks whether another fingerprint can be added.
76 * @return {boolean}
77 * @private
78 */
79 canAddNewFingerprint_: function() {
80 return this.fingerprints_.length < MAX_NUMBER_FINGERPRINTS_ALLOWED;
81 }
82 });
83 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698