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

Side by Side Diff: chrome/browser/resources/settings/passwords_and_forms_page/autofill_section.js

Issue 2965643004: MD Settings: Convert remaining classes to ES6 syntax. (Closed)
Patch Set: Fix Created 3 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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-autofill-section' is the section containing saved 6 * @fileoverview 'settings-autofill-section' is the section containing saved
7 * addresses and credit cards for use in autofill. 7 * addresses and credit cards for use in autofill.
8 */ 8 */
9 9
10 /** 10 /**
11 * Interface for all callbacks to the autofill API. 11 * Interface for all callbacks to the autofill API.
12 * @interface 12 * @interface
13 */ 13 */
14 function AutofillManager() {} 14 class AutofillManager {
15 /**
16 * Add an observer to the list of addresses.
17 * @param {function(!Array<!AutofillManager.AddressEntry>):void} listener
18 */
19 addAddressListChangedListener(listener) {}
20
21 /**
22 * Remove an observer from the list of addresses.
23 * @param {function(!Array<!AutofillManager.AddressEntry>):void} listener
24 */
25 removeAddressListChangedListener(listener) {}
26
27 /**
28 * Request the list of addresses.
29 * @param {function(!Array<!AutofillManager.AddressEntry>):void} callback
30 */
31 getAddressList(callback) {}
32
33 /**
34 * Saves the given address.
35 * @param {!AutofillManager.AddressEntry} address
36 */
37 saveAddress(address) {}
38
39 /** @param {string} guid The guid of the address to remove. */
40 removeAddress(guid) {}
41
42 /**
43 * Add an observer to the list of credit cards.
44 * @param {function(!Array<!AutofillManager.CreditCardEntry>):void} listener
45 */
46 addCreditCardListChangedListener(listener) {}
47
48 /**
49 * Remove an observer from the list of credit cards.
50 * @param {function(!Array<!AutofillManager.CreditCardEntry>):void} listener
51 */
52 removeCreditCardListChangedListener(listener) {}
53
54 /**
55 * Request the list of credit cards.
56 * @param {function(!Array<!AutofillManager.CreditCardEntry>):void} callback
57 */
58 getCreditCardList(callback) {}
59
60 /** @param {string} guid The GUID of the credit card to remove. */
61 removeCreditCard(guid) {}
62
63 /** @param {string} guid The GUID to credit card to remove from the cache. */
64 clearCachedCreditCard(guid) {}
65
66 /**
67 * Saves the given credit card.
68 * @param {!AutofillManager.CreditCardEntry} creditCard
69 */
70 saveCreditCard(creditCard) {}
71 }
15 72
16 /** @typedef {chrome.autofillPrivate.AddressEntry} */ 73 /** @typedef {chrome.autofillPrivate.AddressEntry} */
17 AutofillManager.AddressEntry; 74 AutofillManager.AddressEntry;
18 75
19 /** @typedef {chrome.autofillPrivate.CreditCardEntry} */ 76 /** @typedef {chrome.autofillPrivate.CreditCardEntry} */
20 AutofillManager.CreditCardEntry; 77 AutofillManager.CreditCardEntry;
21 78
22 AutofillManager.prototype = {
23 /**
24 * Add an observer to the list of addresses.
25 * @param {function(!Array<!AutofillManager.AddressEntry>):void} listener
26 */
27 addAddressListChangedListener: assertNotReached,
28
29 /**
30 * Remove an observer from the list of addresses.
31 * @param {function(!Array<!AutofillManager.AddressEntry>):void} listener
32 */
33 removeAddressListChangedListener: assertNotReached,
34
35 /**
36 * Request the list of addresses.
37 * @param {function(!Array<!AutofillManager.AddressEntry>):void} callback
38 */
39 getAddressList: assertNotReached,
40
41 /**
42 * Saves the given address.
43 * @param {!AutofillManager.AddressEntry} address
44 */
45 saveAddress: assertNotReached,
46
47 /** @param {string} guid The guid of the address to remove. */
48 removeAddress: assertNotReached,
49
50 /**
51 * Add an observer to the list of credit cards.
52 * @param {function(!Array<!AutofillManager.CreditCardEntry>):void} listener
53 */
54 addCreditCardListChangedListener: assertNotReached,
55
56 /**
57 * Remove an observer from the list of credit cards.
58 * @param {function(!Array<!AutofillManager.CreditCardEntry>):void} listener
59 */
60 removeCreditCardListChangedListener: assertNotReached,
61
62 /**
63 * Request the list of credit cards.
64 * @param {function(!Array<!AutofillManager.CreditCardEntry>):void} callback
65 */
66 getCreditCardList: assertNotReached,
67
68 /** @param {string} guid The GUID of the credit card to remove. */
69 removeCreditCard: assertNotReached,
70
71 /** @param {string} guid The GUID to credit card to remove from the cache. */
72 clearCachedCreditCard: assertNotReached,
73
74 /**
75 * Saves the given credit card.
76 * @param {!AutofillManager.CreditCardEntry} creditCard
77 */
78 saveCreditCard: assertNotReached,
79 };
80
81 /** 79 /**
82 * Implementation that accesses the private API. 80 * Implementation that accesses the private API.
83 * @implements {AutofillManager} 81 * @implements {AutofillManager}
84 * @constructor
85 */ 82 */
86 function AutofillManagerImpl() {} 83 class AutofillManagerImpl {
87 cr.addSingletonGetter(AutofillManagerImpl); 84 /** @override */
88 85 addAddressListChangedListener(listener) {
89 AutofillManagerImpl.prototype = { 86 chrome.autofillPrivate.onAddressListChanged.addListener(listener);
90 __proto__: AutofillManager, 87 }
91 88
92 /** @override */ 89 /** @override */
93 addAddressListChangedListener: function(listener) { 90 removeAddressListChangedListener(listener) {
94 chrome.autofillPrivate.onAddressListChanged.addListener(listener); 91 chrome.autofillPrivate.onAddressListChanged.removeListener(listener);
95 }, 92 }
96 93
97 /** @override */ 94 /** @override */
98 removeAddressListChangedListener: function(listener) { 95 getAddressList(callback) {
99 chrome.autofillPrivate.onAddressListChanged.removeListener(listener); 96 chrome.autofillPrivate.getAddressList(callback);
100 }, 97 }
101 98
102 /** @override */ 99 /** @override */
103 getAddressList: function(callback) { 100 saveAddress(address) {
104 chrome.autofillPrivate.getAddressList(callback); 101 chrome.autofillPrivate.saveAddress(address);
105 }, 102 }
106 103
107 /** @override */ 104 /** @override */
108 saveAddress: function(address) { 105 removeAddress(guid) {
109 chrome.autofillPrivate.saveAddress(address); 106 chrome.autofillPrivate.removeEntry(assert(guid));
110 }, 107 }
111 108
112 /** @override */ 109 /** @override */
113 removeAddress: function(guid) { 110 addCreditCardListChangedListener(listener) {
114 chrome.autofillPrivate.removeEntry(assert(guid)); 111 chrome.autofillPrivate.onCreditCardListChanged.addListener(listener);
115 }, 112 }
116 113
117 /** @override */ 114 /** @override */
118 addCreditCardListChangedListener: function(listener) { 115 removeCreditCardListChangedListener(listener) {
119 chrome.autofillPrivate.onCreditCardListChanged.addListener(listener); 116 chrome.autofillPrivate.onCreditCardListChanged.removeListener(listener);
120 }, 117 }
121 118
122 /** @override */ 119 /** @override */
123 removeCreditCardListChangedListener: function(listener) { 120 getCreditCardList(callback) {
124 chrome.autofillPrivate.onCreditCardListChanged.removeListener(listener); 121 chrome.autofillPrivate.getCreditCardList(callback);
125 }, 122 }
126 123
127 /** @override */ 124 /** @override */
128 getCreditCardList: function(callback) { 125 removeCreditCard(guid) {
129 chrome.autofillPrivate.getCreditCardList(callback); 126 chrome.autofillPrivate.removeEntry(assert(guid));
130 }, 127 }
131 128
132 /** @override */ 129 /** @override */
133 removeCreditCard: function(guid) { 130 clearCachedCreditCard(guid) {
134 chrome.autofillPrivate.removeEntry(assert(guid)); 131 chrome.autofillPrivate.maskCreditCard(assert(guid));
135 }, 132 }
136 133
137 /** @override */ 134 /** @override */
138 clearCachedCreditCard: function(guid) { 135 saveCreditCard(creditCard) {
139 chrome.autofillPrivate.maskCreditCard(assert(guid));
140 },
141
142 /** @override */
143 saveCreditCard: function(creditCard) {
144 chrome.autofillPrivate.saveCreditCard(creditCard); 136 chrome.autofillPrivate.saveCreditCard(creditCard);
145 } 137 }
146 }; 138 }
139
140 cr.addSingletonGetter(AutofillManagerImpl);
147 141
148 (function() { 142 (function() {
149 'use strict'; 143 'use strict';
150 144
151 Polymer({ 145 Polymer({
152 is: 'settings-autofill-section', 146 is: 'settings-autofill-section',
153 147
154 behaviors: [I18nBehavior], 148 behaviors: [I18nBehavior],
155 149
156 properties: { 150 properties: {
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 /** 455 /**
462 * @private 456 * @private
463 * @param {boolean} toggleValue 457 * @param {boolean} toggleValue
464 * @return {string} 458 * @return {string}
465 */ 459 */
466 getOnOffLabel_: function(toggleValue) { 460 getOnOffLabel_: function(toggleValue) {
467 return toggleValue ? this.i18n('toggleOn') : this.i18n('toggleOff'); 461 return toggleValue ? this.i18n('toggleOn') : this.i18n('toggleOff');
468 } 462 }
469 }); 463 });
470 })(); 464 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698