| Index: chrome/browser/resources/options/password_manager.js
|
| diff --git a/chrome/browser/resources/options/password_manager.js b/chrome/browser/resources/options/password_manager.js
|
| index 4758254538cf243d93e99601941836210b30514d..24a5eac381de7d745c4545cf81ad8713959d41e2 100644
|
| --- a/chrome/browser/resources/options/password_manager.js
|
| +++ b/chrome/browser/resources/options/password_manager.js
|
| @@ -54,6 +54,13 @@ cr.define('options', function() {
|
| */
|
| lastQuery_: null,
|
|
|
| + /**
|
| + * Whether a search query filter is applied to the current data model.
|
| + * @type {boolean}
|
| + * @private
|
| + */
|
| + filterIsActive_: false,
|
| +
|
| /** @override */
|
| initializePage: function() {
|
| Page.prototype.initializePage.call(this);
|
| @@ -153,6 +160,7 @@ cr.define('options', function() {
|
| * @param {Array} entries The list of saved password data.
|
| */
|
| setSavedPasswordsList_: function(entries) {
|
| + this.filterIsActive_ = !!this.lastQuery_;
|
| if (this.lastQuery_) {
|
| // Implement password searching here in javascript, rather than in C++.
|
| // The number of saved passwords shouldn't be too big for us to handle.
|
| @@ -169,6 +177,9 @@ cr.define('options', function() {
|
| return false;
|
| };
|
| entries = entries.filter(filter);
|
| + } else {
|
| + // Adds the Add New Entry row.
|
| + entries.push(null);
|
| }
|
| this.savedPasswordsList_.dataModel = new ArrayDataModel(entries);
|
| this.updateListVisibility_(this.savedPasswordsList_);
|
| @@ -192,7 +203,7 @@ cr.define('options', function() {
|
| */
|
| showPassword_: function(index, password) {
|
| var model = this.savedPasswordsList_.dataModel;
|
| - if (this.lastQuery_) {
|
| + if (this.filterIsActive_) {
|
| // When a filter is active, |index| does not represent the current
|
| // index in the model, but each entry stores its original index, so
|
| // we can find the item using a linear search.
|
| @@ -208,6 +219,52 @@ cr.define('options', function() {
|
| var item = this.savedPasswordsList_.getListItemByIndex(index);
|
| item.showPassword(password);
|
| },
|
| +
|
| + /**
|
| + * Forwards the validity of the origin to the Add New Entry row.
|
| + * @param {string} url The origin.
|
| + * @param {boolean} valid The validity of the origin for adding.
|
| + * @private
|
| + */
|
| + originValidityCheckComplete_: function(url, valid) {
|
| + // There is no Add New Entry row when a filter is active.
|
| + if (this.filterIsActive_)
|
| + return;
|
| + // Since no filter is active, the Add New Entry row always exists and its
|
| + // item is the last one.
|
| + assert(this.savedPasswordsList_.length > 0);
|
| + var addRowItem = this.savedPasswordsList_.getListItemByIndex(
|
| + this.savedPasswordsList_.length - 1);
|
| + addRowItem.originValidityCheckComplete(url, valid);
|
| + },
|
| + };
|
| +
|
| + /**
|
| + * Requests the browser to check the validity of the origin being edited by
|
| + * the user in the Add New Entry row.
|
| + * @param {string} url The origin being edited.
|
| + */
|
| + PasswordManager.checkOriginValidityForAdding = function(url) {
|
| + chrome.send('checkOriginValidityForAdding', [url]);
|
| + };
|
| +
|
| + /**
|
| + * Adds a new password entry.
|
| + * @param {string} url The origin.
|
| + * @param {string} username The username value.
|
| + * @param {string} password The password value.
|
| + */
|
| + PasswordManager.addPassword = function(url, username, password) {
|
| + chrome.send('addPassword', [url, username, password]);
|
| + };
|
| +
|
| + /**
|
| + * Updates the password value of an entry.
|
| + * @param {number} rowIndex The row to update.
|
| + * @param {string} newPassword The new password value.
|
| + */
|
| + PasswordManager.updatePassword = function(rowIndex, newPassword) {
|
| + chrome.send('updatePassword', [String(rowIndex), newPassword]);
|
| };
|
|
|
| /**
|
| @@ -234,7 +291,8 @@ cr.define('options', function() {
|
| [
|
| 'setSavedPasswordsList',
|
| 'setPasswordExceptionsList',
|
| - 'showPassword'
|
| + 'showPassword',
|
| + 'originValidityCheckComplete'
|
| ].forEach(function(name) {
|
| PasswordManager[name] = function() {
|
| var instance = PasswordManager.getInstance();
|
|
|