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

Side by Side Diff: chrome/browser/resources/settings/printing_page/cups_add_printer_dialog.js

Issue 2962413002: Separate manufacturer and model fields from PPD info (Closed)
Patch Set: rebase 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-cups-add-printer-dialog' includes multiple dialogs to 6 * @fileoverview 'settings-cups-add-printer-dialog' includes multiple dialogs to
7 * set up a new CUPS printer. 7 * set up a new CUPS printer.
8 * Subdialogs include: 8 * Subdialogs include:
9 * - 'add-printer-discovery-dialog' is a dialog showing discovered printers on 9 * - 'add-printer-discovery-dialog' is a dialog showing discovered printers on
10 * the network that are available for setup. 10 * the network that are available for setup.
(...skipping 21 matching lines...) Expand all
32 * @const {number} 32 * @const {number}
33 */ 33 */
34 var kPrinterListFullHeight = 350; 34 var kPrinterListFullHeight = 350;
35 35
36 /** 36 /**
37 * Return a reset CupsPrinterInfo object. 37 * Return a reset CupsPrinterInfo object.
38 * @return {!CupsPrinterInfo} 38 * @return {!CupsPrinterInfo}
39 */ 39 */
40 function getEmptyPrinter_() { 40 function getEmptyPrinter_() {
41 return { 41 return {
42 ppdManufacturer: '',
43 ppdModel: '',
42 printerAddress: '', 44 printerAddress: '',
43 printerAutoconf: false, 45 printerAutoconf: false,
44 printerDescription: '', 46 printerDescription: '',
45 printerId: '', 47 printerId: '',
46 printerManufacturer: '', 48 printerManufacturer: '',
47 printerModel: '', 49 printerModel: '',
48 printerName: '', 50 printerName: '',
49 printerPPDPath: '', 51 printerPPDPath: '',
50 printerProtocol: 'ipp', 52 printerProtocol: 'ipp',
51 printerQueue: '', 53 printerQueue: '',
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 this.stopDiscoveringPrinters_(); 133 this.stopDiscoveringPrinters_();
132 this.$$('add-printer-dialog').close(); 134 this.$$('add-printer-dialog').close();
133 }, 135 },
134 136
135 /** @private */ 137 /** @private */
136 switchToManufacturerDialog_: function() { 138 switchToManufacturerDialog_: function() {
137 this.stopDiscoveringPrinters_(); 139 this.stopDiscoveringPrinters_();
138 // If we're switching to the manufacturer/model dialog, clear the existing 140 // If we're switching to the manufacturer/model dialog, clear the existing
139 // data we have about the PPD (if any), as we're dropping that in favor of 141 // data we have about the PPD (if any), as we're dropping that in favor of
140 // user selections. 142 // user selections.
141 this.selectedPrinter.printerManufacturer = ''; 143 this.selectedPrinter.ppdManufacturer = '';
142 this.selectedPrinter.printerModel = ''; 144 this.selectedPrinter.ppdModel = '';
143 this.selectedPrinter.printerPPDPath = ''; 145 this.selectedPrinter.printerPPDPath = '';
144 this.$$('add-printer-dialog').close(); 146 this.$$('add-printer-dialog').close();
145 this.fire('open-manufacturer-model-dialog'); 147 this.fire('open-manufacturer-model-dialog');
146 }, 148 },
147 }); 149 });
148 150
149 Polymer({ 151 Polymer({
150 is: 'add-printer-manually-dialog', 152 is: 'add-printer-manually-dialog',
151 153
152 properties: { 154 properties: {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 type: Array, 213 type: Array,
212 }, 214 },
213 215
214 setupFailed: { 216 setupFailed: {
215 type: Boolean, 217 type: Boolean,
216 value: false, 218 value: false,
217 }, 219 },
218 }, 220 },
219 221
220 observers: [ 222 observers: [
221 'selectedManufacturerChanged_(newPrinter.printerManufacturer)', 223 'selectedManufacturerChanged_(newPrinter.ppdManufacturer)',
222 ], 224 ],
223 225
224 /** @override */ 226 /** @override */
225 ready: function() { 227 ready: function() {
226 settings.CupsPrintersBrowserProxyImpl.getInstance() 228 settings.CupsPrintersBrowserProxyImpl.getInstance()
227 .getCupsPrinterManufacturersList() 229 .getCupsPrinterManufacturersList()
228 .then(this.manufacturerListChanged_.bind(this)); 230 .then(this.manufacturerListChanged_.bind(this));
229 }, 231 },
230 232
231 /** 233 /**
232 * @param {string} manufacturer The manufacturer for which we are retrieving 234 * @param {string} manufacturer The manufacturer for which we are retrieving
233 * models. 235 * models.
234 * @private 236 * @private
235 */ 237 */
236 selectedManufacturerChanged_: function(manufacturer) { 238 selectedManufacturerChanged_: function(manufacturer) {
237 // Reset model if manufacturer is changed. 239 // Reset model if manufacturer is changed.
238 this.set('newPrinter.printerModel', ''); 240 this.set('newPrinter.ppdModel', '');
239 if (manufacturer) { 241 if (manufacturer) {
240 settings.CupsPrintersBrowserProxyImpl.getInstance() 242 settings.CupsPrintersBrowserProxyImpl.getInstance()
241 .getCupsPrinterModelsList(manufacturer) 243 .getCupsPrinterModelsList(manufacturer)
242 .then(this.modelListChanged_.bind(this)); 244 .then(this.modelListChanged_.bind(this));
243 } 245 }
244 }, 246 },
245 247
246 /** @private */ 248 /** @private */
247 onBrowseFile_: function() { 249 onBrowseFile_: function() {
248 settings.CupsPrintersBrowserProxyImpl.getInstance() 250 settings.CupsPrintersBrowserProxyImpl.getInstance()
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 /** 293 /**
292 * @param {string} path The full path of the file 294 * @param {string} path The full path of the file
293 * @return {string} The base name of the file 295 * @return {string} The base name of the file
294 * @private 296 * @private
295 */ 297 */
296 getBaseName_: function(path) { 298 getBaseName_: function(path) {
297 return path.substring(path.lastIndexOf('/') + 1); 299 return path.substring(path.lastIndexOf('/') + 1);
298 }, 300 },
299 301
300 /** 302 /**
301 * @param {string} printerManufacturer 303 * @param {string} ppdManufacturer
302 * @param {string} printerModel 304 * @param {string} ppdModel
303 * @param {string} printerPPDPath 305 * @param {string} printerPPDPath
304 * @return {boolean} Whether we have enough information to set up the printer 306 * @return {boolean} Whether we have enough information to set up the printer
305 * @private 307 * @private
306 */ 308 */
307 canAddPrinter_: function(printerManufacturer, printerModel, printerPPDPath) { 309 canAddPrinter_: function(ppdManufacturer, ppdModel, printerPPDPath) {
308 return !!((printerManufacturer && printerModel) || printerPPDPath); 310 return !!((ppdManufacturer && ppdModel) || printerPPDPath);
309 }, 311 },
310 }); 312 });
311 313
312 Polymer({ 314 Polymer({
313 is: 'add-printer-configuring-dialog', 315 is: 'add-printer-configuring-dialog',
314 316
315 properties: { 317 properties: {
316 printerName: String, 318 printerName: String,
317 dialogTitle: String, 319 dialogTitle: String,
318 }, 320 },
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 onAddPrinter_: function(success, printerName) { 541 onAddPrinter_: function(success, printerName) {
540 this.$$('add-printer-configuring-dialog').close(); 542 this.$$('add-printer-configuring-dialog').close();
541 if (success) 543 if (success)
542 return; 544 return;
543 545
544 if (this.previousDialog_ == AddPrinterDialogs.MANUFACTURER) { 546 if (this.previousDialog_ == AddPrinterDialogs.MANUFACTURER) {
545 this.setupFailed = true; 547 this.setupFailed = true;
546 } 548 }
547 }, 549 },
548 }); 550 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698