| 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.exportPath('print_preview'); | 5 cr.exportPath('print_preview'); |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * @typedef {{selectSaveAsPdfDestination: boolean, | 8 * @typedef {{selectSaveAsPdfDestination: boolean, |
| 9 * layoutSettings.portrait: boolean, | 9 * layoutSettings.portrait: boolean, |
| 10 * pageRange: string, | 10 * pageRange: string, |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 this.onPrivetCapabilitiesSet_.bind(this); | 60 this.onPrivetCapabilitiesSet_.bind(this); |
| 61 global.onPrivetPrintFailed = this.onPrivetPrintFailed_.bind(this); | 61 global.onPrivetPrintFailed = this.onPrivetPrintFailed_.bind(this); |
| 62 global.onExtensionPrintersAdded = | 62 global.onExtensionPrintersAdded = |
| 63 this.onExtensionPrintersAdded_.bind(this); | 63 this.onExtensionPrintersAdded_.bind(this); |
| 64 global.onExtensionCapabilitiesSet = | 64 global.onExtensionCapabilitiesSet = |
| 65 this.onExtensionCapabilitiesSet_.bind(this); | 65 this.onExtensionCapabilitiesSet_.bind(this); |
| 66 global.onEnableManipulateSettingsForTest = | 66 global.onEnableManipulateSettingsForTest = |
| 67 this.onEnableManipulateSettingsForTest_.bind(this); | 67 this.onEnableManipulateSettingsForTest_.bind(this); |
| 68 global.printPresetOptionsFromDocument = | 68 global.printPresetOptionsFromDocument = |
| 69 this.onPrintPresetOptionsFromDocument_.bind(this); | 69 this.onPrintPresetOptionsFromDocument_.bind(this); |
| 70 global.onProvisionalDestinationResolved = |
| 71 this.onProvisionalDestinationResolved_.bind(this); |
| 72 global.failedToResolveProvisionalDestination = |
| 73 this.failedToResolveProvisionalDestination_.bind(this); |
| 70 }; | 74 }; |
| 71 | 75 |
| 72 /** | 76 /** |
| 73 * Event types dispatched from the Chromium native layer. | 77 * Event types dispatched from the Chromium native layer. |
| 74 * @enum {string} | 78 * @enum {string} |
| 75 * @const | 79 * @const |
| 76 */ | 80 */ |
| 77 NativeLayer.EventType = { | 81 NativeLayer.EventType = { |
| 78 ACCESS_TOKEN_READY: 'print_preview.NativeLayer.ACCESS_TOKEN_READY', | 82 ACCESS_TOKEN_READY: 'print_preview.NativeLayer.ACCESS_TOKEN_READY', |
| 79 CAPABILITIES_SET: 'print_preview.NativeLayer.CAPABILITIES_SET', | 83 CAPABILITIES_SET: 'print_preview.NativeLayer.CAPABILITIES_SET', |
| (...skipping 19 matching lines...) Expand all Loading... |
| 99 SETTINGS_INVALID: 'print_preview.NativeLayer.SETTINGS_INVALID', | 103 SETTINGS_INVALID: 'print_preview.NativeLayer.SETTINGS_INVALID', |
| 100 PRIVET_PRINTER_CHANGED: 'print_preview.NativeLayer.PRIVET_PRINTER_CHANGED', | 104 PRIVET_PRINTER_CHANGED: 'print_preview.NativeLayer.PRIVET_PRINTER_CHANGED', |
| 101 PRIVET_CAPABILITIES_SET: | 105 PRIVET_CAPABILITIES_SET: |
| 102 'print_preview.NativeLayer.PRIVET_CAPABILITIES_SET', | 106 'print_preview.NativeLayer.PRIVET_CAPABILITIES_SET', |
| 103 PRIVET_PRINT_FAILED: 'print_preview.NativeLayer.PRIVET_PRINT_FAILED', | 107 PRIVET_PRINT_FAILED: 'print_preview.NativeLayer.PRIVET_PRINT_FAILED', |
| 104 EXTENSION_PRINTERS_ADDED: | 108 EXTENSION_PRINTERS_ADDED: |
| 105 'print_preview.NativeLayer.EXTENSION_PRINTERS_ADDED', | 109 'print_preview.NativeLayer.EXTENSION_PRINTERS_ADDED', |
| 106 EXTENSION_CAPABILITIES_SET: | 110 EXTENSION_CAPABILITIES_SET: |
| 107 'print_preview.NativeLayer.EXTENSION_CAPABILITIES_SET', | 111 'print_preview.NativeLayer.EXTENSION_CAPABILITIES_SET', |
| 108 PRINT_PRESET_OPTIONS: 'print_preview.NativeLayer.PRINT_PRESET_OPTIONS', | 112 PRINT_PRESET_OPTIONS: 'print_preview.NativeLayer.PRINT_PRESET_OPTIONS', |
| 113 EXTENSION_USB_PRINTER_RESOLVED: |
| 114 'print_preview.NativeLayer.EXTENSION_USB_PRINTER_RESOLVED' |
| 109 }; | 115 }; |
| 110 | 116 |
| 111 /** | 117 /** |
| 112 * Constant values matching printing::DuplexMode enum. | 118 * Constant values matching printing::DuplexMode enum. |
| 113 * @enum {number} | 119 * @enum {number} |
| 114 */ | 120 */ |
| 115 NativeLayer.DuplexMode = { | 121 NativeLayer.DuplexMode = { |
| 116 SIMPLEX: 0, | 122 SIMPLEX: 0, |
| 117 LONG_EDGE: 1, | 123 LONG_EDGE: 1, |
| 118 UNKNOWN_DUPLEX_MODE: -1 | 124 UNKNOWN_DUPLEX_MODE: -1 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 /** | 213 /** |
| 208 * Requests the destination's printing capabilities. A CAPABILITIES_SET | 214 * Requests the destination's printing capabilities. A CAPABILITIES_SET |
| 209 * event will be dispatched in response. | 215 * event will be dispatched in response. |
| 210 * @param {string} destinationId ID of the destination. | 216 * @param {string} destinationId ID of the destination. |
| 211 */ | 217 */ |
| 212 startGetLocalDestinationCapabilities: function(destinationId) { | 218 startGetLocalDestinationCapabilities: function(destinationId) { |
| 213 chrome.send('getPrinterCapabilities', [destinationId]); | 219 chrome.send('getPrinterCapabilities', [destinationId]); |
| 214 }, | 220 }, |
| 215 | 221 |
| 216 /** | 222 /** |
| 223 * @param {string} provisionalDestinationId |
| 224 * @param {string} extensionId |
| 225 * @param {!number} usbId |
| 226 */ |
| 227 grantUsbExtensionPermission: |
| 228 function(provisionalDestinationId, extensionId, usbId) { |
| 229 chrome.send('grantExtensionUsbPrinterAccess', |
| 230 [provisionalDestinationId, extensionId, usbId]); |
| 231 }, |
| 232 |
| 233 /** |
| 217 * @param {!print_preview.Destination} destination Destination to print to. | 234 * @param {!print_preview.Destination} destination Destination to print to. |
| 218 * @param {!print_preview.ticket_items.Color} color Color ticket item. | 235 * @param {!print_preview.ticket_items.Color} color Color ticket item. |
| 219 * @return {number} Native layer color model. | 236 * @return {number} Native layer color model. |
| 220 * @private | 237 * @private |
| 221 */ | 238 */ |
| 222 getNativeColorModel_: function(destination, color) { | 239 getNativeColorModel_: function(destination, color) { |
| 223 // For non-local printers native color model is ignored anyway. | 240 // For non-local printers native color model is ignored anyway. |
| 224 var option = destination.isLocal ? color.getSelectedOption() : null; | 241 var option = destination.isLocal ? color.getSelectedOption() : null; |
| 225 var nativeColorModel = parseInt(option ? option.vendor_id : null, 10); | 242 var nativeColorModel = parseInt(option ? option.vendor_id : null, 10); |
| 226 if (isNaN(nativeColorModel)) { | 243 if (isNaN(nativeColorModel)) { |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 */ | 539 */ |
| 523 onFailedToGetPrinterCapabilities_: function(destinationId) { | 540 onFailedToGetPrinterCapabilities_: function(destinationId) { |
| 524 var getCapsFailEvent = new Event( | 541 var getCapsFailEvent = new Event( |
| 525 NativeLayer.EventType.GET_CAPABILITIES_FAIL); | 542 NativeLayer.EventType.GET_CAPABILITIES_FAIL); |
| 526 getCapsFailEvent.destinationId = destinationId; | 543 getCapsFailEvent.destinationId = destinationId; |
| 527 getCapsFailEvent.destinationOrigin = | 544 getCapsFailEvent.destinationOrigin = |
| 528 print_preview.Destination.Origin.LOCAL; | 545 print_preview.Destination.Origin.LOCAL; |
| 529 this.dispatchEvent(getCapsFailEvent); | 546 this.dispatchEvent(getCapsFailEvent); |
| 530 }, | 547 }, |
| 531 | 548 |
| 549 failedToResolveProvisionalDestination_: function(provisionalDestinationId) { |
| 550 var evt = new Event( |
| 551 NativeLayer.EventType.EXTENSION_USB_PRINTER_RESOLVED); |
| 552 evt.provisionalId = provisionalDestinationId; |
| 553 evt.destination = null; |
| 554 this.dispatchEvent(evt); |
| 555 }, |
| 556 |
| 557 onProvisionalDestinationResolved_: function(provisionalDestinationId, |
| 558 destinationInfo) { |
| 559 var evt = new Event( |
| 560 NativeLayer.EventType.EXTENSION_USB_PRINTER_RESOLVED); |
| 561 evt.provisionalId = provisionalDestinationId; |
| 562 evt.destination = destinationInfo; |
| 563 this.dispatchEvent(evt); |
| 564 }, |
| 565 |
| 532 /** | 566 /** |
| 533 * Called when native layer gets settings information for a requested privet | 567 * Called when native layer gets settings information for a requested privet |
| 534 * destination. | 568 * destination. |
| 535 * @param {string} destinationId Printer affected by error. | 569 * @param {string} destinationId Printer affected by error. |
| 536 * @private | 570 * @private |
| 537 */ | 571 */ |
| 538 onFailedToGetPrivetPrinterCapabilities_: function(destinationId) { | 572 onFailedToGetPrivetPrinterCapabilities_: function(destinationId) { |
| 539 var getCapsFailEvent = new Event( | 573 var getCapsFailEvent = new Event( |
| 540 NativeLayer.EventType.GET_CAPABILITIES_FAIL); | 574 NativeLayer.EventType.GET_CAPABILITIES_FAIL); |
| 541 getCapsFailEvent.destinationId = destinationId; | 575 getCapsFailEvent.destinationId = destinationId; |
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1033 return this.serializedAppStateStr_; | 1067 return this.serializedAppStateStr_; |
| 1034 } | 1068 } |
| 1035 }; | 1069 }; |
| 1036 | 1070 |
| 1037 // Export | 1071 // Export |
| 1038 return { | 1072 return { |
| 1039 NativeInitialSettings: NativeInitialSettings, | 1073 NativeInitialSettings: NativeInitialSettings, |
| 1040 NativeLayer: NativeLayer | 1074 NativeLayer: NativeLayer |
| 1041 }; | 1075 }; |
| 1042 }); | 1076 }); |
| OLD | NEW |