| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 cr.define('options', function() { | 5 cr.define('options', function() { |
| 6 /** @const */ var Page = cr.ui.pageManager.Page; | 6 /** @const */ var Page = cr.ui.pageManager.Page; |
| 7 /** @const */ var PageManager = cr.ui.pageManager.PageManager; | 7 /** @const */ var PageManager = cr.ui.pageManager.PageManager; |
| 8 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; | 8 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; |
| 9 | 9 |
| 10 ///////////////////////////////////////////////////////////////////////////// | 10 ///////////////////////////////////////////////////////////////////////////// |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 if (this.lastQuery_) { | 173 if (this.lastQuery_) { |
| 174 // Implement password searching here in javascript, rather than in C++. | 174 // Implement password searching here in javascript, rather than in C++. |
| 175 // The number of saved passwords shouldn't be too big for us to handle. | 175 // The number of saved passwords shouldn't be too big for us to handle. |
| 176 var query = this.lastQuery_; | 176 var query = this.lastQuery_; |
| 177 var filter = function(entry, index, list) { | 177 var filter = function(entry, index, list) { |
| 178 // Search both URL and username. | 178 // Search both URL and username. |
| 179 if (entry[0].toLowerCase().indexOf(query.toLowerCase()) >= 0 || | 179 if (entry[0].toLowerCase().indexOf(query.toLowerCase()) >= 0 || |
| 180 entry[1].toLowerCase().indexOf(query.toLowerCase()) >= 0) { | 180 entry[1].toLowerCase().indexOf(query.toLowerCase()) >= 0) { |
| 181 // Keep the original index so we can delete correctly. See also | 181 // Keep the original index so we can delete correctly. See also |
| 182 // deleteItemAtIndex() in password_manager_list.js that uses this. | 182 // deleteItemAtIndex() in password_manager_list.js that uses this. |
| 183 entry[3] = index; | 183 entry[4] = index; |
| 184 return true; | 184 return true; |
| 185 } | 185 } |
| 186 return false; | 186 return false; |
| 187 }; | 187 }; |
| 188 entries = entries.filter(filter); | 188 entries = entries.filter(filter); |
| 189 } | 189 } |
| 190 this.savedPasswordsList_.dataModel = new ArrayDataModel(entries); | 190 this.savedPasswordsList_.dataModel = new ArrayDataModel(entries); |
| 191 this.updateListVisibility_(this.savedPasswordsList_); | 191 this.updateListVisibility_(this.savedPasswordsList_); |
| 192 }, | 192 }, |
| 193 | 193 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 207 * @param {number} index The original index of the entry in the model. | 207 * @param {number} index The original index of the entry in the model. |
| 208 * @param {string} password The saved password. | 208 * @param {string} password The saved password. |
| 209 */ | 209 */ |
| 210 showPassword_: function(index, password) { | 210 showPassword_: function(index, password) { |
| 211 var model = this.savedPasswordsList_.dataModel; | 211 var model = this.savedPasswordsList_.dataModel; |
| 212 if (this.lastQuery_) { | 212 if (this.lastQuery_) { |
| 213 // When a filter is active, |index| does not represent the current | 213 // When a filter is active, |index| does not represent the current |
| 214 // index in the model, but each entry stores its original index, so | 214 // index in the model, but each entry stores its original index, so |
| 215 // we can find the item using a linear search. | 215 // we can find the item using a linear search. |
| 216 for (var i = 0; i < model.length; ++i) { | 216 for (var i = 0; i < model.length; ++i) { |
| 217 if (model.item(i)[3] == index) { | 217 if (model.item(i)[4] == index) { |
| 218 index = i; | 218 index = i; |
| 219 break; | 219 break; |
| 220 } | 220 } |
| 221 } | 221 } |
| 222 } | 222 } |
| 223 | 223 |
| 224 // Reveal the password in the UI. | 224 // Reveal the password in the UI. |
| 225 var item = this.savedPasswordsList_.getListItemByIndex(index); | 225 var item = this.savedPasswordsList_.getListItemByIndex(index); |
| 226 item.showPassword(password); | 226 item.showPassword(password); |
| 227 }, | 227 }, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 'setPasswordExceptionsList', | 264 'setPasswordExceptionsList', |
| 265 'showPassword' | 265 'showPassword' |
| 266 ]); | 266 ]); |
| 267 | 267 |
| 268 // Export | 268 // Export |
| 269 return { | 269 return { |
| 270 PasswordManager: PasswordManager | 270 PasswordManager: PasswordManager |
| 271 }; | 271 }; |
| 272 | 272 |
| 273 }); | 273 }); |
| OLD | NEW |