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 /** | 5 /** |
6 * @typedef {{ | 6 * @typedef {{ |
7 * creditCardNumber: string, | 7 * creditCardNumber: string, |
8 * expirationMonth: string, | 8 * expirationMonth: string, |
9 * expirationYear: string, | 9 * expirationYear: string, |
10 * guid: string, | 10 * guid: string, |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 * @param {string=} metricsAction The name of the action to log for metrics. | 174 * @param {string=} metricsAction The name of the action to log for metrics. |
175 * @private | 175 * @private |
176 */ | 176 */ |
177 removeData_: function(guid, metricsAction) { | 177 removeData_: function(guid, metricsAction) { |
178 chrome.send('removeData', [guid]); | 178 chrome.send('removeData', [guid]); |
179 if (metricsAction) | 179 if (metricsAction) |
180 chrome.send('coreOptionsUserMetricsAction', [metricsAction]); | 180 chrome.send('coreOptionsUserMetricsAction', [metricsAction]); |
181 }, | 181 }, |
182 | 182 |
183 /** | 183 /** |
184 * Requests profile data for the address represented by |guid| from the | 184 * For local Autofill data, this function causes the AutofillOptionsHandler |
185 * PersonalDataManager. Once the data is loaded, the AutofillOptionsHandler | 185 * to call showEditAddressOverlay(). For Wallet data, the user is |
186 * calls showEditAddressOverlay(). | 186 * redirected to the Wallet web interface. |
187 * @param {string} guid The GUID of the address to edit. | 187 * @param {Object} entry The relevant entry in data model. |
188 * @private | 188 * @private |
189 */ | 189 */ |
190 loadAddressEditor_: function(guid) { | 190 loadAddressEditor_: function(entry) { |
191 chrome.send('loadAddressEditor', [guid]); | 191 if (entry.isLocal) |
| 192 chrome.send('loadAddressEditor', [entry.guid]); |
| 193 else |
| 194 window.open(loadTimeData.getString('manageWalletAddressesUrl')); |
192 }, | 195 }, |
193 | 196 |
194 /** | 197 /** |
195 * Requests profile data for the credit card represented by |guid| from the | 198 * For local Autofill data, this function causes the AutofillOptionsHandler |
196 * PersonalDataManager. Once the data is loaded, the AutofillOptionsHandler | 199 * to call showEditCreditCardOverlay(). For Wallet data, the user is |
197 * calls showEditCreditCardOverlay(). | 200 * redirected to the Wallet web interface. |
198 * @param {string} guid The GUID of the credit card to edit. | 201 * @param {Object} entry The relevant entry in data model. |
199 * @private | 202 * @private |
200 */ | 203 */ |
201 loadCreditCardEditor_: function(guid) { | 204 loadCreditCardEditor_: function(entry) { |
202 chrome.send('loadCreditCardEditor', [guid]); | 205 if (entry.isLocal) |
| 206 chrome.send('loadCreditCardEditor', [entry.guid]); |
| 207 else |
| 208 window.open(loadTimeData.getString('manageWalletPaymentMethodsUrl')); |
203 }, | 209 }, |
204 | 210 |
205 /** | 211 /** |
206 * Shows the 'Edit address' overlay, using the data in |address| to fill the | 212 * Shows the 'Edit address' overlay, using the data in |address| to fill the |
207 * input fields. |address| is a list with one item, an associative array | 213 * input fields. |address| is a list with one item, an associative array |
208 * that contains the address data. | 214 * that contains the address data. |
209 * @private | 215 * @private |
210 */ | 216 */ |
211 showEditAddressOverlay_: function(address) { | 217 showEditAddressOverlay_: function(address) { |
212 var title = loadTimeData.getString('editAddressTitle'); | 218 var title = loadTimeData.getString('editAddressTitle'); |
(...skipping 22 matching lines...) Expand all Loading... |
235 }; | 241 }; |
236 | 242 |
237 AutofillOptions.setCreditCardList = function(entries) { | 243 AutofillOptions.setCreditCardList = function(entries) { |
238 AutofillOptions.getInstance().setCreditCardList_(entries); | 244 AutofillOptions.getInstance().setCreditCardList_(entries); |
239 }; | 245 }; |
240 | 246 |
241 AutofillOptions.removeData = function(guid, metricsAction) { | 247 AutofillOptions.removeData = function(guid, metricsAction) { |
242 AutofillOptions.getInstance().removeData_(guid, metricsAction); | 248 AutofillOptions.getInstance().removeData_(guid, metricsAction); |
243 }; | 249 }; |
244 | 250 |
245 AutofillOptions.loadAddressEditor = function(guid) { | 251 AutofillOptions.loadAddressEditor = function(entry) { |
246 AutofillOptions.getInstance().loadAddressEditor_(guid); | 252 AutofillOptions.getInstance().loadAddressEditor_(entry); |
247 }; | 253 }; |
248 | 254 |
249 AutofillOptions.loadCreditCardEditor = function(guid) { | 255 AutofillOptions.loadCreditCardEditor = function(entry) { |
250 AutofillOptions.getInstance().loadCreditCardEditor_(guid); | 256 AutofillOptions.getInstance().loadCreditCardEditor_(entry); |
251 }; | 257 }; |
252 | 258 |
253 AutofillOptions.editAddress = function(address) { | 259 AutofillOptions.editAddress = function(address) { |
254 AutofillOptions.getInstance().showEditAddressOverlay_(address); | 260 AutofillOptions.getInstance().showEditAddressOverlay_(address); |
255 }; | 261 }; |
256 | 262 |
257 /** | 263 /** |
258 * @param {CreditCardData} creditCard | 264 * @param {CreditCardData} creditCard |
259 */ | 265 */ |
260 AutofillOptions.editCreditCard = function(creditCard) { | 266 AutofillOptions.editCreditCard = function(creditCard) { |
261 AutofillOptions.getInstance().showEditCreditCardOverlay_(creditCard); | 267 AutofillOptions.getInstance().showEditCreditCardOverlay_(creditCard); |
262 }; | 268 }; |
263 | 269 |
264 // Export | 270 // Export |
265 return { | 271 return { |
266 AutofillOptions: AutofillOptions | 272 AutofillOptions: AutofillOptions |
267 }; | 273 }; |
268 | 274 |
269 }); | 275 }); |
270 | 276 |
OLD | NEW |