| 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 cr.define('print_preview', function() { | 5 cr.define('print_preview', function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * An interface to the native Chromium printing system layer. | 9 * An interface to the native Chromium printing system layer. |
| 10 * @constructor | 10 * @constructor |
| 11 * @extends {cr.EventTarget} | 11 * @extends {cr.EventTarget} |
| 12 */ | 12 */ |
| 13 function NativeLayer() { | 13 function NativeLayer() { |
| 14 cr.EventTarget.call(this); | 14 cr.EventTarget.call(this); |
| 15 | 15 |
| 16 // Bind global handlers | 16 // Bind global handlers |
| 17 global['setInitialSettings'] = this.onSetInitialSettings_.bind(this); | 17 global['setInitialSettings'] = this.onSetInitialSettings_.bind(this); |
| 18 global['setUseCloudPrint'] = this.onSetUseCloudPrint_.bind(this); | 18 global['setUseCloudPrint'] = this.onSetUseCloudPrint_.bind(this); |
| 19 global['setPrinters'] = this.onSetPrinters_.bind(this); | 19 global['setPrinters'] = this.onSetPrinters_.bind(this); |
| 20 global['updateWithPrinterCapabilities'] = | 20 global['updateWithPrinterCapabilities'] = |
| 21 this.onUpdateWithPrinterCapabilities_.bind(this); | 21 this.onUpdateWithPrinterCapabilities_.bind(this); |
| 22 global['failedToGetPrinterCapabilities'] = |
| 23 this.onFailedToGetPrinterCapabilities_.bind(this); |
| 22 global['reloadPrintersList'] = this.onReloadPrintersList_.bind(this); | 24 global['reloadPrintersList'] = this.onReloadPrintersList_.bind(this); |
| 23 global['printToCloud'] = this.onPrintToCloud_.bind(this); | 25 global['printToCloud'] = this.onPrintToCloud_.bind(this); |
| 24 global['fileSelectionCancelled'] = | 26 global['fileSelectionCancelled'] = |
| 25 this.onFileSelectionCancelled_.bind(this); | 27 this.onFileSelectionCancelled_.bind(this); |
| 26 global['fileSelectionCompleted'] = | 28 global['fileSelectionCompleted'] = |
| 27 this.onFileSelectionCompleted_.bind(this); | 29 this.onFileSelectionCompleted_.bind(this); |
| 28 global['printPreviewFailed'] = this.onPrintPreviewFailed_.bind(this); | 30 global['printPreviewFailed'] = this.onPrintPreviewFailed_.bind(this); |
| 29 global['invalidPrinterSettings'] = | 31 global['invalidPrinterSettings'] = |
| 30 this.onInvalidPrinterSettings_.bind(this); | 32 this.onInvalidPrinterSettings_.bind(this); |
| 31 global['onDidGetDefaultPageLayout'] = | 33 global['onDidGetDefaultPageLayout'] = |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 * destination. | 403 * destination. |
| 402 * @param {Object} settingsInfo printer setting information. | 404 * @param {Object} settingsInfo printer setting information. |
| 403 * @private | 405 * @private |
| 404 */ | 406 */ |
| 405 onUpdateWithPrinterCapabilities_: function(settingsInfo) { | 407 onUpdateWithPrinterCapabilities_: function(settingsInfo) { |
| 406 var capsSetEvent = new cr.Event(NativeLayer.EventType.CAPABILITIES_SET); | 408 var capsSetEvent = new cr.Event(NativeLayer.EventType.CAPABILITIES_SET); |
| 407 capsSetEvent.settingsInfo = settingsInfo; | 409 capsSetEvent.settingsInfo = settingsInfo; |
| 408 this.dispatchEvent(capsSetEvent); | 410 this.dispatchEvent(capsSetEvent); |
| 409 }, | 411 }, |
| 410 | 412 |
| 413 /** |
| 414 * Called when native layer gets settings information for a requested local |
| 415 * destination. |
| 416 * @param {Object} printer_name printer affected by error. |
| 417 * @private |
| 418 */ |
| 419 onFailedToGetPrinterCapabilities_: function(printer_name) { |
| 420 // TODO(rltoscano): Switch to the next printer. |
| 421 console.log('onFailedToGetPrinterCapabilities: ' + printer_name); |
| 422 }, |
| 423 |
| 411 /** Reloads the printer list. */ | 424 /** Reloads the printer list. */ |
| 412 onReloadPrintersList_: function() { | 425 onReloadPrintersList_: function() { |
| 413 cr.dispatchSimpleEvent(this, NativeLayer.EventType.DESTINATIONS_RELOAD); | 426 cr.dispatchSimpleEvent(this, NativeLayer.EventType.DESTINATIONS_RELOAD); |
| 414 }, | 427 }, |
| 415 | 428 |
| 416 /** | 429 /** |
| 417 * Called from the C++ layer. | 430 * Called from the C++ layer. |
| 418 * Take the PDF data handed to us and submit it to the cloud, closing the | 431 * Take the PDF data handed to us and submit it to the cloud, closing the |
| 419 * print preview tab once the upload is successful. | 432 * print preview tab once the upload is successful. |
| 420 * @param {string} data Data to send as the print job. | 433 * @param {string} data Data to send as the print job. |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 return this.initialDestinationId_; | 754 return this.initialDestinationId_; |
| 742 } | 755 } |
| 743 }; | 756 }; |
| 744 | 757 |
| 745 // Export | 758 // Export |
| 746 return { | 759 return { |
| 747 NativeInitialSettings: NativeInitialSettings, | 760 NativeInitialSettings: NativeInitialSettings, |
| 748 NativeLayer: NativeLayer | 761 NativeLayer: NativeLayer |
| 749 }; | 762 }; |
| 750 }); | 763 }); |
| OLD | NEW |