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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
162 if (entry[0].toLowerCase().indexOf(query.toLowerCase()) >= 0 || | 162 if (entry[0].toLowerCase().indexOf(query.toLowerCase()) >= 0 || |
163 entry[1].toLowerCase().indexOf(query.toLowerCase()) >= 0) { | 163 entry[1].toLowerCase().indexOf(query.toLowerCase()) >= 0) { |
164 // Keep the original index so we can delete correctly. See also | 164 // Keep the original index so we can delete correctly. See also |
165 // deleteItemAtIndex() in password_manager_list.js that uses this. | 165 // deleteItemAtIndex() in password_manager_list.js that uses this. |
166 entry[3] = index; | 166 entry[3] = index; |
167 return true; | 167 return true; |
168 } | 168 } |
169 return false; | 169 return false; |
170 }; | 170 }; |
171 entries = entries.filter(filter); | 171 entries = entries.filter(filter); |
172 } else { | |
173 // Adds the Add New Entry row. | |
174 entries.push(null); | |
172 } | 175 } |
173 this.savedPasswordsList_.dataModel = new ArrayDataModel(entries); | 176 this.savedPasswordsList_.dataModel = new ArrayDataModel(entries); |
174 this.updateListVisibility_(this.savedPasswordsList_); | 177 this.updateListVisibility_(this.savedPasswordsList_); |
175 }, | 178 }, |
176 | 179 |
177 /** | 180 /** |
178 * Updates the data model for the password exceptions list with the values | 181 * Updates the data model for the password exceptions list with the values |
179 * from |entries|. | 182 * from |entries|. |
180 * @param {Array} entries The list of password exception data. | 183 * @param {Array} entries The list of password exception data. |
181 */ | 184 */ |
(...skipping 19 matching lines...) Expand all Loading... | |
201 index = i; | 204 index = i; |
202 break; | 205 break; |
203 } | 206 } |
204 } | 207 } |
205 } | 208 } |
206 | 209 |
207 // Reveal the password in the UI. | 210 // Reveal the password in the UI. |
208 var item = this.savedPasswordsList_.getListItemByIndex(index); | 211 var item = this.savedPasswordsList_.getListItemByIndex(index); |
209 item.showPassword(password); | 212 item.showPassword(password); |
210 }, | 213 }, |
214 | |
215 /** | |
216 * Forwards the validity of the origin to the Add New Entry row. | |
217 * @param {string} url The origin. | |
218 * @param {boolean} valid The validity of the origin for adding. | |
Dan Beam
2014/08/26 17:39:05
@private
jaekyeom
2014/08/27 12:28:52
Done.
| |
219 */ | |
220 originValidityCheckComplete_: function(url, valid) { | |
221 // There is no Add New Entry row when a filter is active. | |
222 if (this.lastQuery_) | |
223 return; | |
224 var model = this.savedPasswordsList_.dataModel; | |
Dan Beam
2014/08/26 17:39:05
what if model.length == 0?
jaekyeom
2014/08/27 12:28:53
Done.
I modified the condition a bit and added a c
| |
225 var addRowItem = this.savedPasswordsList_.getListItemByIndex( | |
226 model.length - 1); | |
227 addRowItem.originValidityCheckComplete(url, valid); | |
228 }, | |
211 }; | 229 }; |
212 | 230 |
213 /** | 231 /** |
232 * Requests the browser to check the validity of the origin being edited by | |
233 * the user in the Add New Entry row. | |
234 * @param {string} url The origin being edited. | |
235 */ | |
236 PasswordManager.checkOriginValidityForAdding = function(url) { | |
237 chrome.send('checkOriginValidityForAdding', [url]); | |
238 }; | |
239 | |
240 /** | |
241 * Adds a new password entry. | |
242 * @param {string} url The origin. | |
243 * @param {string} username The username value. | |
244 * @param {string} password The password value. | |
245 */ | |
246 PasswordManager.addPassword = function(url, username, password) { | |
247 chrome.send('addPassword', [url, username, password]); | |
248 }; | |
249 | |
250 /** | |
251 * Updates the password value of an entry. | |
252 * @param {number} rowIndex The row to update. | |
253 * @param {string} newPassword The new password value. | |
254 */ | |
255 PasswordManager.updatePassword = function(rowIndex, newPassword) { | |
256 chrome.send('updatePassword', [String(rowIndex), newPassword]); | |
257 }; | |
258 | |
259 /** | |
214 * Removes a saved password. | 260 * Removes a saved password. |
215 * @param {number} rowIndex indicating the row to remove. | 261 * @param {number} rowIndex indicating the row to remove. |
216 */ | 262 */ |
217 PasswordManager.removeSavedPassword = function(rowIndex) { | 263 PasswordManager.removeSavedPassword = function(rowIndex) { |
218 chrome.send('removeSavedPassword', [String(rowIndex)]); | 264 chrome.send('removeSavedPassword', [String(rowIndex)]); |
219 }; | 265 }; |
220 | 266 |
221 /** | 267 /** |
222 * Removes a password exception. | 268 * Removes a password exception. |
223 * @param {number} rowIndex indicating the row to remove. | 269 * @param {number} rowIndex indicating the row to remove. |
224 */ | 270 */ |
225 PasswordManager.removePasswordException = function(rowIndex) { | 271 PasswordManager.removePasswordException = function(rowIndex) { |
226 chrome.send('removePasswordException', [String(rowIndex)]); | 272 chrome.send('removePasswordException', [String(rowIndex)]); |
227 }; | 273 }; |
228 | 274 |
229 PasswordManager.requestShowPassword = function(index) { | 275 PasswordManager.requestShowPassword = function(index) { |
230 chrome.send('requestShowPassword', [index]); | 276 chrome.send('requestShowPassword', [index]); |
231 }; | 277 }; |
232 | 278 |
233 // Forward public APIs to private implementations on the singleton instance. | 279 // Forward public APIs to private implementations on the singleton instance. |
234 [ | 280 [ |
235 'setSavedPasswordsList', | 281 'setSavedPasswordsList', |
236 'setPasswordExceptionsList', | 282 'setPasswordExceptionsList', |
237 'showPassword' | 283 'showPassword', |
284 'originValidityCheckComplete' | |
238 ].forEach(function(name) { | 285 ].forEach(function(name) { |
239 PasswordManager[name] = function() { | 286 PasswordManager[name] = function() { |
240 var instance = PasswordManager.getInstance(); | 287 var instance = PasswordManager.getInstance(); |
241 return instance[name + '_'].apply(instance, arguments); | 288 return instance[name + '_'].apply(instance, arguments); |
242 }; | 289 }; |
243 }); | 290 }); |
244 | 291 |
245 // Export | 292 // Export |
246 return { | 293 return { |
247 PasswordManager: PasswordManager | 294 PasswordManager: PasswordManager |
248 }; | 295 }; |
249 | 296 |
250 }); | 297 }); |
OLD | NEW |