OLD | NEW |
---|---|
(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 /** | |
6 * @fileoverview | |
7 * Polymer element for displaying a list of fingerprints. | |
8 * | |
9 * Example: | |
10 * <settings-fingerprint-list></settings-fingerprint-list> | |
11 */ | |
12 | |
13 (function() { | |
14 'use strict'; | |
15 | |
16 /** | |
17 * The max number of fingerprints this list can hold. | |
18 * @type {number} | |
19 * @const | |
20 */ | |
21 var MAX_NUMBER_FINGERPRINTS_ALLOWED = 5; | |
22 | |
23 Polymer({ | |
24 is: 'settings-fingerprint-list', | |
25 | |
26 behaviors: [ | |
27 I18nBehavior, | |
28 ], | |
29 | |
30 properties: { | |
31 /** | |
32 * The list of fingerprint objects. | |
33 * @type {Array<Object>} | |
34 * @private | |
stevenjb
2016/12/07 23:25:40
Combine lines:
@private {Array<Object>}
sammiequon
2016/12/08 03:50:50
Done.
| |
35 */ | |
36 fingerprints_: { | |
37 type: Array, | |
38 value: function() { | |
39 return []; | |
40 }, | |
41 notify: true, | |
42 } | |
43 }, | |
44 | |
45 /** | |
46 * Returns the text to be displayed when the user has set up | |
47 * |MAX_NUMBER_FINGERPRINTS_ALLOWED|. | |
48 * @return {string} | |
49 * @private | |
50 */ | |
51 getFingerprintButtonCannotAddText_: function() { | |
52 return this.i18n('lockScreenCannotAddFingerprint', | |
53 MAX_NUMBER_FINGERPRINTS_ALLOWED); | |
54 }, | |
55 | |
56 /** | |
57 * Check if the registered fingerprints has a fingerprint with name |name|. | |
stevenjb
2016/12/07 23:25:40
s/the registered fingerprints/|fingerprints_|/ (or
sammiequon
2016/12/08 03:50:50
Done.
| |
58 * @param {string} name The name we are looking for. | |
59 * @return {boolean} | |
60 * @private | |
61 */ | |
62 isNameUsed_: function(name) { | |
63 return !!this.fingerprints_.find(function(e) { | |
64 return e.name == name; | |
65 }); | |
66 }, | |
67 | |
68 /** | |
69 * Adds a fingerprint with a default name. | |
70 * @private | |
71 */ | |
72 onAddFingerprint_: function() { | |
73 // Determines what the newly added fingerprint's name should be. | |
74 // TODO(sammiequon): Add fingerprint using private API once it is ready. | |
stevenjb
2016/12/07 23:25:40
Rather than committing fake code in the initial UI
sammiequon
2016/12/08 03:50:50
I do not think too much of the initial code here w
stevenjb
2016/12/08 16:49:40
Shouldn't this whole function just be:
chrome.fin
sammiequon
2016/12/08 20:22:40
I put the naming stuff here since the users change
| |
75 | |
76 var fingerprintName; | |
77 for (var i = 1; i <= MAX_NUMBER_FINGERPRINTS_ALLOWED; ++i) { | |
78 fingerprintName = this.i18n('lockScreenFingerprintNewName', i); | |
79 if (this.isNameUsed_(fingerprintName)) | |
80 continue; | |
81 break; | |
82 } | |
83 this.push('fingerprints_', { 'name': fingerprintName }); | |
84 }, | |
85 | |
86 /** | |
87 * Deletes a fingerprint from |fingerprints_|. | |
88 * @private | |
89 */ | |
90 onFingerprintDelete_: function(e) { | |
91 // TODO(sammiequon): Remove fingerprint using private API once it is ready. | |
92 this.splice('fingerprints_', e.model.index, 1); | |
93 }, | |
94 | |
95 /** | |
96 * Checks whether another fingerprint can be added. | |
97 * @return {boolean} | |
98 * @private | |
99 */ | |
100 canAddNewFingerprint_: function(length) { | |
101 return length < MAX_NUMBER_FINGERPRINTS_ALLOWED; | |
102 } | |
103 }); | |
104 })(); | |
OLD | NEW |