OLD | NEW |
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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 Polymer({ | 68 Polymer({ |
69 is: 'add-printer-maually-dialog', | 69 is: 'add-printer-maually-dialog', |
70 | 70 |
71 properties: { | 71 properties: { |
72 /** @type {!CupsPrinterInfo} */ | 72 /** @type {!CupsPrinterInfo} */ |
73 newPrinter: { | 73 newPrinter: { |
74 type: Object, | 74 type: Object, |
75 notify: true, | 75 notify: true, |
76 value: function() { | 76 value: function() { |
77 return { | 77 return { |
78 printerAddress: '', | 78 printerAddress: '', |
79 printerDescription: '', | 79 printerDescription: '', |
80 printerId: '', | 80 printerId: '', |
81 printerManufacturer: '', | 81 printerManufacturer: '', |
82 printerModel: '', | 82 printerModel: '', |
83 printerName: '', | 83 printerName: '', |
84 printerProtocol: 'ipp', | 84 printerPPDPath: '', |
85 printerQueue: '', | 85 printerProtocol: 'ipp', |
86 printerStatus: '', | 86 printerQueue: '', |
| 87 printerStatus: '', |
87 }; | 88 }; |
88 }, | 89 }, |
89 }, | 90 }, |
90 }, | 91 }, |
91 | 92 |
92 /** @private */ | 93 /** @private */ |
93 switchToDiscoveryDialog_: function() { | 94 switchToDiscoveryDialog_: function() { |
94 this.$$('add-printer-dialog').close(); | 95 this.$$('add-printer-dialog').close(); |
95 this.fire('open-discovery-printers-dialog'); | 96 this.fire('open-discovery-printers-dialog'); |
96 }, | 97 }, |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 // TODO(xdai): Get available manufacturerList after the API is ready. | 181 // TODO(xdai): Get available manufacturerList after the API is ready. |
181 }, | 182 }, |
182 | 183 |
183 /** @private */ | 184 /** @private */ |
184 selectedManufacturerChanged_: function() { | 185 selectedManufacturerChanged_: function() { |
185 // TODO(xdai): Get available modelList for a selected manufacturer after | 186 // TODO(xdai): Get available modelList for a selected manufacturer after |
186 // the API is ready. | 187 // the API is ready. |
187 }, | 188 }, |
188 | 189 |
189 /** @private */ | 190 /** @private */ |
| 191 onBrowseFile_: function() { |
| 192 settings.CupsPrintersBrowserProxyImpl.getInstance(). |
| 193 getCupsPrinterPPDPath().then(this.printerPPDPathChanged_.bind(this)); |
| 194 }, |
| 195 |
| 196 /** |
| 197 * @param {string} path |
| 198 * @private |
| 199 */ |
| 200 printerPPDPathChanged_: function(path) { |
| 201 this.newPrinter.printerPPDPath = path; |
| 202 this.$$('paper-input').value = this.getBaseName_(path); |
| 203 }, |
| 204 |
| 205 /** @private */ |
190 switchToManualAddDialog_: function() { | 206 switchToManualAddDialog_: function() { |
191 this.$$('add-printer-dialog').close(); | 207 this.$$('add-printer-dialog').close(); |
192 this.fire('open-manually-add-printer-dialog'); | 208 this.fire('open-manually-add-printer-dialog'); |
193 }, | 209 }, |
194 | 210 |
195 /** @private */ | 211 /** @private */ |
196 onCancelTap_: function() { | 212 onCancelTap_: function() { |
197 this.$$('add-printer-dialog').close(); | 213 this.$$('add-printer-dialog').close(); |
198 }, | 214 }, |
199 | 215 |
200 /** @private */ | 216 /** @private */ |
201 switchToConfiguringDialog_: function() { | 217 switchToConfiguringDialog_: function() { |
202 this.$$('add-printer-dialog').close(); | 218 this.$$('add-printer-dialog').close(); |
203 this.fire('open-configuring-printer-dialog'); | 219 this.fire('open-configuring-printer-dialog'); |
204 }, | 220 }, |
| 221 |
| 222 /** |
| 223 * @param {string} path The full path of the file |
| 224 * @return {string} The base name of the file |
| 225 * @private |
| 226 */ |
| 227 getBaseName_: function(path) { |
| 228 return path.substring(path.lastIndexOf('/') + 1); |
| 229 }, |
205 }); | 230 }); |
206 | 231 |
207 Polymer({ | 232 Polymer({ |
208 is: 'add-printer-configuring-dialog', | 233 is: 'add-printer-configuring-dialog', |
209 | 234 |
210 properties: { | 235 properties: { |
211 printerName: String, | 236 printerName: String, |
212 }, | 237 }, |
213 | 238 |
214 /** @override */ | 239 /** @override */ |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 getConfiguringPrinterName_: function() { | 361 getConfiguringPrinterName_: function() { |
337 if (this.previousDialog_ == AddPrinterDialogs.DISCOVERY) | 362 if (this.previousDialog_ == AddPrinterDialogs.DISCOVERY) |
338 return this.selectedPrinter.printerName; | 363 return this.selectedPrinter.printerName; |
339 if (this.previousDialog_ == AddPrinterDialogs.MANUALLY || | 364 if (this.previousDialog_ == AddPrinterDialogs.MANUALLY || |
340 this.previousDialog_ == AddPrinterDialogs.MANUFACTURER) { | 365 this.previousDialog_ == AddPrinterDialogs.MANUFACTURER) { |
341 return this.newPrinter.printerName; | 366 return this.newPrinter.printerName; |
342 } | 367 } |
343 return ''; | 368 return ''; |
344 }, | 369 }, |
345 }); | 370 }); |
OLD | NEW |