Chromium Code Reviews| 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 'settings-passwords-and-forms-page' is the settings page | 6 * @fileoverview 'settings-passwords-and-forms-page' is the settings page |
| 7 * for passwords and auto fill. | 7 * for passwords and auto fill. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 /** | 10 /** |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 109 * @param {function(!Array<!AutofillManager.AddressEntry>):void} listener | 109 * @param {function(!Array<!AutofillManager.AddressEntry>):void} listener |
| 110 */ | 110 */ |
| 111 removeAddressListChangedListener: assertNotReached, | 111 removeAddressListChangedListener: assertNotReached, |
| 112 | 112 |
| 113 /** | 113 /** |
| 114 * Request the list of addresses. | 114 * Request the list of addresses. |
| 115 * @param {function(!Array<!AutofillManager.AddressEntry>):void} callback | 115 * @param {function(!Array<!AutofillManager.AddressEntry>):void} callback |
| 116 */ | 116 */ |
| 117 getAddressList: assertNotReached, | 117 getAddressList: assertNotReached, |
| 118 | 118 |
| 119 /** @param {!AutofillManager.AddressEntry} address The address to remove. */ | 119 /** @param {string} guid The guid of the address to remove. */ |
| 120 removeAddress: assertNotReached, | 120 removeAddress: assertNotReached, |
| 121 | 121 |
| 122 /** | 122 /** |
| 123 * Add an observer to the list of credit cards. | 123 * Add an observer to the list of credit cards. |
| 124 * @param {function(!Array<!AutofillManager.CreditCardEntry>):void} listener | 124 * @param {function(!Array<!AutofillManager.CreditCardEntry>):void} listener |
| 125 */ | 125 */ |
| 126 addCreditCardListChangedListener: assertNotReached, | 126 addCreditCardListChangedListener: assertNotReached, |
| 127 | 127 |
| 128 /** | 128 /** |
| 129 * Remove an observer from the list of credit cards. | 129 * Remove an observer from the list of credit cards. |
| 130 * @param {function(!Array<!AutofillManager.CreditCardEntry>):void} listener | 130 * @param {function(!Array<!AutofillManager.CreditCardEntry>):void} listener |
| 131 */ | 131 */ |
| 132 removeCreditCardListChangedListener: assertNotReached, | 132 removeCreditCardListChangedListener: assertNotReached, |
| 133 | 133 |
| 134 /** | 134 /** |
| 135 * Request the list of credit cards. | 135 * Request the list of credit cards. |
| 136 * @param {function(!Array<!AutofillManager.CreditCardEntry>):void} callback | 136 * @param {function(!Array<!AutofillManager.CreditCardEntry>):void} callback |
| 137 */ | 137 */ |
| 138 getCreditCardList: assertNotReached, | 138 getCreditCardList: assertNotReached, |
| 139 | 139 |
| 140 /** | 140 /** @param {string} guid The GUID of the credit card to remove. */ |
| 141 * @param {!AutofillManager.CreditCardEntry} creditCard The credit card to | |
| 142 * remove. | |
| 143 */ | |
| 144 removeCreditCard: assertNotReached, | 141 removeCreditCard: assertNotReached, |
| 145 | 142 |
| 143 /** @param {string} guid The GUID to credit card to remove from the cache. */ | |
| 144 clearCachedCreditCard: assertNotReached, | |
| 145 | |
| 146 /** | 146 /** |
| 147 * Saves the given credit card. | 147 * Saves the given credit card. |
| 148 * @param {!AutofillManager.CreditCardEntry} creditCard | 148 * @param {!AutofillManager.CreditCardEntry} creditCard |
| 149 */ | 149 */ |
| 150 saveCreditCard: assertNotReached, | 150 saveCreditCard: assertNotReached, |
| 151 }; | 151 }; |
| 152 | 152 |
| 153 /** | 153 /** |
| 154 * Implementation that accesses the private API. | 154 * Implementation that accesses the private API. |
| 155 * @implements {PasswordManager} | 155 * @implements {PasswordManager} |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 240 removeAddressListChangedListener: function(listener) { | 240 removeAddressListChangedListener: function(listener) { |
| 241 chrome.autofillPrivate.onAddressListChanged.removeListener(listener); | 241 chrome.autofillPrivate.onAddressListChanged.removeListener(listener); |
| 242 }, | 242 }, |
| 243 | 243 |
| 244 /** @override */ | 244 /** @override */ |
| 245 getAddressList: function(callback) { | 245 getAddressList: function(callback) { |
| 246 chrome.autofillPrivate.getAddressList(callback); | 246 chrome.autofillPrivate.getAddressList(callback); |
| 247 }, | 247 }, |
| 248 | 248 |
| 249 /** @override */ | 249 /** @override */ |
| 250 removeAddress: function(address) { | 250 removeAddress: function(guid) { |
| 251 chrome.autofillPrivate.removeEntry(/** @type {string} */(address.guid)); | 251 // GUID identifies an address: can't delete one if you don't know which |
|
tommycli
2016/06/27 22:31:28
The assert is pretty self explanatory. No need for
hcarmona
2016/06/27 22:42:13
👍
| |
| 252 // address. | |
| 253 assert(guid); | |
| 254 chrome.autofillPrivate.removeEntry(guid); | |
| 252 }, | 255 }, |
| 253 | 256 |
| 254 /** @override */ | 257 /** @override */ |
| 255 addCreditCardListChangedListener: function(listener) { | 258 addCreditCardListChangedListener: function(listener) { |
| 256 chrome.autofillPrivate.onCreditCardListChanged.addListener(listener); | 259 chrome.autofillPrivate.onCreditCardListChanged.addListener(listener); |
| 257 }, | 260 }, |
| 258 | 261 |
| 259 /** @override */ | 262 /** @override */ |
| 260 removeCreditCardListChangedListener: function(listener) { | 263 removeCreditCardListChangedListener: function(listener) { |
| 261 chrome.autofillPrivate.onCreditCardListChanged.removeListener(listener); | 264 chrome.autofillPrivate.onCreditCardListChanged.removeListener(listener); |
| 262 }, | 265 }, |
| 263 | 266 |
| 264 /** @override */ | 267 /** @override */ |
| 265 getCreditCardList: function(callback) { | 268 getCreditCardList: function(callback) { |
| 266 chrome.autofillPrivate.getCreditCardList(callback); | 269 chrome.autofillPrivate.getCreditCardList(callback); |
| 267 }, | 270 }, |
| 268 | 271 |
| 269 /** @override */ | 272 /** @override */ |
| 270 removeCreditCard: function(creditCard) { | 273 removeCreditCard: function(guid) { |
| 271 chrome.autofillPrivate.removeEntry(/** @type {string} */(creditCard.guid)); | 274 // GUID identifies a credit card: can't delete one if you don't know which |
| 275 // credit card. | |
| 276 assert(guid); | |
| 277 chrome.autofillPrivate.removeEntry(guid); | |
| 272 }, | 278 }, |
| 273 | 279 |
| 274 /** @override */ | 280 /** @override */ |
| 281 clearCachedCreditCard: function(guid) { | |
| 282 // GUID identifies a credit card: can't clear cache if you don't know which | |
| 283 // credit card. | |
| 284 assert(guid); | |
| 285 chrome.autofillPrivate.maskCreditCard(guid); | |
| 286 }, | |
| 287 | |
| 288 /** @override */ | |
| 275 saveCreditCard: function(creditCard) { | 289 saveCreditCard: function(creditCard) { |
| 276 chrome.autofillPrivate.saveCreditCard(creditCard); | 290 chrome.autofillPrivate.saveCreditCard(creditCard); |
| 277 } | 291 } |
| 278 }; | 292 }; |
| 279 | 293 |
| 280 (function() { | 294 (function() { |
| 281 'use strict'; | 295 'use strict'; |
| 282 | 296 |
| 283 Polymer({ | 297 Polymer({ |
| 284 is: 'settings-passwords-and-forms-page', | 298 is: 'settings-passwords-and-forms-page', |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 319 addresses: Array, | 333 addresses: Array, |
| 320 | 334 |
| 321 /** | 335 /** |
| 322 * An array of saved addresses. | 336 * An array of saved addresses. |
| 323 * @type {!Array<!AutofillManager.CreditCardEntry>} | 337 * @type {!Array<!AutofillManager.CreditCardEntry>} |
| 324 */ | 338 */ |
| 325 creditCards: Array, | 339 creditCards: Array, |
| 326 }, | 340 }, |
| 327 | 341 |
| 328 listeners: { | 342 listeners: { |
| 343 'clear-credit-card': 'clearCreditCard_', | |
| 329 'remove-address': 'removeAddress_', | 344 'remove-address': 'removeAddress_', |
| 330 'remove-credit-card': 'removeCreditCard_', | 345 'remove-credit-card': 'removeCreditCard_', |
| 331 'remove-password-exception': 'removePasswordException_', | 346 'remove-password-exception': 'removePasswordException_', |
| 332 'remove-saved-password': 'removeSavedPassword_', | 347 'remove-saved-password': 'removeSavedPassword_', |
| 333 'save-credit-card': 'saveCreditCard_', | 348 'save-credit-card': 'saveCreditCard_', |
| 334 'show-password': 'showPassword_', | 349 'show-password': 'showPassword_', |
| 335 }, | 350 }, |
| 336 | 351 |
| 337 /** @type {?function(!Array<PasswordManager.PasswordUiEntry>):void} */ | 352 /** @type {?function(!Array<PasswordManager.PasswordUiEntry>):void} */ |
| 338 setSavedPasswordsListener_: null, | 353 setSavedPasswordsListener_: null, |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 415 removeSavedPassword_: function(event) { | 430 removeSavedPassword_: function(event) { |
| 416 this.passwordManager_.removeSavedPassword(event.detail); | 431 this.passwordManager_.removeSavedPassword(event.detail); |
| 417 }, | 432 }, |
| 418 | 433 |
| 419 /** | 434 /** |
| 420 * Listens for the remove-address event, and calls the private API. | 435 * Listens for the remove-address event, and calls the private API. |
| 421 * @param {!Event} event | 436 * @param {!Event} event |
| 422 * @private | 437 * @private |
| 423 */ | 438 */ |
| 424 removeAddress_: function(event) { | 439 removeAddress_: function(event) { |
| 425 this.autofillManager_.removeAddress(event.detail); | 440 this.autofillManager_.removeAddress(event.detail.guid); |
| 426 }, | 441 }, |
| 427 | 442 |
| 428 /** | 443 /** |
| 429 * Listens for the remove-credit-card event, and calls the private API. | 444 * Listens for the remove-credit-card event, and calls the private API. |
| 430 * @param {!Event} event | 445 * @param {!Event} event |
| 431 * @private | 446 * @private |
| 432 */ | 447 */ |
| 433 removeCreditCard_: function(event) { | 448 removeCreditCard_: function(event) { |
| 434 this.autofillManager_.removeCreditCard(event.detail); | 449 this.autofillManager_.removeCreditCard(event.detail.guid); |
| 435 }, | 450 }, |
| 436 | 451 |
| 437 /** | 452 /** |
| 453 * Listens for the clear-credit-card event, and calls the private API. | |
| 454 * @param {!Event} event | |
| 455 * @private | |
| 456 */ | |
| 457 clearCreditCard_: function(event) { | |
| 458 this.autofillManager_.clearCachedCreditCard(event.detail.guid); | |
| 459 }, | |
| 460 | |
| 461 /** | |
| 438 * Shows the manage autofill sub page. | 462 * Shows the manage autofill sub page. |
| 439 * @param {!Event} event | 463 * @param {!Event} event |
| 440 * @private | 464 * @private |
| 441 */ | 465 */ |
| 442 onAutofillTap_: function(event) { | 466 onAutofillTap_: function(event) { |
| 443 // Ignore clicking on the toggle button and verify autofill is enabled. | 467 // Ignore clicking on the toggle button and verify autofill is enabled. |
| 444 if (Polymer.dom(event).localTarget != this.$.autofillToggle && | 468 if (Polymer.dom(event).localTarget != this.$.autofillToggle && |
| 445 this.getPref('autofill.enabled').value) { | 469 this.getPref('autofill.enabled').value) { |
| 446 this.$.pages.setSubpageChain(['manage-autofill']); | 470 this.$.pages.setSubpageChain(['manage-autofill']); |
| 447 } | 471 } |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 475 * @param {!Event} event | 499 * @param {!Event} event |
| 476 * @private | 500 * @private |
| 477 */ | 501 */ |
| 478 showPassword_: function(event) { | 502 showPassword_: function(event) { |
| 479 this.passwordManager_.getPlaintextPassword(event.detail, function(e) { | 503 this.passwordManager_.getPlaintextPassword(event.detail, function(e) { |
| 480 this.$$('#passwordSection').setPassword(e.loginPair, e.plaintextPassword); | 504 this.$$('#passwordSection').setPassword(e.loginPair, e.plaintextPassword); |
| 481 }.bind(this)); | 505 }.bind(this)); |
| 482 }, | 506 }, |
| 483 }); | 507 }); |
| 484 })(); | 508 })(); |
| OLD | NEW |