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 * guid: string, | 7 * guid: string, |
8 * label: string, | 8 * label: string, |
9 * sublabel: string, | 9 * sublabel: string, |
10 * isLocal: boolean, | 10 * isLocal: boolean, |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 sublabel.className = 'deemphasized'; | 83 sublabel.className = 'deemphasized'; |
84 sublabel.textContent = this.metadata_.sublabel; | 84 sublabel.textContent = this.metadata_.sublabel; |
85 this.contentElement.appendChild(sublabel); | 85 this.contentElement.appendChild(sublabel); |
86 | 86 |
87 if (!this.metadata_.isLocal) { | 87 if (!this.metadata_.isLocal) { |
88 this.deletable = false; | 88 this.deletable = false; |
89 this.contentElement.appendChild(CreateGoogleAccountLabel()); | 89 this.contentElement.appendChild(CreateGoogleAccountLabel()); |
90 } | 90 } |
91 | 91 |
92 // The 'Edit' button. | 92 // The 'Edit' button. |
93 var guid = this.metadata_.guid; | 93 var metadata = this.metadata_; |
94 var editButtonEl = AutofillEditProfileButton( | 94 var editButtonEl = AutofillEditProfileButton( |
95 function() { AutofillOptions.loadAddressEditor(guid); }); | 95 AddressListItem.prototype.loadAddressEditor.bind(this)); |
96 this.contentElement.appendChild(editButtonEl); | 96 this.contentElement.appendChild(editButtonEl); |
97 }, | 97 }, |
| 98 |
| 99 /** |
| 100 * For local Autofill data, this function causes the AutofillOptionsHandler |
| 101 * to call showEditAddressOverlay(). For Wallet data, the user is |
| 102 * redirected to the Wallet web interface. |
| 103 */ |
| 104 loadAddressEditor: function() { |
| 105 if (this.metadata_.isLocal) |
| 106 chrome.send('loadAddressEditor', [this.metadata_.guid]); |
| 107 else |
| 108 window.open(loadTimeData.getString('manageWalletAddressesUrl')); |
| 109 }, |
98 }; | 110 }; |
99 | 111 |
100 /** | 112 /** |
101 * Creates a new credit card list item. | 113 * Creates a new credit card list item. |
102 * @param {AutofillEntityMetadata} metadata Details about a credit card. | 114 * @param {AutofillEntityMetadata} metadata Details about a credit card. |
103 * @constructor | 115 * @constructor |
104 * @extends {options.DeletableItem} | 116 * @extends {options.DeletableItem} |
105 */ | 117 */ |
106 function CreditCardListItem(metadata) { | 118 function CreditCardListItem(metadata) { |
107 var el = cr.doc.createElement('div'); | 119 var el = cr.doc.createElement('div'); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 this.contentElement.appendChild(localCopyText); | 156 this.contentElement.appendChild(localCopyText); |
145 | 157 |
146 var clearLocalCopyButton = AutofillEditProfileButton( | 158 var clearLocalCopyButton = AutofillEditProfileButton( |
147 function() { chrome.send('clearLocalCardCopy', [guid]); }); | 159 function() { chrome.send('clearLocalCardCopy', [guid]); }); |
148 clearLocalCopyButton.textContent = | 160 clearLocalCopyButton.textContent = |
149 loadTimeData.getString('autofillClearLocalCopyButton'); | 161 loadTimeData.getString('autofillClearLocalCopyButton'); |
150 this.contentElement.appendChild(clearLocalCopyButton); | 162 this.contentElement.appendChild(clearLocalCopyButton); |
151 } | 163 } |
152 | 164 |
153 // The 'Edit' button. | 165 // The 'Edit' button. |
| 166 var metadata = this.metadata_; |
154 var editButtonEl = AutofillEditProfileButton( | 167 var editButtonEl = AutofillEditProfileButton( |
155 function() { AutofillOptions.loadCreditCardEditor(guid); }); | 168 CreditCardListItem.prototype.loadCreditCardEditor.bind(this)); |
156 this.contentElement.appendChild(editButtonEl); | 169 this.contentElement.appendChild(editButtonEl); |
157 }, | 170 }, |
| 171 |
| 172 /** |
| 173 * For local Autofill data, this function causes the AutofillOptionsHandler |
| 174 * to call showEditCreditCardOverlay(). For Wallet data, the user is |
| 175 * redirected to the Wallet web interface. |
| 176 */ |
| 177 loadCreditCardEditor: function() { |
| 178 if (this.metadata_.isLocal) |
| 179 chrome.send('loadCreditCardEditor', [this.metadata_.guid]); |
| 180 else |
| 181 window.open(loadTimeData.getString('manageWalletPaymentMethodsUrl')); |
| 182 }, |
158 }; | 183 }; |
159 | 184 |
160 /** | 185 /** |
161 * Creates a new value list item. | 186 * Creates a new value list item. |
162 * @param {options.autofillOptions.AutofillValuesList} list The parent list of | 187 * @param {options.autofillOptions.AutofillValuesList} list The parent list of |
163 * this item. | 188 * this item. |
164 * @param {string} entry A string value. | 189 * @param {string} entry A string value. |
165 * @constructor | 190 * @constructor |
166 * @extends {options.InlineEditableItem} | 191 * @extends {options.InlineEditableItem} |
167 */ | 192 */ |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 | 426 |
402 AutofillAddressList.prototype = { | 427 AutofillAddressList.prototype = { |
403 __proto__: AutofillProfileList.prototype, | 428 __proto__: AutofillProfileList.prototype, |
404 | 429 |
405 decorate: function() { | 430 decorate: function() { |
406 AutofillProfileList.prototype.decorate.call(this); | 431 AutofillProfileList.prototype.decorate.call(this); |
407 }, | 432 }, |
408 | 433 |
409 /** @override */ | 434 /** @override */ |
410 activateItemAtIndex: function(index) { | 435 activateItemAtIndex: function(index) { |
411 AutofillOptions.loadAddressEditor(this.dataModel.item(index)); | 436 this.getListItemByIndex(index).loadAddressEditor(); |
412 }, | 437 }, |
413 | 438 |
414 /** | 439 /** |
415 * @override | 440 * @override |
416 * @param {AutofillEntityMetadata} metadata | 441 * @param {AutofillEntityMetadata} metadata |
417 */ | 442 */ |
418 createItem: function(metadata) { | 443 createItem: function(metadata) { |
419 return new AddressListItem(metadata); | 444 return new AddressListItem(metadata); |
420 }, | 445 }, |
421 | 446 |
(...skipping 13 matching lines...) Expand all Loading... |
435 | 460 |
436 AutofillCreditCardList.prototype = { | 461 AutofillCreditCardList.prototype = { |
437 __proto__: AutofillProfileList.prototype, | 462 __proto__: AutofillProfileList.prototype, |
438 | 463 |
439 decorate: function() { | 464 decorate: function() { |
440 AutofillProfileList.prototype.decorate.call(this); | 465 AutofillProfileList.prototype.decorate.call(this); |
441 }, | 466 }, |
442 | 467 |
443 /** @override */ | 468 /** @override */ |
444 activateItemAtIndex: function(index) { | 469 activateItemAtIndex: function(index) { |
445 AutofillOptions.loadCreditCardEditor(this.dataModel.item(index)); | 470 this.getListItemByIndex(index).loadCreditCardEditor(); |
446 }, | 471 }, |
447 | 472 |
448 /** | 473 /** |
449 * @override | 474 * @override |
450 * @param {AutofillEntityMetadata} metadata | 475 * @param {AutofillEntityMetadata} metadata |
451 */ | 476 */ |
452 createItem: function(metadata) { | 477 createItem: function(metadata) { |
453 return new CreditCardListItem(metadata); | 478 return new CreditCardListItem(metadata); |
454 }, | 479 }, |
455 | 480 |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
593 CreditCardListItem: CreditCardListItem, | 618 CreditCardListItem: CreditCardListItem, |
594 ValuesListItem: ValuesListItem, | 619 ValuesListItem: ValuesListItem, |
595 NameListItem: NameListItem, | 620 NameListItem: NameListItem, |
596 AutofillAddressList: AutofillAddressList, | 621 AutofillAddressList: AutofillAddressList, |
597 AutofillCreditCardList: AutofillCreditCardList, | 622 AutofillCreditCardList: AutofillCreditCardList, |
598 AutofillValuesList: AutofillValuesList, | 623 AutofillValuesList: AutofillValuesList, |
599 AutofillNameValuesList: AutofillNameValuesList, | 624 AutofillNameValuesList: AutofillNameValuesList, |
600 AutofillPhoneValuesList: AutofillPhoneValuesList, | 625 AutofillPhoneValuesList: AutofillPhoneValuesList, |
601 }; | 626 }; |
602 }); | 627 }); |
OLD | NEW |