Chromium Code Reviews| 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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 168 * Updates the data model for the saved passwords list with the values from | 168 * Updates the data model for the saved passwords list with the values from |
| 169 * |entries|. | 169 * |entries|. |
| 170 * @param {!Array} entries The list of saved password data. | 170 * @param {!Array} entries The list of saved password data. |
| 171 */ | 171 */ |
| 172 setSavedPasswordsList_: function(entries) { | 172 setSavedPasswordsList_: function(entries) { |
| 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 shown URL and username. |
| 179 if (entry[0].toLowerCase().indexOf(query.toLowerCase()) >= 0 || | 179 var shownUrl = entry[options.passwordManager.SHOWN_URL_DATA_INDEX]; |
| 180 entry[1].toLowerCase().indexOf(query.toLowerCase()) >= 0) { | 180 var username = entry[options.passwordManager.USERNAME_DATA_INDEX]; |
| 181 if (shownUrl.toLowerCase().indexOf(query.toLowerCase()) >= 0 || | |
| 182 username.toLowerCase().indexOf(query.toLowerCase()) >= 0) { | |
| 181 // Keep the original index so we can delete correctly. See also | 183 // Keep the original index so we can delete correctly. See also |
| 182 // deleteItemAtIndex() in password_manager_list.js that uses this. | 184 // deleteItemAtIndex() in password_manager_list.js that uses this. |
| 183 entry[4] = index; | 185 entry[options.passwordManager.ORIGINAL_DATA_INDEX] = index; |
| 184 return true; | 186 return true; |
| 185 } | 187 } |
| 186 return false; | 188 return false; |
| 187 }; | 189 }; |
| 188 entries = entries.filter(filter); | 190 entries = entries.filter(filter); |
| 189 } | 191 } |
| 190 this.savedPasswordsList_.dataModel = new ArrayDataModel(entries); | 192 this.savedPasswordsList_.dataModel = new ArrayDataModel(entries); |
| 191 this.updateListVisibility_(this.savedPasswordsList_); | 193 this.updateListVisibility_(this.savedPasswordsList_); |
| 192 }, | 194 }, |
| 193 | 195 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 207 * @param {number} index The original index of the entry in the model. | 209 * @param {number} index The original index of the entry in the model. |
| 208 * @param {string} password The saved password. | 210 * @param {string} password The saved password. |
| 209 */ | 211 */ |
| 210 showPassword_: function(index, password) { | 212 showPassword_: function(index, password) { |
| 211 var model = this.savedPasswordsList_.dataModel; | 213 var model = this.savedPasswordsList_.dataModel; |
| 212 if (this.lastQuery_) { | 214 if (this.lastQuery_) { |
| 213 // When a filter is active, |index| does not represent the current | 215 // When a filter is active, |index| does not represent the current |
| 214 // index in the model, but each entry stores its original index, so | 216 // index in the model, but each entry stores its original index, so |
| 215 // we can find the item using a linear search. | 217 // we can find the item using a linear search. |
| 216 for (var i = 0; i < model.length; ++i) { | 218 for (var i = 0; i < model.length; ++i) { |
| 217 if (model.item(i)[4] == index) { | 219 if (model.item(i)[options.passwordManager.ORIGINAL_DATA_INDEX] == |
|
Evan Stade
2015/10/05 18:59:41
The item should be changed to a dict (js object) a
kolos1
2015/10/06 18:52:32
Done.
| |
| 220 index) { | |
| 218 index = i; | 221 index = i; |
| 219 break; | 222 break; |
| 220 } | 223 } |
| 221 } | 224 } |
| 222 } | 225 } |
| 223 | 226 |
| 224 // Reveal the password in the UI. | 227 // Reveal the password in the UI. |
| 225 var item = this.savedPasswordsList_.getListItemByIndex(index); | 228 var item = this.savedPasswordsList_.getListItemByIndex(index); |
| 226 item.showPassword(password); | 229 item.showPassword(password); |
| 227 }, | 230 }, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 264 'setPasswordExceptionsList', | 267 'setPasswordExceptionsList', |
| 265 'showPassword' | 268 'showPassword' |
| 266 ]); | 269 ]); |
| 267 | 270 |
| 268 // Export | 271 // Export |
| 269 return { | 272 return { |
| 270 PasswordManager: PasswordManager | 273 PasswordManager: PasswordManager |
| 271 }; | 274 }; |
| 272 | 275 |
| 273 }); | 276 }); |
| OLD | NEW |