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

Unified Diff: chrome/browser/resources/settings/passwords_and_forms_page/autofill_section.js

Issue 2946563002: Run clang-format on .js files in c/b/r/settings (Closed)
Patch Set: dschuyler@ review Created 3 years, 6 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/settings/passwords_and_forms_page/autofill_section.js
diff --git a/chrome/browser/resources/settings/passwords_and_forms_page/autofill_section.js b/chrome/browser/resources/settings/passwords_and_forms_page/autofill_section.js
index 3cfa7102bf39ec613367cfb284658088b593d54f..0a7dff75c10fa0789dc77cf144e69e86a8d70264 100644
--- a/chrome/browser/resources/settings/passwords_and_forms_page/autofill_section.js
+++ b/chrome/browser/resources/settings/passwords_and_forms_page/autofill_section.js
@@ -146,325 +146,325 @@ AutofillManagerImpl.prototype = {
};
(function() {
- 'use strict';
-
- Polymer({
- is: 'settings-autofill-section',
-
- behaviors: [I18nBehavior],
-
- properties: {
- /**
- * An array of saved addresses.
- * @type {!Array<!AutofillManager.AddressEntry>}
- */
- addresses: Array,
-
- /**
- * The model for any address related action menus or dialogs.
- * @private {?chrome.autofillPrivate.AddressEntry}
- */
- activeAddress: Object,
-
- /** @private */
- showAddressDialog_: Boolean,
-
- /**
- * An array of saved credit cards.
- * @type {!Array<!AutofillManager.CreditCardEntry>}
- */
- creditCards: Array,
-
- /**
- * The model for any credit card related action menus or dialogs.
- * @private {?chrome.autofillPrivate.CreditCardEntry}
- */
- activeCreditCard: Object,
-
- /** @private */
- showCreditCardDialog_: Boolean,
- },
-
- listeners: {
- 'save-address': 'saveAddress_',
- 'save-credit-card': 'saveCreditCard_',
- },
+'use strict';
- /**
- * The element to return focus to, when the currently active dialog is
- * closed.
- * @private {?HTMLElement}
- */
- activeDialogAnchor_: null,
+Polymer({
+ is: 'settings-autofill-section',
- /**
- * @type {AutofillManager}
- * @private
- */
- autofillManager_: null,
+ behaviors: [I18nBehavior],
+ properties: {
/**
- * @type {?function(!Array<!AutofillManager.AddressEntry>)}
- * @private
+ * An array of saved addresses.
+ * @type {!Array<!AutofillManager.AddressEntry>}
*/
- setAddressesListener_: null,
+ addresses: Array,
/**
- * @type {?function(!Array<!AutofillManager.CreditCardEntry>)}
- * @private
+ * The model for any address related action menus or dialogs.
+ * @private {?chrome.autofillPrivate.AddressEntry}
*/
- setCreditCardsListener_: null,
-
- /** @override */
- attached: function() {
- // Create listener functions.
- /** @type {function(!Array<!AutofillManager.AddressEntry>)} */
- var setAddressesListener = function(list) {
- this.addresses = list;
- }.bind(this);
-
- /** @type {function(!Array<!AutofillManager.CreditCardEntry>)} */
- var setCreditCardsListener = function(list) {
- this.creditCards = list;
- }.bind(this);
-
- // Remember the bound reference in order to detach.
- this.setAddressesListener_ = setAddressesListener;
- this.setCreditCardsListener_ = setCreditCardsListener;
-
- // Set the managers. These can be overridden by tests.
- this.autofillManager_ = AutofillManagerImpl.getInstance();
-
- // Request initial data.
- this.autofillManager_.getAddressList(setAddressesListener);
- this.autofillManager_.getCreditCardList(setCreditCardsListener);
-
- // Listen for changes.
- this.autofillManager_.addAddressListChangedListener(setAddressesListener);
- this.autofillManager_.addCreditCardListChangedListener(
- setCreditCardsListener);
- },
-
- /** @override */
- detached: function() {
- this.autofillManager_.removeAddressListChangedListener(
- /** @type {function(!Array<!AutofillManager.AddressEntry>)} */(
- this.setAddressesListener_));
- this.autofillManager_.removeCreditCardListChangedListener(
- /** @type {function(!Array<!AutofillManager.CreditCardEntry>)} */(
- this.setCreditCardsListener_));
- },
+ activeAddress: Object,
+
+ /** @private */
+ showAddressDialog_: Boolean,
/**
- * Formats the expiration date so it's displayed as MM/YYYY.
- * @param {!chrome.autofillPrivate.CreditCardEntry} item
- * @return {string}
- * @private
+ * An array of saved credit cards.
+ * @type {!Array<!AutofillManager.CreditCardEntry>}
*/
- expiration_: function(item) {
- return item.expirationMonth + '/' + item.expirationYear;
- },
+ creditCards: Array,
/**
- * Open the address action menu.
- * @param {!Event} e The polymer event.
- * @private
+ * The model for any credit card related action menus or dialogs.
+ * @private {?chrome.autofillPrivate.CreditCardEntry}
*/
- onAddressMenuTap_: function(e) {
- var menuEvent = /** @type {!{model: !{item: !Object}}} */(e);
+ activeCreditCard: Object,
- /* TODO(scottchen): drop the [dataHost][dataHost] once this bug is fixed:
- https://github.com/Polymer/polymer/issues/2574 */
- var item = menuEvent.model['dataHost']['dataHost'].item;
+ /** @private */
+ showCreditCardDialog_: Boolean,
+ },
- // Copy item so dialog won't update model on cancel.
- this.activeAddress = /** @type {!chrome.autofillPrivate.AddressEntry} */(
- Object.assign({}, item));
+ listeners: {
+ 'save-address': 'saveAddress_',
+ 'save-credit-card': 'saveCreditCard_',
+ },
- var dotsButton = /** @type {!HTMLElement} */ (Polymer.dom(e).localTarget);
- /** @type {!CrActionMenuElement} */ (
- this.$.addressSharedMenu).showAt(dotsButton);
- this.activeDialogAnchor_ = dotsButton;
- },
+ /**
+ * The element to return focus to, when the currently active dialog is
+ * closed.
+ * @private {?HTMLElement}
+ */
+ activeDialogAnchor_: null,
- /**
- * Handles tapping on the "Add address" button.
- * @param {!Event} e The polymer event.
- * @private
- */
- onAddAddressTap_: function(e) {
- e.preventDefault();
- this.activeAddress = {};
- this.showAddressDialog_ = true;
- this.activeDialogAnchor_ = this.$.addAddress;
- },
+ /**
+ * @type {AutofillManager}
+ * @private
+ */
+ autofillManager_: null,
- /** @private */
- onAddressDialogClosed_: function() {
- this.showAddressDialog_ = false;
- cr.ui.focusWithoutInk(assert(this.activeDialogAnchor_));
- this.activeDialogAnchor_ = null;
- },
+ /**
+ * @type {?function(!Array<!AutofillManager.AddressEntry>)}
+ * @private
+ */
+ setAddressesListener_: null,
- /**
- * Handles tapping on the "Edit" address button.
- * @param {!Event} e The polymer event.
- * @private
- */
- onMenuEditAddressTap_: function(e) {
- e.preventDefault();
- this.showAddressDialog_ = true;
- this.$.addressSharedMenu.close();
- },
+ /**
+ * @type {?function(!Array<!AutofillManager.CreditCardEntry>)}
+ * @private
+ */
+ setCreditCardsListener_: null,
- /** @private */
- onRemoteEditAddressTap_: function() {
- window.open(this.i18n('manageAddressesUrl'));
- },
+ /** @override */
+ attached: function() {
+ // Create listener functions.
+ /** @type {function(!Array<!AutofillManager.AddressEntry>)} */
+ var setAddressesListener = function(list) {
+ this.addresses = list;
+ }.bind(this);
+
+ /** @type {function(!Array<!AutofillManager.CreditCardEntry>)} */
+ var setCreditCardsListener = function(list) {
+ this.creditCards = list;
+ }.bind(this);
+
+ // Remember the bound reference in order to detach.
+ this.setAddressesListener_ = setAddressesListener;
+ this.setCreditCardsListener_ = setCreditCardsListener;
+
+ // Set the managers. These can be overridden by tests.
+ this.autofillManager_ = AutofillManagerImpl.getInstance();
+
+ // Request initial data.
+ this.autofillManager_.getAddressList(setAddressesListener);
+ this.autofillManager_.getCreditCardList(setCreditCardsListener);
+
+ // Listen for changes.
+ this.autofillManager_.addAddressListChangedListener(setAddressesListener);
+ this.autofillManager_.addCreditCardListChangedListener(
+ setCreditCardsListener);
+ },
- /**
- * Handles tapping on the "Remove" address button.
- * @private
- */
- onMenuRemoveAddressTap_: function() {
- this.autofillManager_.removeAddress(
- /** @type {string} */(this.activeAddress.guid));
- this.$.addressSharedMenu.close();
- },
+ /** @override */
+ detached: function() {
+ this.autofillManager_.removeAddressListChangedListener(
+ /** @type {function(!Array<!AutofillManager.AddressEntry>)} */ (
+ this.setAddressesListener_));
+ this.autofillManager_.removeCreditCardListChangedListener(
+ /** @type {function(!Array<!AutofillManager.CreditCardEntry>)} */ (
+ this.setCreditCardsListener_));
+ },
- /**
- * Opens the credit card action menu.
- * @param {!Event} e The polymer event.
- * @private
- */
- onCreditCardMenuTap_: function(e) {
- var menuEvent = /** @type {!{model: !{item: !Object}}} */(e);
+ /**
+ * Formats the expiration date so it's displayed as MM/YYYY.
+ * @param {!chrome.autofillPrivate.CreditCardEntry} item
+ * @return {string}
+ * @private
+ */
+ expiration_: function(item) {
+ return item.expirationMonth + '/' + item.expirationYear;
+ },
- /* TODO(scottchen): drop the [dataHost][dataHost] once this bug is fixed:
- https://github.com/Polymer/polymer/issues/2574 */
- var item = menuEvent.model['dataHost']['dataHost'].item;
+ /**
+ * Open the address action menu.
+ * @param {!Event} e The polymer event.
+ * @private
+ */
+ onAddressMenuTap_: function(e) {
+ var menuEvent = /** @type {!{model: !{item: !Object}}} */ (e);
- // Copy item so dialog won't update model on cancel.
- this.activeCreditCard =
- /** @type {!chrome.autofillPrivate.CreditCardEntry} */(
- Object.assign({}, item));
+ /* TODO(scottchen): drop the [dataHost][dataHost] once this bug is fixed:
+ https://github.com/Polymer/polymer/issues/2574 */
+ var item = menuEvent.model['dataHost']['dataHost'].item;
- var dotsButton = /** @type {!HTMLElement} */ (Polymer.dom(e).localTarget);
- /** @type {!CrActionMenuElement} */ (
- this.$.creditCardSharedMenu).showAt(dotsButton);
- this.activeDialogAnchor_ = dotsButton;
- },
+ // Copy item so dialog won't update model on cancel.
+ this.activeAddress = /** @type {!chrome.autofillPrivate.AddressEntry} */ (
+ Object.assign({}, item));
- /**
- * Handles tapping on the "Add credit card" button.
- * @param {!Event} e
- * @private
- */
- onAddCreditCardTap_: function(e) {
- e.preventDefault();
- var date = new Date(); // Default to current month/year.
- var expirationMonth = date.getMonth() + 1; // Months are 0 based.
- this.activeCreditCard = {
- expirationMonth: expirationMonth.toString(),
- expirationYear: date.getFullYear().toString(),
- };
- this.showCreditCardDialog_ = true;
- this.activeDialogAnchor_ = this.$.addCreditCard;
- },
+ var dotsButton = /** @type {!HTMLElement} */ (Polymer.dom(e).localTarget);
+ /** @type {!CrActionMenuElement} */ (this.$.addressSharedMenu)
+ .showAt(dotsButton);
+ this.activeDialogAnchor_ = dotsButton;
+ },
- /** @private */
- onCreditCardDialogClosed_: function() {
- this.showCreditCardDialog_ = false;
- cr.ui.focusWithoutInk(assert(this.activeDialogAnchor_));
- this.activeDialogAnchor_ = null;
- },
+ /**
+ * Handles tapping on the "Add address" button.
+ * @param {!Event} e The polymer event.
+ * @private
+ */
+ onAddAddressTap_: function(e) {
+ e.preventDefault();
+ this.activeAddress = {};
+ this.showAddressDialog_ = true;
+ this.activeDialogAnchor_ = this.$.addAddress;
+ },
- /**
- * Handles tapping on the "Edit" credit card button.
- * @param {!Event} e The polymer event.
- * @private
- */
- onMenuEditCreditCardTap_: function(e) {
- e.preventDefault();
+ /** @private */
+ onAddressDialogClosed_: function() {
+ this.showAddressDialog_ = false;
+ cr.ui.focusWithoutInk(assert(this.activeDialogAnchor_));
+ this.activeDialogAnchor_ = null;
+ },
- if (this.activeCreditCard.metadata.isLocal)
- this.showCreditCardDialog_ = true;
- else
- this.onRemoteEditCreditCardTap_();
+ /**
+ * Handles tapping on the "Edit" address button.
+ * @param {!Event} e The polymer event.
+ * @private
+ */
+ onMenuEditAddressTap_: function(e) {
+ e.preventDefault();
+ this.showAddressDialog_ = true;
+ this.$.addressSharedMenu.close();
+ },
- this.$.creditCardSharedMenu.close();
- },
+ /** @private */
+ onRemoteEditAddressTap_: function() {
+ window.open(this.i18n('manageAddressesUrl'));
+ },
- /** @private */
- onRemoteEditCreditCardTap_: function() {
- window.open(this.i18n('manageCreditCardsUrl'));
- },
+ /**
+ * Handles tapping on the "Remove" address button.
+ * @private
+ */
+ onMenuRemoveAddressTap_: function() {
+ this.autofillManager_.removeAddress(
+ /** @type {string} */ (this.activeAddress.guid));
+ this.$.addressSharedMenu.close();
+ },
- /**
- * Handles tapping on the "Remove" credit card button.
- * @private
- */
- onMenuRemoveCreditCardTap_: function() {
- this.autofillManager_.removeCreditCard(
- /** @type {string} */(this.activeCreditCard.guid));
- this.$.creditCardSharedMenu.close();
- },
+ /**
+ * Opens the credit card action menu.
+ * @param {!Event} e The polymer event.
+ * @private
+ */
+ onCreditCardMenuTap_: function(e) {
+ var menuEvent = /** @type {!{model: !{item: !Object}}} */ (e);
+
+ /* TODO(scottchen): drop the [dataHost][dataHost] once this bug is fixed:
+ https://github.com/Polymer/polymer/issues/2574 */
+ var item = menuEvent.model['dataHost']['dataHost'].item;
+
+ // Copy item so dialog won't update model on cancel.
+ this.activeCreditCard =
+ /** @type {!chrome.autofillPrivate.CreditCardEntry} */ (
+ Object.assign({}, item));
+
+ var dotsButton = /** @type {!HTMLElement} */ (Polymer.dom(e).localTarget);
+ /** @type {!CrActionMenuElement} */ (this.$.creditCardSharedMenu)
+ .showAt(dotsButton);
+ this.activeDialogAnchor_ = dotsButton;
+ },
- /**
- * Handles tapping on the "Clear copy" button for cached credit cards.
- * @private
- */
- onMenuClearCreditCardTap_: function() {
- this.autofillManager_.clearCachedCreditCard(
- /** @type {string} */(this.activeCreditCard.guid));
- this.$.creditCardSharedMenu.close();
- },
+ /**
+ * Handles tapping on the "Add credit card" button.
+ * @param {!Event} e
+ * @private
+ */
+ onAddCreditCardTap_: function(e) {
+ e.preventDefault();
+ var date = new Date(); // Default to current month/year.
+ var expirationMonth = date.getMonth() + 1; // Months are 0 based.
+ this.activeCreditCard = {
+ expirationMonth: expirationMonth.toString(),
+ expirationYear: date.getFullYear().toString(),
+ };
+ this.showCreditCardDialog_ = true;
+ this.activeDialogAnchor_ = this.$.addCreditCard;
+ },
- /**
- * The 3-dot menu should not be shown if the card is entirely remote.
- * @param {!chrome.autofillPrivate.AutofillMetadata} metadata
- * @return {boolean}
- * @private
- */
- showDots_: function(metadata) {
- return !!(metadata.isLocal || metadata.isCached);
- },
+ /** @private */
+ onCreditCardDialogClosed_: function() {
+ this.showCreditCardDialog_ = false;
+ cr.ui.focusWithoutInk(assert(this.activeDialogAnchor_));
+ this.activeDialogAnchor_ = null;
+ },
- /**
- * Returns true if the list exists and has items.
- * @param {Array<Object>} list
- * @return {boolean}
- * @private
- */
- hasSome_: function(list) {
- return !!(list && list.length);
- },
+ /**
+ * Handles tapping on the "Edit" credit card button.
+ * @param {!Event} e The polymer event.
+ * @private
+ */
+ onMenuEditCreditCardTap_: function(e) {
+ e.preventDefault();
- /**
- * Listens for the save-address event, and calls the private API.
- * @param {!Event} event
- * @private
- */
- saveAddress_: function(event) {
- this.autofillManager_.saveAddress(event.detail);
- },
+ if (this.activeCreditCard.metadata.isLocal)
+ this.showCreditCardDialog_ = true;
+ else
+ this.onRemoteEditCreditCardTap_();
- /**
- * Listens for the save-credit-card event, and calls the private API.
- * @param {!Event} event
- * @private
- */
- saveCreditCard_: function(event) {
- this.autofillManager_.saveCreditCard(event.detail);
- },
+ this.$.creditCardSharedMenu.close();
+ },
- /**
- * @private
- * @param {boolean} toggleValue
- * @return {string}
- */
- getOnOffLabel_: function(toggleValue) {
- return toggleValue ? this.i18n('toggleOn') : this.i18n('toggleOff');
- }
- });
+ /** @private */
+ onRemoteEditCreditCardTap_: function() {
+ window.open(this.i18n('manageCreditCardsUrl'));
+ },
+
+ /**
+ * Handles tapping on the "Remove" credit card button.
+ * @private
+ */
+ onMenuRemoveCreditCardTap_: function() {
+ this.autofillManager_.removeCreditCard(
+ /** @type {string} */ (this.activeCreditCard.guid));
+ this.$.creditCardSharedMenu.close();
+ },
+
+ /**
+ * Handles tapping on the "Clear copy" button for cached credit cards.
+ * @private
+ */
+ onMenuClearCreditCardTap_: function() {
+ this.autofillManager_.clearCachedCreditCard(
+ /** @type {string} */ (this.activeCreditCard.guid));
+ this.$.creditCardSharedMenu.close();
+ },
+
+ /**
+ * The 3-dot menu should not be shown if the card is entirely remote.
+ * @param {!chrome.autofillPrivate.AutofillMetadata} metadata
+ * @return {boolean}
+ * @private
+ */
+ showDots_: function(metadata) {
+ return !!(metadata.isLocal || metadata.isCached);
+ },
+
+ /**
+ * Returns true if the list exists and has items.
+ * @param {Array<Object>} list
+ * @return {boolean}
+ * @private
+ */
+ hasSome_: function(list) {
+ return !!(list && list.length);
+ },
+
+ /**
+ * Listens for the save-address event, and calls the private API.
+ * @param {!Event} event
+ * @private
+ */
+ saveAddress_: function(event) {
+ this.autofillManager_.saveAddress(event.detail);
+ },
+
+ /**
+ * Listens for the save-credit-card event, and calls the private API.
+ * @param {!Event} event
+ * @private
+ */
+ saveCreditCard_: function(event) {
+ this.autofillManager_.saveCreditCard(event.detail);
+ },
+
+ /**
+ * @private
+ * @param {boolean} toggleValue
+ * @return {string}
+ */
+ getOnOffLabel_: function(toggleValue) {
+ return toggleValue ? this.i18n('toggleOn') : this.i18n('toggleOff');
+ }
+});
})();

Powered by Google App Engine
This is Rietveld 408576698