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

Unified 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 7 errors. Created 4 years 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/settings/people_page/fingerprint_list.js
diff --git a/chrome/browser/resources/settings/people_page/fingerprint_list.js b/chrome/browser/resources/settings/people_page/fingerprint_list.js
new file mode 100644
index 0000000000000000000000000000000000000000..eba8ba657a1389c833b2c3ec6bd20e1ef5c42f89
--- /dev/null
+++ b/chrome/browser/resources/settings/people_page/fingerprint_list.js
@@ -0,0 +1,104 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/**
+ * @fileoverview
+ * Polymer element for displaying a list of fingerprints.
+ *
+ * Example:
+ * <settings-fingerprint-list></settings-fingerprint-list>
+ */
+
+(function() {
+'use strict';
+
+/**
+ * The max number of fingerprints this list can hold.
+ * @type {number}
+ * @const
+ */
+var MAX_NUMBER_FINGERPRINTS_ALLOWED = 5;
+
+Polymer({
+ is: 'settings-fingerprint-list',
+
+ behaviors: [
+ I18nBehavior,
+ ],
+
+ properties: {
+ /**
+ * The list of fingerprint objects.
+ * @type {Array<Object>}
+ * @private
stevenjb 2016/12/07 23:25:40 Combine lines: @private {Array<Object>}
sammiequon 2016/12/08 03:50:50 Done.
+ */
+ fingerprints_: {
+ type: Array,
+ value: function() {
+ return [];
+ },
+ notify: true,
+ }
+ },
+
+ /**
+ * Returns the text to be displayed when the user has set up
+ * |MAX_NUMBER_FINGERPRINTS_ALLOWED|.
+ * @return {string}
+ * @private
+ */
+ getFingerprintButtonCannotAddText_: function() {
+ return this.i18n('lockScreenCannotAddFingerprint',
+ MAX_NUMBER_FINGERPRINTS_ALLOWED);
+ },
+
+ /**
+ * 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.
+ * @param {string} name The name we are looking for.
+ * @return {boolean}
+ * @private
+ */
+ isNameUsed_: function(name) {
+ return !!this.fingerprints_.find(function(e) {
+ return e.name == name;
+ });
+ },
+
+ /**
+ * Adds a fingerprint with a default name.
+ * @private
+ */
+ onAddFingerprint_: function() {
+ // Determines what the newly added fingerprint's name should be.
+ // 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
+
+ var fingerprintName;
+ for (var i = 1; i <= MAX_NUMBER_FINGERPRINTS_ALLOWED; ++i) {
+ fingerprintName = this.i18n('lockScreenFingerprintNewName', i);
+ if (this.isNameUsed_(fingerprintName))
+ continue;
+ break;
+ }
+ this.push('fingerprints_', { 'name': fingerprintName });
+ },
+
+ /**
+ * Deletes a fingerprint from |fingerprints_|.
+ * @private
+ */
+ onFingerprintDelete_: function(e) {
+ // TODO(sammiequon): Remove fingerprint using private API once it is ready.
+ this.splice('fingerprints_', e.model.index, 1);
+ },
+
+ /**
+ * Checks whether another fingerprint can be added.
+ * @return {boolean}
+ * @private
+ */
+ canAddNewFingerprint_: function(length) {
+ return length < MAX_NUMBER_FINGERPRINTS_ALLOWED;
+ }
+});
+})();

Powered by Google App Engine
This is Rietveld 408576698