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 11 matching lines...) Expand all Loading... | |
22 * printerDescription: (string | undefined), | 22 * printerDescription: (string | undefined), |
23 * cupsEnterprisePrinter: (boolean | undefined), | 23 * cupsEnterprisePrinter: (boolean | undefined), |
24 * printerOptions: (Object | undefined), | 24 * printerOptions: (Object | undefined), |
25 * }} | 25 * }} |
26 */ | 26 */ |
27 print_preview.LocalDestinationInfo; | 27 print_preview.LocalDestinationInfo; |
28 | 28 |
29 /** | 29 /** |
30 * @typedef {{ | 30 * @typedef {{ |
31 * printerId: string, | 31 * printerId: string, |
32 * printerName: string, | |
33 * printerDescription: string, | |
34 * cupsEnterprisePrinter: (boolean | undefined), | |
35 * capabilities: print_preview.Cdd, | |
dpapad
2017/06/14 17:19:36
Should this be !print_preview.Cdd ?
rbpotter
2017/06/14 18:28:25
Done. Needs to be !print_preview.Cdd as it is pass
| |
36 * }} | |
37 */ | |
38 print_preview.PrinterCapabilitiesResponse; | |
39 | |
40 /** | |
41 * @typedef {{ | |
42 * serviceName: string, | |
43 * name: string, | |
44 * hasLocalPrinting: boolean, | |
45 * isUnregistered: boolean, | |
46 * cloudID: string, | |
47 * }} | |
48 * @see PrintPreviewHandler::FillPrinterDescription in print_preview_handler.cc | |
49 */ | |
50 print_preview.PrivetPrinterDescription; | |
51 | |
52 /** | |
53 * @typedef {{ | |
54 * printer: !print_preview.PrivetPrinterDescription, | |
55 * capabilities: !print_preview.Cdd, | |
56 * }} | |
57 */ | |
58 print_preview.PrivetPrinterCapabilitiesResponse; | |
59 | |
60 /** | |
61 * @typedef {{ | |
62 * printerId: string, | |
32 * success: boolean, | 63 * success: boolean, |
33 * capabilities: Object, | 64 * capabilities: Object, |
34 * }} | 65 * }} |
35 */ | 66 */ |
36 print_preview.PrinterSetupResponse; | 67 print_preview.PrinterSetupResponse; |
37 | 68 |
38 cr.define('print_preview', function() { | 69 cr.define('print_preview', function() { |
39 'use strict'; | 70 'use strict'; |
40 | 71 |
41 /** | 72 /** |
42 * An interface to the native Chromium printing system layer. | 73 * An interface to the native Chromium printing system layer. |
43 * @constructor | 74 * @constructor |
44 */ | 75 */ |
45 function NativeLayer() { | 76 function NativeLayer() { |
46 // Bind global handlers | 77 // Bind global handlers |
47 global.setUseCloudPrint = this.onSetUseCloudPrint_.bind(this); | 78 global.setUseCloudPrint = this.onSetUseCloudPrint_.bind(this); |
48 global.updateWithPrinterCapabilities = | |
49 this.onUpdateWithPrinterCapabilities_.bind(this); | |
50 global.failedToGetPrinterCapabilities = | |
51 this.onFailedToGetPrinterCapabilities_.bind(this); | |
52 global.failedToGetPrivetPrinterCapabilities = | |
53 this.onFailedToGetPrivetPrinterCapabilities_.bind(this); | |
54 global.failedToGetExtensionPrinterCapabilities = | |
55 this.onFailedToGetExtensionPrinterCapabilities_.bind(this); | |
56 global.reloadPrintersList = this.onReloadPrintersList_.bind(this); | 79 global.reloadPrintersList = this.onReloadPrintersList_.bind(this); |
57 global.printToCloud = this.onPrintToCloud_.bind(this); | 80 global.printToCloud = this.onPrintToCloud_.bind(this); |
58 global.fileSelectionCancelled = | 81 global.fileSelectionCancelled = |
59 this.onFileSelectionCancelled_.bind(this); | 82 this.onFileSelectionCancelled_.bind(this); |
60 global.fileSelectionCompleted = | 83 global.fileSelectionCompleted = |
61 this.onFileSelectionCompleted_.bind(this); | 84 this.onFileSelectionCompleted_.bind(this); |
62 global.printPreviewFailed = this.onPrintPreviewFailed_.bind(this); | 85 global.printPreviewFailed = this.onPrintPreviewFailed_.bind(this); |
63 global.invalidPrinterSettings = | 86 global.invalidPrinterSettings = |
64 this.onInvalidPrinterSettings_.bind(this); | 87 this.onInvalidPrinterSettings_.bind(this); |
65 global.onDidGetDefaultPageLayout = | 88 global.onDidGetDefaultPageLayout = |
66 this.onDidGetDefaultPageLayout_.bind(this); | 89 this.onDidGetDefaultPageLayout_.bind(this); |
67 global.onDidGetPreviewPageCount = | 90 global.onDidGetPreviewPageCount = |
68 this.onDidGetPreviewPageCount_.bind(this); | 91 this.onDidGetPreviewPageCount_.bind(this); |
69 global.onDidPreviewPage = this.onDidPreviewPage_.bind(this); | 92 global.onDidPreviewPage = this.onDidPreviewPage_.bind(this); |
70 global.updatePrintPreview = this.onUpdatePrintPreview_.bind(this); | 93 global.updatePrintPreview = this.onUpdatePrintPreview_.bind(this); |
71 global.onDidGetAccessToken = this.onDidGetAccessToken_.bind(this); | 94 global.onDidGetAccessToken = this.onDidGetAccessToken_.bind(this); |
72 global.onPrivetCapabilitiesSet = | |
73 this.onPrivetCapabilitiesSet_.bind(this); | |
74 global.onPrivetPrintFailed = this.onPrivetPrintFailed_.bind(this); | 95 global.onPrivetPrintFailed = this.onPrivetPrintFailed_.bind(this); |
75 global.onExtensionCapabilitiesSet = | |
76 this.onExtensionCapabilitiesSet_.bind(this); | |
77 global.onEnableManipulateSettingsForTest = | 96 global.onEnableManipulateSettingsForTest = |
78 this.onEnableManipulateSettingsForTest_.bind(this); | 97 this.onEnableManipulateSettingsForTest_.bind(this); |
79 global.printPresetOptionsFromDocument = | 98 global.printPresetOptionsFromDocument = |
80 this.onPrintPresetOptionsFromDocument_.bind(this); | 99 this.onPrintPresetOptionsFromDocument_.bind(this); |
81 global.onProvisionalPrinterResolved = | 100 global.onProvisionalPrinterResolved = |
82 this.onProvisionalDestinationResolved_.bind(this); | 101 this.onProvisionalDestinationResolved_.bind(this); |
83 global.failedToResolveProvisionalPrinter = | 102 global.failedToResolveProvisionalPrinter = |
84 this.failedToResolveProvisionalDestination_.bind(this); | 103 this.failedToResolveProvisionalDestination_.bind(this); |
85 | 104 |
86 /** @private {!cr.EventTarget} */ | 105 /** @private {!cr.EventTarget} */ |
(...skipping 21 matching lines...) Expand all Loading... | |
108 currentInstance = instance; | 127 currentInstance = instance; |
109 }; | 128 }; |
110 | 129 |
111 /** | 130 /** |
112 * Event types dispatched from the Chromium native layer. | 131 * Event types dispatched from the Chromium native layer. |
113 * @enum {string} | 132 * @enum {string} |
114 * @const | 133 * @const |
115 */ | 134 */ |
116 NativeLayer.EventType = { | 135 NativeLayer.EventType = { |
117 ACCESS_TOKEN_READY: 'print_preview.NativeLayer.ACCESS_TOKEN_READY', | 136 ACCESS_TOKEN_READY: 'print_preview.NativeLayer.ACCESS_TOKEN_READY', |
118 CAPABILITIES_SET: 'print_preview.NativeLayer.CAPABILITIES_SET', | |
119 CLOUD_PRINT_ENABLE: 'print_preview.NativeLayer.CLOUD_PRINT_ENABLE', | 137 CLOUD_PRINT_ENABLE: 'print_preview.NativeLayer.CLOUD_PRINT_ENABLE', |
120 DESTINATIONS_RELOAD: 'print_preview.NativeLayer.DESTINATIONS_RELOAD', | 138 DESTINATIONS_RELOAD: 'print_preview.NativeLayer.DESTINATIONS_RELOAD', |
121 DISABLE_SCALING: 'print_preview.NativeLayer.DISABLE_SCALING', | 139 DISABLE_SCALING: 'print_preview.NativeLayer.DISABLE_SCALING', |
122 FILE_SELECTION_CANCEL: 'print_preview.NativeLayer.FILE_SELECTION_CANCEL', | 140 FILE_SELECTION_CANCEL: 'print_preview.NativeLayer.FILE_SELECTION_CANCEL', |
123 FILE_SELECTION_COMPLETE: | 141 FILE_SELECTION_COMPLETE: |
124 'print_preview.NativeLayer.FILE_SELECTION_COMPLETE', | 142 'print_preview.NativeLayer.FILE_SELECTION_COMPLETE', |
125 GET_CAPABILITIES_FAIL: 'print_preview.NativeLayer.GET_CAPABILITIES_FAIL', | |
126 MANIPULATE_SETTINGS_FOR_TEST: | 143 MANIPULATE_SETTINGS_FOR_TEST: |
127 'print_preview.NativeLayer.MANIPULATE_SETTINGS_FOR_TEST', | 144 'print_preview.NativeLayer.MANIPULATE_SETTINGS_FOR_TEST', |
128 PAGE_COUNT_READY: 'print_preview.NativeLayer.PAGE_COUNT_READY', | 145 PAGE_COUNT_READY: 'print_preview.NativeLayer.PAGE_COUNT_READY', |
129 PAGE_LAYOUT_READY: 'print_preview.NativeLayer.PAGE_LAYOUT_READY', | 146 PAGE_LAYOUT_READY: 'print_preview.NativeLayer.PAGE_LAYOUT_READY', |
130 PAGE_PREVIEW_READY: 'print_preview.NativeLayer.PAGE_PREVIEW_READY', | 147 PAGE_PREVIEW_READY: 'print_preview.NativeLayer.PAGE_PREVIEW_READY', |
131 PREVIEW_GENERATION_DONE: | 148 PREVIEW_GENERATION_DONE: |
132 'print_preview.NativeLayer.PREVIEW_GENERATION_DONE', | 149 'print_preview.NativeLayer.PREVIEW_GENERATION_DONE', |
133 PREVIEW_GENERATION_FAIL: | 150 PREVIEW_GENERATION_FAIL: |
134 'print_preview.NativeLayer.PREVIEW_GENERATION_FAIL', | 151 'print_preview.NativeLayer.PREVIEW_GENERATION_FAIL', |
135 PRINT_TO_CLOUD: 'print_preview.NativeLayer.PRINT_TO_CLOUD', | 152 PRINT_TO_CLOUD: 'print_preview.NativeLayer.PRINT_TO_CLOUD', |
136 SETTINGS_INVALID: 'print_preview.NativeLayer.SETTINGS_INVALID', | 153 SETTINGS_INVALID: 'print_preview.NativeLayer.SETTINGS_INVALID', |
137 PRIVET_PRINTER_CHANGED: 'print_preview.NativeLayer.PRIVET_PRINTER_CHANGED', | |
138 PRIVET_CAPABILITIES_SET: | |
139 'print_preview.NativeLayer.PRIVET_CAPABILITIES_SET', | |
140 PRIVET_PRINT_FAILED: 'print_preview.NativeLayer.PRIVET_PRINT_FAILED', | 154 PRIVET_PRINT_FAILED: 'print_preview.NativeLayer.PRIVET_PRINT_FAILED', |
141 EXTENSION_CAPABILITIES_SET: | |
142 'print_preview.NativeLayer.EXTENSION_CAPABILITIES_SET', | |
143 PRINT_PRESET_OPTIONS: 'print_preview.NativeLayer.PRINT_PRESET_OPTIONS', | 155 PRINT_PRESET_OPTIONS: 'print_preview.NativeLayer.PRINT_PRESET_OPTIONS', |
144 PROVISIONAL_DESTINATION_RESOLVED: | 156 PROVISIONAL_DESTINATION_RESOLVED: |
145 'print_preview.NativeLayer.PROVISIONAL_DESTINATION_RESOLVED' | 157 'print_preview.NativeLayer.PROVISIONAL_DESTINATION_RESOLVED' |
146 }; | 158 }; |
147 | 159 |
148 /** | 160 /** |
149 * Constant values matching printing::DuplexMode enum. | 161 * Constant values matching printing::DuplexMode enum. |
150 * @enum {number} | 162 * @enum {number} |
151 */ | 163 */ |
152 NativeLayer.DuplexMode = { | 164 NativeLayer.DuplexMode = { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
234 * Requests the network's privet print destinations. After this is called, | 246 * Requests the network's privet print destinations. After this is called, |
235 * a number of privet-printer-changed events may be fired. | 247 * a number of privet-printer-changed events may be fired. |
236 * @return {!Promise} Resolves when privet printer search is completed. | 248 * @return {!Promise} Resolves when privet printer search is completed. |
237 * Rejected if privet printers are not enabled. | 249 * Rejected if privet printers are not enabled. |
238 */ | 250 */ |
239 getPrivetPrinters: function() { | 251 getPrivetPrinters: function() { |
240 return cr.sendWithPromise('getPrivetPrinters'); | 252 return cr.sendWithPromise('getPrivetPrinters'); |
241 }, | 253 }, |
242 | 254 |
243 /** | 255 /** |
244 * Requests the privet destination's printing capabilities. A | |
245 * PRIVET_CAPABILITIES_SET event will be dispatched in response. | |
246 * @param {string} destinationId ID of the destination. | |
247 */ | |
248 startGetPrivetDestinationCapabilities: function(destinationId) { | |
249 chrome.send('getPrivetPrinterCapabilities', [destinationId]); | |
250 }, | |
251 | |
252 /** | |
253 * Request a list of extension printers. Printers are reported as they are | 256 * Request a list of extension printers. Printers are reported as they are |
254 * found by a series of 'extension-printers-added' events. | 257 * found by a series of 'extension-printers-added' events. |
255 * @return {!Promise} Will be resolved when all extension managed printers | 258 * @return {!Promise} Will be resolved when all extension managed printers |
256 * have been sent. | 259 * have been sent. |
257 */ | 260 */ |
258 getExtensionPrinters: function() { | 261 getExtensionPrinters: function() { |
259 return cr.sendWithPromise('getExtensionPrinters'); | 262 return cr.sendWithPromise('getExtensionPrinters'); |
260 }, | 263 }, |
261 | 264 |
262 /** | 265 /** |
263 * Requests an extension destination's printing capabilities. A | 266 * Requests the destination's printing capabilities. Returns a promise that |
264 * EXTENSION_CAPABILITIES_SET event will be dispatched in response. | 267 * will be resolved with the capabilities if they are obtained successfully. |
265 * @param {string} destinationId The ID of the destination whose | 268 * @param {string} destinationId ID of the destination. |
266 * capabilities are requested. | 269 * @return {!Promise<!print_preview.PrinterCapabilitiesResponse>} |
267 */ | 270 */ |
268 startGetExtensionDestinationCapabilities: function(destinationId) { | 271 getPrinterCapabilities: function(destinationId) { |
269 chrome.send('getExtensionPrinterCapabilities', [destinationId]); | 272 return cr.sendWithPromise('getPrinterCapabilities', destinationId); |
270 }, | 273 }, |
271 | 274 |
272 /** | 275 /** |
273 * Requests the destination's printing capabilities. A CAPABILITIES_SET | 276 * Requests the privet destination's printing capabilities. Returns a |
274 * event will be dispatched in response. | 277 * promise that will be resolved with capabilities and printer information |
278 * if capabilities are obtained successfully. | |
275 * @param {string} destinationId ID of the destination. | 279 * @param {string} destinationId ID of the destination. |
280 * @return {!Promise<!print_preview.PrivetPrinterCapabilitiesResponse>} | |
276 */ | 281 */ |
277 startGetLocalDestinationCapabilities: function(destinationId) { | 282 getPrivetPrinterCapabilities: function(destinationId) { |
278 chrome.send('getPrinterCapabilities', [destinationId]); | 283 return cr.sendWithPromise('getPrivetPrinterCapabilities', destinationId); |
279 }, | 284 }, |
280 | 285 |
281 /** | 286 /** |
287 * Requests the extension destination's printing capabilities. Returns a | |
288 * promise that will be resolved with the ID and capabilities if | |
289 * capabilities are obtained successfully. | |
290 * @param {string} destinationId The ID of the destination whose | |
291 * capabilities are requested. | |
292 * @return {!Promise<!print_preview.Cdd>} | |
293 */ | |
294 getExtensionPrinterCapabilities: function(destinationId) { | |
295 return cr.sendWithPromise('getExtensionPrinterCapabilities', | |
296 destinationId); | |
297 }, | |
298 | |
299 /** | |
282 * Requests Chrome to resolve provisional extension destination by granting | 300 * Requests Chrome to resolve provisional extension destination by granting |
283 * the provider extension access to the printer. Chrome will respond with | 301 * the provider extension access to the printer. Chrome will respond with |
284 * the resolved destination properties by calling | 302 * the resolved destination properties by calling |
285 * {@code onProvisionalPrinterResolved}, or in case of an error | 303 * {@code onProvisionalPrinterResolved}, or in case of an error |
286 * {@code failedToResolveProvisionalPrinter} | 304 * {@code failedToResolveProvisionalPrinter} |
287 * @param {string} provisionalDestinationId | 305 * @param {string} provisionalDestinationId |
288 */ | 306 */ |
289 grantExtensionPrinterAccess: function(provisionalDestinationId) { | 307 grantExtensionPrinterAccess: function(provisionalDestinationId) { |
290 chrome.send('grantExtensionPrinterAccess', [provisionalDestinationId]); | 308 chrome.send('grantExtensionPrinterAccess', [provisionalDestinationId]); |
291 }, | 309 }, |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
542 * @private | 560 * @private |
543 */ | 561 */ |
544 onSetUseCloudPrint_: function(settings) { | 562 onSetUseCloudPrint_: function(settings) { |
545 var cloudPrintEnableEvent = new Event( | 563 var cloudPrintEnableEvent = new Event( |
546 NativeLayer.EventType.CLOUD_PRINT_ENABLE); | 564 NativeLayer.EventType.CLOUD_PRINT_ENABLE); |
547 cloudPrintEnableEvent.baseCloudPrintUrl = settings['cloudPrintUrl'] || ''; | 565 cloudPrintEnableEvent.baseCloudPrintUrl = settings['cloudPrintUrl'] || ''; |
548 cloudPrintEnableEvent.appKioskMode = settings['appKioskMode'] || false; | 566 cloudPrintEnableEvent.appKioskMode = settings['appKioskMode'] || false; |
549 this.eventTarget_.dispatchEvent(cloudPrintEnableEvent); | 567 this.eventTarget_.dispatchEvent(cloudPrintEnableEvent); |
550 }, | 568 }, |
551 | 569 |
552 /** | |
553 * Called when native layer gets settings information for a requested local | |
554 * destination. | |
555 * @param {Object} settingsInfo printer setting information. | |
556 * @private | |
557 */ | |
558 onUpdateWithPrinterCapabilities_: function(settingsInfo) { | |
559 assert(settingsInfo.capabilities, | |
560 'Capabilities update without capabilites'); | |
561 var capsSetEvent = new Event(NativeLayer.EventType.CAPABILITIES_SET); | |
562 capsSetEvent.settingsInfo = settingsInfo; | |
563 this.eventTarget_.dispatchEvent(capsSetEvent); | |
564 }, | |
565 | |
566 /** | |
567 * Called when native layer gets settings information for a requested local | |
568 * destination. | |
569 * @param {string} destinationId Printer affected by error. | |
570 * @private | |
571 */ | |
572 onFailedToGetPrinterCapabilities_: function(destinationId) { | |
573 var getCapsFailEvent = new Event( | |
574 NativeLayer.EventType.GET_CAPABILITIES_FAIL); | |
575 getCapsFailEvent.destinationId = destinationId; | |
576 getCapsFailEvent.destinationOrigin = | |
577 print_preview.DestinationOrigin.LOCAL; | |
578 this.eventTarget_.dispatchEvent(getCapsFailEvent); | |
579 }, | |
580 | |
581 /** | |
582 * Called when native layer gets settings information for a requested privet | |
583 * destination. | |
584 * @param {string} destinationId Printer affected by error. | |
585 * @private | |
586 */ | |
587 onFailedToGetPrivetPrinterCapabilities_: function(destinationId) { | |
588 var getCapsFailEvent = new Event( | |
589 NativeLayer.EventType.GET_CAPABILITIES_FAIL); | |
590 getCapsFailEvent.destinationId = destinationId; | |
591 getCapsFailEvent.destinationOrigin = | |
592 print_preview.DestinationOrigin.PRIVET; | |
593 this.eventTarget_.dispatchEvent(getCapsFailEvent); | |
594 }, | |
595 | |
596 /** | |
597 * Called when native layer fails to get settings information for a | |
598 * requested extension destination. | |
599 * @param {string} destinationId Printer affected by error. | |
600 * @private | |
601 */ | |
602 onFailedToGetExtensionPrinterCapabilities_: function(destinationId) { | |
603 var getCapsFailEvent = new Event( | |
604 NativeLayer.EventType.GET_CAPABILITIES_FAIL); | |
605 getCapsFailEvent.destinationId = destinationId; | |
606 getCapsFailEvent.destinationOrigin = | |
607 print_preview.DestinationOrigin.EXTENSION; | |
608 this.eventTarget_.dispatchEvent(getCapsFailEvent); | |
609 }, | |
610 | |
611 /** Reloads the printer list. */ | 570 /** Reloads the printer list. */ |
612 onReloadPrintersList_: function() { | 571 onReloadPrintersList_: function() { |
613 cr.dispatchSimpleEvent(this.eventTarget_, | 572 cr.dispatchSimpleEvent(this.eventTarget_, |
614 NativeLayer.EventType.DESTINATIONS_RELOAD); | 573 NativeLayer.EventType.DESTINATIONS_RELOAD); |
615 }, | 574 }, |
616 | 575 |
617 /** | 576 /** |
618 * Called from the C++ layer. | 577 * Called from the C++ layer. |
619 * Take the PDF data handed to us and submit it to the cloud, closing the | 578 * Take the PDF data handed to us and submit it to the cloud, closing the |
620 * print preview dialog once the upload is successful. | 579 * print preview dialog once the upload is successful. |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
767 * @private | 726 * @private |
768 */ | 727 */ |
769 onPrintPresetOptionsFromDocument_: function(options) { | 728 onPrintPresetOptionsFromDocument_: function(options) { |
770 var printPresetOptionsEvent = new Event( | 729 var printPresetOptionsEvent = new Event( |
771 NativeLayer.EventType.PRINT_PRESET_OPTIONS); | 730 NativeLayer.EventType.PRINT_PRESET_OPTIONS); |
772 printPresetOptionsEvent.optionsFromDocument = options; | 731 printPresetOptionsEvent.optionsFromDocument = options; |
773 this.eventTarget_.dispatchEvent(printPresetOptionsEvent); | 732 this.eventTarget_.dispatchEvent(printPresetOptionsEvent); |
774 }, | 733 }, |
775 | 734 |
776 /** | 735 /** |
777 * @param {Object} printer Specifies information about the printer that was | |
778 * added. | |
779 * @private | |
780 */ | |
781 onPrivetCapabilitiesSet_: function(printer, capabilities) { | |
782 var privetCapabilitiesSetEvent = | |
783 new Event(NativeLayer.EventType.PRIVET_CAPABILITIES_SET); | |
784 privetCapabilitiesSetEvent.printer = printer; | |
785 privetCapabilitiesSetEvent.capabilities = capabilities; | |
786 this.eventTarget_.dispatchEvent(privetCapabilitiesSetEvent); | |
787 }, | |
788 | |
789 /** | |
790 * @param {string} http_error The HTTP response code or -1 if not an HTTP | 736 * @param {string} http_error The HTTP response code or -1 if not an HTTP |
791 * error. | 737 * error. |
792 * @private | 738 * @private |
793 */ | 739 */ |
794 onPrivetPrintFailed_: function(http_error) { | 740 onPrivetPrintFailed_: function(http_error) { |
795 var privetPrintFailedEvent = | 741 var privetPrintFailedEvent = |
796 new Event(NativeLayer.EventType.PRIVET_PRINT_FAILED); | 742 new Event(NativeLayer.EventType.PRIVET_PRINT_FAILED); |
797 privetPrintFailedEvent.httpError = http_error; | 743 privetPrintFailedEvent.httpError = http_error; |
798 this.eventTarget_.dispatchEvent(privetPrintFailedEvent); | 744 this.eventTarget_.dispatchEvent(privetPrintFailedEvent); |
799 }, | 745 }, |
800 | 746 |
801 /** | 747 /** |
802 * Called when an extension responds to a request for an extension printer | |
803 * capabilities. | |
804 * @param {string} printerId The printer's ID. | |
805 * @param {!Object} capabilities The reported printer capabilities. | |
806 */ | |
807 onExtensionCapabilitiesSet_: function(printerId, | |
808 capabilities) { | |
809 var event = new Event(NativeLayer.EventType.EXTENSION_CAPABILITIES_SET); | |
810 event.printerId = printerId; | |
811 event.capabilities = capabilities; | |
812 this.eventTarget_.dispatchEvent(event); | |
813 }, | |
814 | |
815 /** | |
816 * Called when Chrome reports that attempt to resolve a provisional | 748 * Called when Chrome reports that attempt to resolve a provisional |
817 * destination failed. | 749 * destination failed. |
818 * @param {string} destinationId The provisional destination ID. | 750 * @param {string} destinationId The provisional destination ID. |
819 * @private | 751 * @private |
820 */ | 752 */ |
821 failedToResolveProvisionalDestination_: function(destinationId) { | 753 failedToResolveProvisionalDestination_: function(destinationId) { |
822 var evt = new Event( | 754 var evt = new Event( |
823 NativeLayer.EventType.PROVISIONAL_DESTINATION_RESOLVED); | 755 NativeLayer.EventType.PROVISIONAL_DESTINATION_RESOLVED); |
824 evt.provisionalId = destinationId; | 756 evt.provisionalId = destinationId; |
825 evt.destination = null; | 757 evt.destination = null; |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1073 return this.serializedDefaultDestinationSelectionRulesStr_; | 1005 return this.serializedDefaultDestinationSelectionRulesStr_; |
1074 } | 1006 } |
1075 }; | 1007 }; |
1076 | 1008 |
1077 // Export | 1009 // Export |
1078 return { | 1010 return { |
1079 NativeInitialSettings: NativeInitialSettings, | 1011 NativeInitialSettings: NativeInitialSettings, |
1080 NativeLayer: NativeLayer | 1012 NativeLayer: NativeLayer |
1081 }; | 1013 }; |
1082 }); | 1014 }); |
OLD | NEW |