Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(769)

Side by Side Diff: chrome/browser/resources/options/password_manager.js

Issue 1318523011: [Password Manager] Copiable username and origin. Linkable origin elided from the left. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes with StringPiece Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/resources/options/password_manager_list.css » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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_FIELD];
180 entry[1].toLowerCase().indexOf(query.toLowerCase()) >= 0) { 180 var username = entry[options.passwordManager.USERNAME_FIELD];
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_INDEX_FIELD] = 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
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_INDEX_FIELD] ==
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 27 matching lines...) Expand all
255 'setPasswordExceptionsList', 258 'setPasswordExceptionsList',
256 'showPassword' 259 'showPassword'
257 ]); 260 ]);
258 261
259 // Export 262 // Export
260 return { 263 return {
261 PasswordManager: PasswordManager 264 PasswordManager: PasswordManager
262 }; 265 };
263 266
264 }); 267 });
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/options/password_manager_list.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698