diff options
author | mdm@chromium.org <mdm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-28 01:38:10 +0000 |
---|---|---|
committer | mdm@chromium.org <mdm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-28 01:38:10 +0000 |
commit | 111a1d6c4b289a4409e188e9b2fcb812cfb3fd2c (patch) | |
tree | 1ccee9c0724ea25286656f2a880c421fbcabcc15 /chrome/browser/resources | |
parent | e94a4d04cfb2f2fa6955561d130521cfedc52e38 (diff) | |
download | chromium_src-111a1d6c4b289a4409e188e9b2fcb812cfb3fd2c.zip chromium_src-111a1d6c4b289a4409e188e9b2fcb812cfb3fd2c.tar.gz chromium_src-111a1d6c4b289a4409e188e9b2fcb812cfb3fd2c.tar.bz2 |
Keep the original index of password list items when filtering, so the right password can be deleted. (Instead of some random other password!)
BUG=87221
TEST=deleteting passwords when the password list is filtered (searched) works correctly
Review URL: http://codereview.chromium.org/7274015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@90695 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/resources')
-rw-r--r-- | chrome/browser/resources/options/password_manager.js | 10 | ||||
-rw-r--r-- | chrome/browser/resources/options/password_manager_list.js | 8 |
2 files changed, 15 insertions, 3 deletions
diff --git a/chrome/browser/resources/options/password_manager.js b/chrome/browser/resources/options/password_manager.js index 2c11928..273d2c0 100644 --- a/chrome/browser/resources/options/password_manager.js +++ b/chrome/browser/resources/options/password_manager.js @@ -153,9 +153,15 @@ cr.define('options', function() { // Implement password searching here in javascript, rather than in C++. // The number of saved passwords shouldn't be too big for us to handle. var query = this.lastQuery_; - var filter = function(entry) { + var filter = function(entry, index, list) { // Search both URL and username. - return entry[0].indexOf(query) >= 0 || entry[1].indexOf(query) >= 0; + if (entry[0].indexOf(query) >= 0 || entry[1].indexOf(query) >= 0) { + // Keep the original index so we can delete correctly. See also + // deleteItemAtIndex() in password_manager_list.js that uses this. + entry[3] = index; + return true; + } + return false; }; entries = entries.filter(filter); } diff --git a/chrome/browser/resources/options/password_manager_list.js b/chrome/browser/resources/options/password_manager_list.js index 7b791d2..c3b822a 100644 --- a/chrome/browser/resources/options/password_manager_list.js +++ b/chrome/browser/resources/options/password_manager_list.js @@ -10,7 +10,8 @@ cr.define('options.passwordManager', function() { /** * Creates a new passwords list item. - * @param {Array} entry An array of the form [url, username, password]. + * @param {Array} entry An array of the form [url, username, password]. When + * the list has been filtered, a fourth element [index] may be present. * @constructor * @extends {cr.ui.ListItem} */ @@ -229,6 +230,11 @@ cr.define('options.passwordManager', function() { /** @inheritDoc */ deleteItemAtIndex: function(index) { + var item = this.dataModel.item(index); + if (item && item.length > 3) { + // The fourth element, if present, is the original index to delete. + index = item[3]; + } PasswordManager.removeSavedPassword(index); }, |