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 /** |
| 6 * @typedef {{ |
| 7 * creditCardNumber: string, |
| 8 * expirationMonth: string, |
| 9 * expirationYear: string, |
| 10 * guid: string, |
| 11 * nameOnCard: string |
| 12 * }} |
| 13 * @see chrome/browser/ui/webui/options/autofill_options_handler.cc |
| 14 */ |
| 15 var CreditCardData; |
| 16 |
5 cr.define('options', function() { | 17 cr.define('options', function() { |
6 var Page = cr.ui.pageManager.Page; | 18 var Page = cr.ui.pageManager.Page; |
7 var PageManager = cr.ui.pageManager.PageManager; | 19 var PageManager = cr.ui.pageManager.PageManager; |
8 var ArrayDataModel = cr.ui.ArrayDataModel; | 20 var ArrayDataModel = cr.ui.ArrayDataModel; |
9 | 21 |
10 ///////////////////////////////////////////////////////////////////////////// | 22 ///////////////////////////////////////////////////////////////////////////// |
11 // AutofillOptions class: | 23 // AutofillOptions class: |
12 | 24 |
13 /** | 25 /** |
14 * Encapsulated handling of Autofill options page. | 26 * Encapsulated handling of Autofill options page. |
15 * @constructor | 27 * @constructor |
| 28 * @extends {cr.ui.pageManager.Page} |
16 */ | 29 */ |
17 function AutofillOptions() { | 30 function AutofillOptions() { |
18 Page.call(this, 'autofill', | 31 Page.call(this, 'autofill', |
19 loadTimeData.getString('autofillOptionsPageTabTitle'), | 32 loadTimeData.getString('autofillOptionsPageTabTitle'), |
20 'autofill-options'); | 33 'autofill-options'); |
21 } | 34 } |
22 | 35 |
23 cr.addSingletonGetter(AutofillOptions); | 36 cr.addSingletonGetter(AutofillOptions); |
24 | 37 |
25 AutofillOptions.prototype = { | 38 AutofillOptions.prototype = { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 | 85 |
73 // TODO(jhawkins): What happens when Autofill is disabled whilst on the | 86 // TODO(jhawkins): What happens when Autofill is disabled whilst on the |
74 // Autofill options page? | 87 // Autofill options page? |
75 }, | 88 }, |
76 | 89 |
77 /** | 90 /** |
78 * Creates, decorates and initializes the address list. | 91 * Creates, decorates and initializes the address list. |
79 * @private | 92 * @private |
80 */ | 93 */ |
81 createAddressList_: function() { | 94 createAddressList_: function() { |
82 this.addressList_ = $('address-list'); | 95 var addressList = $('address-list'); |
83 options.autofillOptions.AutofillAddressList.decorate(this.addressList_); | 96 options.autofillOptions.AutofillAddressList.decorate(addressList); |
| 97 this.addressList_ = assertInstanceof(addressList, |
| 98 options.DeletableItemList); |
84 this.addressList_.autoExpands = true; | 99 this.addressList_.autoExpands = true; |
85 }, | 100 }, |
86 | 101 |
87 /** | 102 /** |
88 * Creates, decorates and initializes the credit card list. | 103 * Creates, decorates and initializes the credit card list. |
89 * @private | 104 * @private |
90 */ | 105 */ |
91 createCreditCardList_: function() { | 106 createCreditCardList_: function() { |
92 this.creditCardList_ = $('creditcard-list'); | 107 var creditCardList = $('creditcard-list'); |
93 options.autofillOptions.AutofillCreditCardList.decorate( | 108 options.autofillOptions.AutofillCreditCardList.decorate(creditCardList); |
94 this.creditCardList_); | 109 this.creditCardList_ = assertInstanceof(creditCardList, |
| 110 options.DeletableItemList); |
95 this.creditCardList_.autoExpands = true; | 111 this.creditCardList_.autoExpands = true; |
96 }, | 112 }, |
97 | 113 |
98 /** | 114 /** |
99 * Shows the 'Add address' overlay, specifically by loading the | 115 * Shows the 'Add address' overlay, specifically by loading the |
100 * 'Edit address' overlay and modifying the overlay title. | 116 * 'Edit address' overlay and modifying the overlay title. |
101 * @private | 117 * @private |
102 */ | 118 */ |
103 showAddAddressOverlay_: function() { | 119 showAddAddressOverlay_: function() { |
104 var title = loadTimeData.getString('addAddressTitle'); | 120 var title = loadTimeData.getString('addAddressTitle'); |
(...skipping 10 matching lines...) Expand all Loading... |
115 showAddCreditCardOverlay_: function() { | 131 showAddCreditCardOverlay_: function() { |
116 var title = loadTimeData.getString('addCreditCardTitle'); | 132 var title = loadTimeData.getString('addCreditCardTitle'); |
117 AutofillEditCreditCardOverlay.setTitle(title); | 133 AutofillEditCreditCardOverlay.setTitle(title); |
118 PageManager.showPageByName('autofillEditCreditCard'); | 134 PageManager.showPageByName('autofillEditCreditCard'); |
119 AutofillEditCreditCardOverlay.prepForNewCard(); | 135 AutofillEditCreditCardOverlay.prepForNewCard(); |
120 }, | 136 }, |
121 | 137 |
122 /** | 138 /** |
123 * Updates the data model for the address list with the values from | 139 * Updates the data model for the address list with the values from |
124 * |entries|. | 140 * |entries|. |
125 * @param {Array} entries The list of addresses. | 141 * @param {!Array} entries The list of addresses. |
126 */ | 142 */ |
127 setAddressList_: function(entries) { | 143 setAddressList_: function(entries) { |
128 this.addressList_.dataModel = new ArrayDataModel(entries); | 144 this.addressList_.dataModel = new ArrayDataModel(entries); |
129 }, | 145 }, |
130 | 146 |
131 /** | 147 /** |
132 * Updates the data model for the credit card list with the values from | 148 * Updates the data model for the credit card list with the values from |
133 * |entries|. | 149 * |entries|. |
134 * @param {Array} entries The list of credit cards. | 150 * @param {!Array} entries The list of credit cards. |
135 */ | 151 */ |
136 setCreditCardList_: function(entries) { | 152 setCreditCardList_: function(entries) { |
137 this.creditCardList_.dataModel = new ArrayDataModel(entries); | 153 this.creditCardList_.dataModel = new ArrayDataModel(entries); |
138 }, | 154 }, |
139 | 155 |
140 /** | 156 /** |
141 * Removes the Autofill address or credit card represented by |guid|. | 157 * Removes the Autofill address or credit card represented by |guid|. |
142 * @param {string} guid The GUID of the address to remove. | 158 * @param {string} guid The GUID of the address to remove. |
143 * @private | 159 * @private |
144 */ | 160 */ |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 var title = loadTimeData.getString('editAddressTitle'); | 194 var title = loadTimeData.getString('editAddressTitle'); |
179 AutofillEditAddressOverlay.setTitle(title); | 195 AutofillEditAddressOverlay.setTitle(title); |
180 AutofillEditAddressOverlay.loadAddress(address); | 196 AutofillEditAddressOverlay.loadAddress(address); |
181 PageManager.showPageByName('autofillEditAddress'); | 197 PageManager.showPageByName('autofillEditAddress'); |
182 }, | 198 }, |
183 | 199 |
184 /** | 200 /** |
185 * Shows the 'Edit credit card' overlay, using the data in |credit_card| to | 201 * Shows the 'Edit credit card' overlay, using the data in |credit_card| to |
186 * fill the input fields. |creditCard| is a list with one item, an | 202 * fill the input fields. |creditCard| is a list with one item, an |
187 * associative array that contains the credit card data. | 203 * associative array that contains the credit card data. |
| 204 * @param {CreditCardData} creditCard |
188 * @private | 205 * @private |
189 */ | 206 */ |
190 showEditCreditCardOverlay_: function(creditCard) { | 207 showEditCreditCardOverlay_: function(creditCard) { |
191 var title = loadTimeData.getString('editCreditCardTitle'); | 208 var title = loadTimeData.getString('editCreditCardTitle'); |
192 AutofillEditCreditCardOverlay.setTitle(title); | 209 AutofillEditCreditCardOverlay.setTitle(title); |
193 AutofillEditCreditCardOverlay.loadCreditCard(creditCard); | 210 AutofillEditCreditCardOverlay.loadCreditCard(creditCard); |
194 PageManager.showPageByName('autofillEditCreditCard'); | 211 PageManager.showPageByName('autofillEditCreditCard'); |
195 }, | 212 }, |
196 }; | 213 }; |
197 | 214 |
(...skipping 14 matching lines...) Expand all Loading... |
212 }; | 229 }; |
213 | 230 |
214 AutofillOptions.loadCreditCardEditor = function(guid) { | 231 AutofillOptions.loadCreditCardEditor = function(guid) { |
215 AutofillOptions.getInstance().loadCreditCardEditor_(guid); | 232 AutofillOptions.getInstance().loadCreditCardEditor_(guid); |
216 }; | 233 }; |
217 | 234 |
218 AutofillOptions.editAddress = function(address) { | 235 AutofillOptions.editAddress = function(address) { |
219 AutofillOptions.getInstance().showEditAddressOverlay_(address); | 236 AutofillOptions.getInstance().showEditAddressOverlay_(address); |
220 }; | 237 }; |
221 | 238 |
| 239 /** |
| 240 * @param {CreditCardData} creditCard |
| 241 */ |
222 AutofillOptions.editCreditCard = function(creditCard) { | 242 AutofillOptions.editCreditCard = function(creditCard) { |
223 AutofillOptions.getInstance().showEditCreditCardOverlay_(creditCard); | 243 AutofillOptions.getInstance().showEditCreditCardOverlay_(creditCard); |
224 }; | 244 }; |
225 | 245 |
226 // Export | 246 // Export |
227 return { | 247 return { |
228 AutofillOptions: AutofillOptions | 248 AutofillOptions: AutofillOptions |
229 }; | 249 }; |
230 | 250 |
231 }); | 251 }); |
232 | 252 |
OLD | NEW |