| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 /** | 5 /** |
| 6 * @fileoverview 'passwords-section' is the collapsible section containing | 6 * @fileoverview 'passwords-section' is the collapsible section containing |
| 7 * the list of saved passwords as well as the list of sites that will never | 7 * the list of saved passwords as well as the list of sites that will never |
| 8 * save any passwords. | 8 * save any passwords. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 // Listen for changes. | 268 // Listen for changes. |
| 269 this.passwordManager_.addSavedPasswordListChangedListener( | 269 this.passwordManager_.addSavedPasswordListChangedListener( |
| 270 setSavedPasswordsListener); | 270 setSavedPasswordsListener); |
| 271 this.passwordManager_.addExceptionListChangedListener( | 271 this.passwordManager_.addExceptionListChangedListener( |
| 272 setPasswordExceptionsListener); | 272 setPasswordExceptionsListener); |
| 273 }, | 273 }, |
| 274 | 274 |
| 275 /** @override */ | 275 /** @override */ |
| 276 detached: function() { | 276 detached: function() { |
| 277 this.passwordManager_.removeSavedPasswordListChangedListener( | 277 this.passwordManager_.removeSavedPasswordListChangedListener( |
| 278 /** @type {function(!Array<PasswordManager.PasswordUiEntry>):void} */( | 278 /** @type {function(!Array<PasswordManager.PasswordUiEntry>):void} */ ( |
| 279 this.setSavedPasswordsListener_)); | 279 this.setSavedPasswordsListener_)); |
| 280 this.passwordManager_.removeExceptionListChangedListener( | 280 this.passwordManager_.removeExceptionListChangedListener( |
| 281 /** @type {function(!Array<PasswordManager.ExceptionEntry>):void} */( | 281 /** @type {function(!Array<PasswordManager.ExceptionEntry>):void} */ ( |
| 282 this.setPasswordExceptionsListener_)); | 282 this.setPasswordExceptionsListener_)); |
| 283 }, | 283 }, |
| 284 | 284 |
| 285 /** | 285 /** |
| 286 * Sets the password in the current password dialog if the loginPair matches. | 286 * Sets the password in the current password dialog if the loginPair matches. |
| 287 * @param {!chrome.passwordsPrivate.LoginPair} loginPair | 287 * @param {!chrome.passwordsPrivate.LoginPair} loginPair |
| 288 * @param {string} password | 288 * @param {string} password |
| 289 */ | 289 */ |
| 290 setPassword: function(loginPair, password) { | 290 setPassword: function(loginPair, password) { |
| 291 if (this.activePassword && | 291 if (this.activePassword && |
| 292 this.activePassword.loginPair.urls.origin == loginPair.urls.origin && | 292 this.activePassword.loginPair.urls.origin == loginPair.urls.origin && |
| 293 this.activePassword.loginPair.username == loginPair.username) { | 293 this.activePassword.loginPair.username == loginPair.username) { |
| 294 this.$$('password-edit-dialog').password = password; | 294 this.$$('password-edit-dialog').password = password; |
| 295 } | 295 } |
| 296 }, | 296 }, |
| 297 | 297 |
| 298 /** | 298 /** |
| 299 * Shows the edit password dialog. | 299 * Shows the edit password dialog. |
| 300 * @param {!Event} e | 300 * @param {!Event} e |
| 301 * @private | 301 * @private |
| 302 */ | 302 */ |
| 303 onMenuEditPasswordTap_: function(e) { | 303 onMenuEditPasswordTap_: function(e) { |
| 304 e.preventDefault(); | 304 e.preventDefault(); |
| 305 /** @type {CrActionMenuElement} */(this.$.menu).close(); | 305 /** @type {CrActionMenuElement} */ (this.$.menu).close(); |
| 306 this.showPasswordEditDialog_ = true; | 306 this.showPasswordEditDialog_ = true; |
| 307 }, | 307 }, |
| 308 | 308 |
| 309 /** @private */ | 309 /** @private */ |
| 310 onPasswordEditDialogClosed_: function() { | 310 onPasswordEditDialogClosed_: function() { |
| 311 this.showPasswordEditDialog_ = false; | 311 this.showPasswordEditDialog_ = false; |
| 312 cr.ui.focusWithoutInk(assert(this.activeDialogAnchor_)); | 312 cr.ui.focusWithoutInk(assert(this.activeDialogAnchor_)); |
| 313 this.activeDialogAnchor_ = null; | 313 this.activeDialogAnchor_ = null; |
| 314 }, | 314 }, |
| 315 | 315 |
| 316 /** | 316 /** |
| 317 * @param {!Array<!chrome.passwordsPrivate.PasswordUiEntry>} savedPasswords | 317 * @param {!Array<!chrome.passwordsPrivate.PasswordUiEntry>} savedPasswords |
| 318 * @param {string} filter | 318 * @param {string} filter |
| 319 * @return {!Array<!chrome.passwordsPrivate.PasswordUiEntry>} | 319 * @return {!Array<!chrome.passwordsPrivate.PasswordUiEntry>} |
| 320 * @private | 320 * @private |
| 321 */ | 321 */ |
| 322 getFilteredPasswords_: function(savedPasswords, filter) { | 322 getFilteredPasswords_: function(savedPasswords, filter) { |
| 323 if (!filter) | 323 if (!filter) |
| 324 return savedPasswords; | 324 return savedPasswords; |
| 325 | 325 |
| 326 return savedPasswords.filter(function(password) { | 326 return savedPasswords.filter(function(password) { |
| 327 return password.loginPair.urls.shown.includes(filter) || | 327 return password.loginPair.urls.shown.includes(filter) || |
| 328 password.loginPair.username.includes(filter); | 328 password.loginPair.username.includes(filter); |
| 329 }); | 329 }); |
| 330 }, | 330 }, |
| 331 | 331 |
| 332 /** | 332 /** |
| 333 * @param {string} filter | 333 * @param {string} filter |
| 334 * @return {function(!chrome.passwordsPrivate.ExceptionEntry): boolean} | 334 * @return {function(!chrome.passwordsPrivate.ExceptionEntry): boolean} |
| 335 * @private | 335 * @private |
| 336 */ | 336 */ |
| 337 passwordExceptionFilter_: function(filter) { | 337 passwordExceptionFilter_: function(filter) { |
| 338 return function(exception) { | 338 return function(exception) { |
| 339 return exception.urls.shown.includes(filter); | 339 return exception.urls.shown.includes(filter); |
| 340 }; | 340 }; |
| 341 }, | 341 }, |
| 342 | 342 |
| 343 /** | 343 /** |
| 344 * Fires an event that should delete the saved password. | 344 * Fires an event that should delete the saved password. |
| 345 * @private | 345 * @private |
| 346 */ | 346 */ |
| 347 onMenuRemovePasswordTap_: function() { | 347 onMenuRemovePasswordTap_: function() { |
| 348 this.passwordManager_.removeSavedPassword(this.activePassword.loginPair); | 348 this.passwordManager_.removeSavedPassword(this.activePassword.loginPair); |
| 349 /** @type {CrActionMenuElement} */(this.$.menu).close(); | 349 /** @type {CrActionMenuElement} */ (this.$.menu).close(); |
| 350 }, | 350 }, |
| 351 | 351 |
| 352 /** | 352 /** |
| 353 * Fires an event that should delete the password exception. | 353 * Fires an event that should delete the password exception. |
| 354 * @param {!ExceptionEntryEntryEvent} e The polymer event. | 354 * @param {!ExceptionEntryEntryEvent} e The polymer event. |
| 355 * @private | 355 * @private |
| 356 */ | 356 */ |
| 357 onRemoveExceptionButtonTap_: function(e) { | 357 onRemoveExceptionButtonTap_: function(e) { |
| 358 this.passwordManager_.removeException(e.model.item.urls.origin); | 358 this.passwordManager_.removeException(e.model.item.urls.origin); |
| 359 }, | 359 }, |
| 360 | 360 |
| 361 /** | 361 /** |
| 362 * Opens the password action menu. | 362 * Opens the password action menu. |
| 363 * @param {!Event} event | 363 * @param {!Event} event |
| 364 * @private | 364 * @private |
| 365 */ | 365 */ |
| 366 onPasswordMenuTap_: function(event) { | 366 onPasswordMenuTap_: function(event) { |
| 367 var menu = /** @type {!CrActionMenuElement} */(this.$.menu); | 367 var menu = /** @type {!CrActionMenuElement} */ (this.$.menu); |
| 368 var target = /** @type {!HTMLElement} */ (event.detail.target); | 368 var target = /** @type {!HTMLElement} */ (event.detail.target); |
| 369 | 369 |
| 370 this.activePassword = | 370 this.activePassword = |
| 371 /** @type {!chrome.passwordsPrivate.PasswordUiEntry} */ ( | 371 /** @type {!chrome.passwordsPrivate.PasswordUiEntry} */ ( |
| 372 event.detail.item); | 372 event.detail.item); |
| 373 menu.showAt(target); | 373 menu.showAt(target); |
| 374 this.activeDialogAnchor_ = target; | 374 this.activeDialogAnchor_ = target; |
| 375 }, | 375 }, |
| 376 | 376 |
| 377 /** | 377 /** |
| 378 * Returns true if the list exists and has items. | 378 * Returns true if the list exists and has items. |
| 379 * @param {Array<Object>} list | 379 * @param {Array<Object>} list |
| 380 * @return {boolean} | 380 * @return {boolean} |
| 381 * @private | 381 * @private |
| 382 */ | 382 */ |
| 383 hasSome_: function(list) { | 383 hasSome_: function(list) { |
| 384 return !!(list && list.length); | 384 return !!(list && list.length); |
| 385 }, | 385 }, |
| 386 | 386 |
| 387 /** | 387 /** |
| 388 * Listens for the show-password event, and calls the private API. | 388 * Listens for the show-password event, and calls the private API. |
| 389 * @param {!Event} event | 389 * @param {!Event} event |
| 390 * @private | 390 * @private |
| 391 */ | 391 */ |
| 392 showPassword_: function(event) { | 392 showPassword_: function(event) { |
| 393 this.passwordManager_.getPlaintextPassword( | 393 this.passwordManager_.getPlaintextPassword( |
| 394 /** @type {!PasswordManager.LoginPair} */(event.detail), | 394 /** @type {!PasswordManager.LoginPair} */ (event.detail), |
| 395 function(item) { | 395 function(item) { |
| 396 this.setPassword(item.loginPair, item.plaintextPassword); | 396 this.setPassword(item.loginPair, item.plaintextPassword); |
| 397 }.bind(this)); | 397 }.bind(this)); |
| 398 }, | 398 }, |
| 399 | 399 |
| 400 /** | 400 /** |
| 401 * @private | 401 * @private |
| 402 * @param {boolean} toggleValue | 402 * @param {boolean} toggleValue |
| 403 * @return {string} | 403 * @return {string} |
| 404 */ | 404 */ |
| 405 getOnOffLabel_: function(toggleValue) { | 405 getOnOffLabel_: function(toggleValue) { |
| 406 return toggleValue ? this.i18n('toggleOn') : this.i18n('toggleOff'); | 406 return toggleValue ? this.i18n('toggleOn') : this.i18n('toggleOff'); |
| 407 } | 407 } |
| 408 }); | 408 }); |
| 409 })(); | 409 })(); |
| OLD | NEW |