| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 this.onDidGetDefaultPageLayout_.bind(this); | 66 this.onDidGetDefaultPageLayout_.bind(this); |
| 67 global.onDidGetPreviewPageCount = | 67 global.onDidGetPreviewPageCount = |
| 68 this.onDidGetPreviewPageCount_.bind(this); | 68 this.onDidGetPreviewPageCount_.bind(this); |
| 69 global.onDidPreviewPage = this.onDidPreviewPage_.bind(this); | 69 global.onDidPreviewPage = this.onDidPreviewPage_.bind(this); |
| 70 global.updatePrintPreview = this.onUpdatePrintPreview_.bind(this); | 70 global.updatePrintPreview = this.onUpdatePrintPreview_.bind(this); |
| 71 global.onDidGetAccessToken = this.onDidGetAccessToken_.bind(this); | 71 global.onDidGetAccessToken = this.onDidGetAccessToken_.bind(this); |
| 72 global.onPrivetPrinterChanged = this.onPrivetPrinterChanged_.bind(this); | 72 global.onPrivetPrinterChanged = this.onPrivetPrinterChanged_.bind(this); |
| 73 global.onPrivetCapabilitiesSet = | 73 global.onPrivetCapabilitiesSet = |
| 74 this.onPrivetCapabilitiesSet_.bind(this); | 74 this.onPrivetCapabilitiesSet_.bind(this); |
| 75 global.onPrivetPrintFailed = this.onPrivetPrintFailed_.bind(this); | 75 global.onPrivetPrintFailed = this.onPrivetPrintFailed_.bind(this); |
| 76 global.onExtensionPrintersAdded = | |
| 77 this.onExtensionPrintersAdded_.bind(this); | |
| 78 global.onExtensionCapabilitiesSet = | 76 global.onExtensionCapabilitiesSet = |
| 79 this.onExtensionCapabilitiesSet_.bind(this); | 77 this.onExtensionCapabilitiesSet_.bind(this); |
| 80 global.onEnableManipulateSettingsForTest = | 78 global.onEnableManipulateSettingsForTest = |
| 81 this.onEnableManipulateSettingsForTest_.bind(this); | 79 this.onEnableManipulateSettingsForTest_.bind(this); |
| 82 global.printPresetOptionsFromDocument = | 80 global.printPresetOptionsFromDocument = |
| 83 this.onPrintPresetOptionsFromDocument_.bind(this); | 81 this.onPrintPresetOptionsFromDocument_.bind(this); |
| 84 global.onProvisionalPrinterResolved = | 82 global.onProvisionalPrinterResolved = |
| 85 this.onProvisionalDestinationResolved_.bind(this); | 83 this.onProvisionalDestinationResolved_.bind(this); |
| 86 global.failedToResolveProvisionalPrinter = | 84 global.failedToResolveProvisionalPrinter = |
| 87 this.failedToResolveProvisionalDestination_.bind(this); | 85 this.failedToResolveProvisionalDestination_.bind(this); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 PREVIEW_GENERATION_DONE: | 133 PREVIEW_GENERATION_DONE: |
| 136 'print_preview.NativeLayer.PREVIEW_GENERATION_DONE', | 134 'print_preview.NativeLayer.PREVIEW_GENERATION_DONE', |
| 137 PREVIEW_GENERATION_FAIL: | 135 PREVIEW_GENERATION_FAIL: |
| 138 'print_preview.NativeLayer.PREVIEW_GENERATION_FAIL', | 136 'print_preview.NativeLayer.PREVIEW_GENERATION_FAIL', |
| 139 PRINT_TO_CLOUD: 'print_preview.NativeLayer.PRINT_TO_CLOUD', | 137 PRINT_TO_CLOUD: 'print_preview.NativeLayer.PRINT_TO_CLOUD', |
| 140 SETTINGS_INVALID: 'print_preview.NativeLayer.SETTINGS_INVALID', | 138 SETTINGS_INVALID: 'print_preview.NativeLayer.SETTINGS_INVALID', |
| 141 PRIVET_PRINTER_CHANGED: 'print_preview.NativeLayer.PRIVET_PRINTER_CHANGED', | 139 PRIVET_PRINTER_CHANGED: 'print_preview.NativeLayer.PRIVET_PRINTER_CHANGED', |
| 142 PRIVET_CAPABILITIES_SET: | 140 PRIVET_CAPABILITIES_SET: |
| 143 'print_preview.NativeLayer.PRIVET_CAPABILITIES_SET', | 141 'print_preview.NativeLayer.PRIVET_CAPABILITIES_SET', |
| 144 PRIVET_PRINT_FAILED: 'print_preview.NativeLayer.PRIVET_PRINT_FAILED', | 142 PRIVET_PRINT_FAILED: 'print_preview.NativeLayer.PRIVET_PRINT_FAILED', |
| 145 EXTENSION_PRINTERS_ADDED: | |
| 146 'print_preview.NativeLayer.EXTENSION_PRINTERS_ADDED', | |
| 147 EXTENSION_CAPABILITIES_SET: | 143 EXTENSION_CAPABILITIES_SET: |
| 148 'print_preview.NativeLayer.EXTENSION_CAPABILITIES_SET', | 144 'print_preview.NativeLayer.EXTENSION_CAPABILITIES_SET', |
| 149 PRINT_PRESET_OPTIONS: 'print_preview.NativeLayer.PRINT_PRESET_OPTIONS', | 145 PRINT_PRESET_OPTIONS: 'print_preview.NativeLayer.PRINT_PRESET_OPTIONS', |
| 150 PROVISIONAL_DESTINATION_RESOLVED: | 146 PROVISIONAL_DESTINATION_RESOLVED: |
| 151 'print_preview.NativeLayer.PROVISIONAL_DESTINATION_RESOLVED' | 147 'print_preview.NativeLayer.PROVISIONAL_DESTINATION_RESOLVED' |
| 152 }; | 148 }; |
| 153 | 149 |
| 154 /** | 150 /** |
| 155 * Constant values matching printing::DuplexMode enum. | 151 * Constant values matching printing::DuplexMode enum. |
| 156 * @enum {number} | 152 * @enum {number} |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 * PRIVET_CAPABILITIES_SET event will be dispatched in response. | 254 * PRIVET_CAPABILITIES_SET event will be dispatched in response. |
| 259 * @param {string} destinationId ID of the destination. | 255 * @param {string} destinationId ID of the destination. |
| 260 */ | 256 */ |
| 261 startGetPrivetDestinationCapabilities: function(destinationId) { | 257 startGetPrivetDestinationCapabilities: function(destinationId) { |
| 262 chrome.send('getPrivetPrinterCapabilities', [destinationId]); | 258 chrome.send('getPrivetPrinterCapabilities', [destinationId]); |
| 263 }, | 259 }, |
| 264 | 260 |
| 265 /** | 261 /** |
| 266 * Requests that extension system dispatches an event requesting the list of | 262 * Requests that extension system dispatches an event requesting the list of |
| 267 * extension managed printers. | 263 * extension managed printers. |
| 264 * @return {!Promise<boolean>} Will be resolved when all extension managed |
| 265 * printers have been sent. |
| 268 */ | 266 */ |
| 269 startGetExtensionDestinations: function() { | 267 getExtensionPrinters: function() { |
| 270 chrome.send('getExtensionPrinters'); | 268 return cr.sendWithPromise('getExtensionPrinters'); |
| 271 }, | 269 }, |
| 272 | 270 |
| 273 /** | 271 /** |
| 274 * Requests an extension destination's printing capabilities. A | 272 * Requests an extension destination's printing capabilities. A |
| 275 * EXTENSION_CAPABILITIES_SET event will be dispatched in response. | 273 * EXTENSION_CAPABILITIES_SET event will be dispatched in response. |
| 276 * @param {string} destinationId The ID of the destination whose | 274 * @param {string} destinationId The ID of the destination whose |
| 277 * capabilities are requested. | 275 * capabilities are requested. |
| 278 */ | 276 */ |
| 279 startGetExtensionDestinationCapabilities: function(destinationId) { | 277 startGetExtensionDestinationCapabilities: function(destinationId) { |
| 280 chrome.send('getExtensionPrinterCapabilities', [destinationId]); | 278 chrome.send('getExtensionPrinterCapabilities', [destinationId]); |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 815 * @private | 813 * @private |
| 816 */ | 814 */ |
| 817 onPrivetPrintFailed_: function(http_error) { | 815 onPrivetPrintFailed_: function(http_error) { |
| 818 var privetPrintFailedEvent = | 816 var privetPrintFailedEvent = |
| 819 new Event(NativeLayer.EventType.PRIVET_PRINT_FAILED); | 817 new Event(NativeLayer.EventType.PRIVET_PRINT_FAILED); |
| 820 privetPrintFailedEvent.httpError = http_error; | 818 privetPrintFailedEvent.httpError = http_error; |
| 821 this.eventTarget_.dispatchEvent(privetPrintFailedEvent); | 819 this.eventTarget_.dispatchEvent(privetPrintFailedEvent); |
| 822 }, | 820 }, |
| 823 | 821 |
| 824 /** | 822 /** |
| 825 * @param {Array<!{extensionId: string, | |
| 826 * extensionName: string, | |
| 827 * id: string, | |
| 828 * name: string, | |
| 829 * description: (string|undefined), | |
| 830 * provisional: (boolean|undefined)}>} printers The list | |
| 831 * containing information about printers added by an extension. | |
| 832 * @param {boolean} done Whether this is the final list of extension | |
| 833 * managed printers. | |
| 834 */ | |
| 835 onExtensionPrintersAdded_: function(printers, done) { | |
| 836 var event = new Event(NativeLayer.EventType.EXTENSION_PRINTERS_ADDED); | |
| 837 event.printers = printers; | |
| 838 event.done = done; | |
| 839 this.eventTarget_.dispatchEvent(event); | |
| 840 }, | |
| 841 | |
| 842 /** | |
| 843 * Called when an extension responds to a request for an extension printer | 823 * Called when an extension responds to a request for an extension printer |
| 844 * capabilities. | 824 * capabilities. |
| 845 * @param {string} printerId The printer's ID. | 825 * @param {string} printerId The printer's ID. |
| 846 * @param {!Object} capabilities The reported printer capabilities. | 826 * @param {!Object} capabilities The reported printer capabilities. |
| 847 */ | 827 */ |
| 848 onExtensionCapabilitiesSet_: function(printerId, | 828 onExtensionCapabilitiesSet_: function(printerId, |
| 849 capabilities) { | 829 capabilities) { |
| 850 var event = new Event(NativeLayer.EventType.EXTENSION_CAPABILITIES_SET); | 830 var event = new Event(NativeLayer.EventType.EXTENSION_CAPABILITIES_SET); |
| 851 event.printerId = printerId; | 831 event.printerId = printerId; |
| 852 event.capabilities = capabilities; | 832 event.capabilities = capabilities; |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1114 return this.serializedDefaultDestinationSelectionRulesStr_; | 1094 return this.serializedDefaultDestinationSelectionRulesStr_; |
| 1115 } | 1095 } |
| 1116 }; | 1096 }; |
| 1117 | 1097 |
| 1118 // Export | 1098 // Export |
| 1119 return { | 1099 return { |
| 1120 NativeInitialSettings: NativeInitialSettings, | 1100 NativeInitialSettings: NativeInitialSettings, |
| 1121 NativeLayer: NativeLayer | 1101 NativeLayer: NativeLayer |
| 1122 }; | 1102 }; |
| 1123 }); | 1103 }); |
| OLD | NEW |