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

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

Issue 2571443002: Fix bug when transitioning from an empty to a non-empty password list (Closed)
Patch Set: Created 4 years 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 | no next file » | 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 if (this.lastQuery_ != filter) { 153 if (this.lastQuery_ != filter) {
154 this.lastQuery_ = filter; 154 this.lastQuery_ = filter;
155 // Searching for passwords has the side effect of requerying the 155 // Searching for passwords has the side effect of requerying the
156 // underlying password store. This is done intentionally, as on OS X and 156 // underlying password store. This is done intentionally, as on OS X and
157 // Linux they can change from outside and we won't be notified of it. 157 // Linux they can change from outside and we won't be notified of it.
158 chrome.send('updatePasswordLists'); 158 chrome.send('updatePasswordLists');
159 } 159 }
160 }, 160 },
161 161
162 /** 162 /**
163 * Updates the visibility of the list and empty list placeholder. 163 * Updates the list with the given entries and updates the visibility of the
164 * list and empty list placeholder.
164 * @param {!cr.ui.List} list The list to toggle visilibility for. 165 * @param {!cr.ui.List} list The list to toggle visilibility for.
166 * @param {!Array} entries The list of entries.
165 */ 167 */
166 updateListVisibility_: function(list) { 168 updateListAndVisibility_: function(list, entries) {
167 var empty = list.dataModel.length == 0; 169 // Since the dataModel setter behaves lazily, the visibility needs to be
170 // updated before the list itself. Otherwise, there will be no visible
171 // effect when the list transitions from a hidden to a visible state. This
172 // is because the setter would realize that the list is hidden and would
173 // not render its new entries (http://crbug.com/672869).
174 var empty = entries.length == 0;
168 var listPlaceHolderID = list.id + '-empty-placeholder'; 175 var listPlaceHolderID = list.id + '-empty-placeholder';
169 list.hidden = empty; 176 list.hidden = empty;
170 $(listPlaceHolderID).hidden = !empty; 177 $(listPlaceHolderID).hidden = !empty;
178 list.dataModel = new ArrayDataModel(entries);
171 }, 179 },
172 180
173 /** 181 /**
174 * Updates eliding of origins. If there is no enough space to show the full 182 * Updates eliding of origins. If there is no enough space to show the full
175 * origin, the origin is elided from the left with ellipsis. 183 * origin, the origin is elided from the left with ellipsis.
176 * @param {!cr.ui.List} list The list to update eliding. 184 * @param {!cr.ui.List} list The list to update eliding.
177 */ 185 */
178 updateOriginsEliding_: function(list) { 186 updateOriginsEliding_: function(list) {
179 var entries = list.getElementsByClassName('deletable-item'); 187 var entries = list.getElementsByClassName('deletable-item');
180 if (entries.length == 0) 188 if (entries.length == 0)
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 username.toLowerCase().indexOf(query.toLowerCase()) >= 0) { 246 username.toLowerCase().indexOf(query.toLowerCase()) >= 0) {
239 // Keep the original index so we can delete correctly. See also 247 // Keep the original index so we can delete correctly. See also
240 // deleteItemAtIndex() in password_manager_list.js that uses this. 248 // deleteItemAtIndex() in password_manager_list.js that uses this.
241 entry[options.passwordManager.ORIGINAL_INDEX_FIELD] = index; 249 entry[options.passwordManager.ORIGINAL_INDEX_FIELD] = index;
242 return true; 250 return true;
243 } 251 }
244 return false; 252 return false;
245 }; 253 };
246 entries = entries.filter(filter); 254 entries = entries.filter(filter);
247 } 255 }
248 this.savedPasswordsList_.dataModel = new ArrayDataModel(entries); 256 this.updateListAndVisibility_(this.savedPasswordsList_, entries);
kolos1 2016/12/12 13:05:10 To prevent closure compilation error, we could add
249 this.updateListVisibility_(this.savedPasswordsList_);
250 // updateOriginsEliding_ should be called after updateListVisibility_, 257 // updateOriginsEliding_ should be called after updateListVisibility_,
251 // otherwise updateOrigins... might be not able to read width of elements. 258 // otherwise updateOrigins... might be not able to read width of elements.
252 this.updateOriginsEliding_(this.savedPasswordsList_); 259 this.updateOriginsEliding_(this.savedPasswordsList_);
253 }, 260 },
254 261
255 /** 262 /**
256 * Updates the data model for the password exceptions list with the values 263 * Updates the data model for the password exceptions list with the values
257 * from |entries|. 264 * from |entries|.
258 * @param {!Array} entries The list of password exception data. 265 * @param {!Array} entries The list of password exception data.
259 */ 266 */
260 setPasswordExceptionsList_: function(entries) { 267 setPasswordExceptionsList_: function(entries) {
261 this.passwordExceptionsList_.dataModel = new ArrayDataModel(entries); 268 this.updateListAndVisibility_(this.passwordExceptionsList_, entries);
262 this.updateListVisibility_(this.passwordExceptionsList_);
263 // updateOriginsEliding_ should be called after updateListVisibility_, 269 // updateOriginsEliding_ should be called after updateListVisibility_,
264 // otherwise updateOrigins... might be not able to read width of elements. 270 // otherwise updateOrigins... might be not able to read width of elements.
265 this.updateOriginsEliding_(this.passwordExceptionsList_); 271 this.updateOriginsEliding_(this.passwordExceptionsList_);
266 }, 272 },
267 273
268 /** 274 /**
269 * Reveals the password for a saved password entry. This is called by the 275 * Reveals the password for a saved password entry. This is called by the
270 * backend after it has authenticated the user. 276 * backend after it has authenticated the user.
271 * @param {number} index The original index of the entry in the model. 277 * @param {number} index The original index of the entry in the model.
272 * @param {string} password The saved password. 278 * @param {string} password The saved password.
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 'showImportExportButton', 340 'showImportExportButton',
335 'showPassword', 341 'showPassword',
336 ]); 342 ]);
337 343
338 // Export 344 // Export
339 return { 345 return {
340 PasswordManager: PasswordManager 346 PasswordManager: PasswordManager
341 }; 347 };
342 348
343 }); 349 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698