| 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..1c4ac476ccf082bc2d998b5ba3d6fe3e817a308e
|
| --- /dev/null
|
| +++ b/chrome/browser/resources/settings/people_page/fingerprint_list.js
|
| @@ -0,0 +1,107 @@
|
| +// 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.
|
| + * @private {Array<Object>}
|
| + */
|
| + fingerprints_: {
|
| + type: Array,
|
| + value: function() {
|
| + return [];
|
| + },
|
| + notify: true
|
| + }
|
| + },
|
| +
|
| + /**
|
| + * Check if |fingerprints_| has a fingerprint with name |name|.
|
| + * @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.
|
| +
|
| + 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 });
|
| + this.$.fingerprintsList.fire('iron-resize');
|
| + },
|
| +
|
| + /**
|
| + * 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);
|
| + this.$.fingerprintsList.fire('iron-resize');
|
| + },
|
| +
|
| + /**
|
| + * Returns the text to be displayed for the add fingerprint button.
|
| + * @return {string}
|
| + * @private
|
| + */
|
| + getFingerprintButtonText_: function(length) {
|
| + if (this.canAddNewFingerprint_(length))
|
| + return this.i18n('lockScreenAddFingerprint');
|
| +
|
| + return this.i18n('lockScreenCannotAddFingerprint',
|
| + MAX_NUMBER_FINGERPRINTS_ALLOWED);
|
| + },
|
| +
|
| + /**
|
| + * Checks whether another fingerprint can be added.
|
| + * @return {boolean}
|
| + * @private
|
| + */
|
| + canAddNewFingerprint_: function(length) {
|
| + return length < MAX_NUMBER_FINGERPRINTS_ALLOWED;
|
| + }
|
| +});
|
| +})();
|
|
|