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

Side by Side Diff: chrome/browser/resources/options/autofill_options.js

Issue 410293004: Split OptionsPage into Page and PageManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ugh just no Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
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 cr.define('options', function() { 5 cr.define('options', function() {
6 var OptionsPage = options.OptionsPage; 6 var Page = cr.ui.pageManager.Page;
7 var PageManager = cr.ui.pageManager.PageManager;
7 var ArrayDataModel = cr.ui.ArrayDataModel; 8 var ArrayDataModel = cr.ui.ArrayDataModel;
8 9
9 ///////////////////////////////////////////////////////////////////////////// 10 /////////////////////////////////////////////////////////////////////////////
10 // AutofillOptions class: 11 // AutofillOptions class:
11 12
12 /** 13 /**
13 * Encapsulated handling of Autofill options page. 14 * Encapsulated handling of Autofill options page.
14 * @constructor 15 * @constructor
15 */ 16 */
16 function AutofillOptions() { 17 function AutofillOptions() {
17 OptionsPage.call(this, 18 Page.call(this, 'autofill',
18 'autofill', 19 loadTimeData.getString('autofillOptionsPageTabTitle'),
19 loadTimeData.getString('autofillOptionsPageTabTitle'), 20 'autofill-options');
20 'autofill-options');
21 } 21 }
22 22
23 cr.addSingletonGetter(AutofillOptions); 23 cr.addSingletonGetter(AutofillOptions);
24 24
25 AutofillOptions.prototype = { 25 AutofillOptions.prototype = {
26 __proto__: OptionsPage.prototype, 26 __proto__: Page.prototype,
27 27
28 /** 28 /**
29 * The address list. 29 * The address list.
30 * @type {DeletableItemList} 30 * @type {DeletableItemList}
31 * @private 31 * @private
32 */ 32 */
33 addressList_: null, 33 addressList_: null,
34 34
35 /** 35 /**
36 * The credit card list. 36 * The credit card list.
37 * @type {DeletableItemList} 37 * @type {DeletableItemList}
38 * @private 38 * @private
39 */ 39 */
40 creditCardList_: null, 40 creditCardList_: null,
41 41
42 /** @override */ 42 /** @override */
43 initializePage: function() { 43 initializePage: function() {
44 OptionsPage.prototype.initializePage.call(this); 44 Page.prototype.initializePage.call(this);
45 45
46 this.createAddressList_(); 46 this.createAddressList_();
47 this.createCreditCardList_(); 47 this.createCreditCardList_();
48 48
49 var self = this; 49 var self = this;
50 $('autofill-add-address').onclick = function(event) { 50 $('autofill-add-address').onclick = function(event) {
51 self.showAddAddressOverlay_(); 51 self.showAddAddressOverlay_();
52 }; 52 };
53 $('autofill-add-creditcard').onclick = function(event) { 53 $('autofill-add-creditcard').onclick = function(event) {
54 self.showAddCreditCardOverlay_(); 54 self.showAddCreditCardOverlay_();
55 }; 55 };
56 $('autofill-options-confirm').onclick = function(event) { 56 $('autofill-options-confirm').onclick = function(event) {
57 OptionsPage.closeOverlay(); 57 PageManager.closeOverlay();
58 }; 58 };
59 <if expr="is_macosx"> 59 <if expr="is_macosx">
60 $('autofill-use-mac-address-book-checkbox').onchange = function(event) { 60 $('autofill-use-mac-address-book-checkbox').onchange = function(event) {
61 if (this.checked) { 61 if (this.checked) {
62 setTimeout(function() { 62 setTimeout(function() {
63 // Prompt the user to give Chrome access to the user's Address 63 // Prompt the user to give Chrome access to the user's Address
64 // Book, if the user was not previously prompted. The dialog that 64 // Book, if the user was not previously prompted. The dialog that
65 // appears blocks the Chrome process, so wait for a small period of 65 // appears blocks the Chrome process, so wait for a small period of
66 // time to allow the checkbox to appear filled in. 66 // time to allow the checkbox to appear filled in.
67 chrome.send('accessAddressBook'); 67 chrome.send('accessAddressBook');
(...skipping 28 matching lines...) Expand all
96 }, 96 },
97 97
98 /** 98 /**
99 * Shows the 'Add address' overlay, specifically by loading the 99 * Shows the 'Add address' overlay, specifically by loading the
100 * 'Edit address' overlay and modifying the overlay title. 100 * 'Edit address' overlay and modifying the overlay title.
101 * @private 101 * @private
102 */ 102 */
103 showAddAddressOverlay_: function() { 103 showAddAddressOverlay_: function() {
104 var title = loadTimeData.getString('addAddressTitle'); 104 var title = loadTimeData.getString('addAddressTitle');
105 AutofillEditAddressOverlay.setTitle(title); 105 AutofillEditAddressOverlay.setTitle(title);
106 OptionsPage.navigateToPage('autofillEditAddress'); 106 PageManager.showPageByName('autofillEditAddress');
107 }, 107 },
108 108
109 /** 109 /**
110 * Shows the 'Add credit card' overlay, specifically by loading the 110 * Shows the 'Add credit card' overlay, specifically by loading the
111 * 'Edit credit card' overlay and modifying the overlay title. 111 * 'Edit credit card' overlay and modifying the overlay title.
112 * @private 112 * @private
113 */ 113 */
114 showAddCreditCardOverlay_: function() { 114 showAddCreditCardOverlay_: function() {
115 var title = loadTimeData.getString('addCreditCardTitle'); 115 var title = loadTimeData.getString('addCreditCardTitle');
116 AutofillEditCreditCardOverlay.setTitle(title); 116 AutofillEditCreditCardOverlay.setTitle(title);
117 OptionsPage.navigateToPage('autofillEditCreditCard'); 117 PageManager.showPageByName('autofillEditCreditCard');
118 }, 118 },
119 119
120 /** 120 /**
121 * Updates the data model for the address list with the values from 121 * Updates the data model for the address list with the values from
122 * |entries|. 122 * |entries|.
123 * @param {Array} entries The list of addresses. 123 * @param {Array} entries The list of addresses.
124 */ 124 */
125 setAddressList_: function(entries) { 125 setAddressList_: function(entries) {
126 this.addressList_.dataModel = new ArrayDataModel(entries); 126 this.addressList_.dataModel = new ArrayDataModel(entries);
127 }, 127 },
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 /** 169 /**
170 * Shows the 'Edit address' overlay, using the data in |address| to fill the 170 * Shows the 'Edit address' overlay, using the data in |address| to fill the
171 * input fields. |address| is a list with one item, an associative array 171 * input fields. |address| is a list with one item, an associative array
172 * that contains the address data. 172 * that contains the address data.
173 * @private 173 * @private
174 */ 174 */
175 showEditAddressOverlay_: function(address) { 175 showEditAddressOverlay_: function(address) {
176 var title = loadTimeData.getString('editAddressTitle'); 176 var title = loadTimeData.getString('editAddressTitle');
177 AutofillEditAddressOverlay.setTitle(title); 177 AutofillEditAddressOverlay.setTitle(title);
178 AutofillEditAddressOverlay.loadAddress(address); 178 AutofillEditAddressOverlay.loadAddress(address);
179 OptionsPage.navigateToPage('autofillEditAddress'); 179 PageManager.showPageByName('autofillEditAddress');
180 }, 180 },
181 181
182 /** 182 /**
183 * Shows the 'Edit credit card' overlay, using the data in |credit_card| to 183 * Shows the 'Edit credit card' overlay, using the data in |credit_card| to
184 * fill the input fields. |address| is a list with one item, an associative 184 * fill the input fields. |address| is a list with one item, an associative
185 * array that contains the credit card data. 185 * array that contains the credit card data.
186 * @private 186 * @private
187 */ 187 */
188 showEditCreditCardOverlay_: function(creditCard) { 188 showEditCreditCardOverlay_: function(creditCard) {
189 var title = loadTimeData.getString('editCreditCardTitle'); 189 var title = loadTimeData.getString('editCreditCardTitle');
190 AutofillEditCreditCardOverlay.setTitle(title); 190 AutofillEditCreditCardOverlay.setTitle(title);
191 AutofillEditCreditCardOverlay.loadCreditCard(creditCard); 191 AutofillEditCreditCardOverlay.loadCreditCard(creditCard);
192 OptionsPage.navigateToPage('autofillEditCreditCard'); 192 PageManager.showPageByName('autofillEditCreditCard');
193 }, 193 },
194 }; 194 };
195 195
196 AutofillOptions.setAddressList = function(entries) { 196 AutofillOptions.setAddressList = function(entries) {
197 AutofillOptions.getInstance().setAddressList_(entries); 197 AutofillOptions.getInstance().setAddressList_(entries);
198 }; 198 };
199 199
200 AutofillOptions.setCreditCardList = function(entries) { 200 AutofillOptions.setCreditCardList = function(entries) {
201 AutofillOptions.getInstance().setCreditCardList_(entries); 201 AutofillOptions.getInstance().setCreditCardList_(entries);
202 }; 202 };
(...skipping 18 matching lines...) Expand all
221 AutofillOptions.getInstance().showEditCreditCardOverlay_(creditCard); 221 AutofillOptions.getInstance().showEditCreditCardOverlay_(creditCard);
222 }; 222 };
223 223
224 // Export 224 // Export
225 return { 225 return {
226 AutofillOptions: AutofillOptions 226 AutofillOptions: AutofillOptions
227 }; 227 };
228 228
229 }); 229 });
230 230
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698