| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 global.printPreviewFailed = this.onPrintPreviewFailed_.bind(this); | 62 global.printPreviewFailed = this.onPrintPreviewFailed_.bind(this); |
| 63 global.invalidPrinterSettings = | 63 global.invalidPrinterSettings = |
| 64 this.onInvalidPrinterSettings_.bind(this); | 64 this.onInvalidPrinterSettings_.bind(this); |
| 65 global.onDidGetDefaultPageLayout = | 65 global.onDidGetDefaultPageLayout = |
| 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); | |
| 73 global.onPrivetCapabilitiesSet = | 72 global.onPrivetCapabilitiesSet = |
| 74 this.onPrivetCapabilitiesSet_.bind(this); | 73 this.onPrivetCapabilitiesSet_.bind(this); |
| 75 global.onPrivetPrintFailed = this.onPrivetPrintFailed_.bind(this); | 74 global.onPrivetPrintFailed = this.onPrivetPrintFailed_.bind(this); |
| 76 global.onExtensionCapabilitiesSet = | 75 global.onExtensionCapabilitiesSet = |
| 77 this.onExtensionCapabilitiesSet_.bind(this); | 76 this.onExtensionCapabilitiesSet_.bind(this); |
| 78 global.onEnableManipulateSettingsForTest = | 77 global.onEnableManipulateSettingsForTest = |
| 79 this.onEnableManipulateSettingsForTest_.bind(this); | 78 this.onEnableManipulateSettingsForTest_.bind(this); |
| 80 global.printPresetOptionsFromDocument = | 79 global.printPresetOptionsFromDocument = |
| 81 this.onPrintPresetOptionsFromDocument_.bind(this); | 80 this.onPrintPresetOptionsFromDocument_.bind(this); |
| 82 global.onProvisionalPrinterResolved = | 81 global.onProvisionalPrinterResolved = |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 /** | 225 /** |
| 227 * Requests the system's local print destinations. A LOCAL_DESTINATIONS_SET | 226 * Requests the system's local print destinations. A LOCAL_DESTINATIONS_SET |
| 228 * event will be dispatched in response. | 227 * event will be dispatched in response. |
| 229 * @return {!Promise<!Array<print_preview.LocalDestinationInfo>>} | 228 * @return {!Promise<!Array<print_preview.LocalDestinationInfo>>} |
| 230 */ | 229 */ |
| 231 getPrinters: function() { | 230 getPrinters: function() { |
| 232 return cr.sendWithPromise('getPrinters'); | 231 return cr.sendWithPromise('getPrinters'); |
| 233 }, | 232 }, |
| 234 | 233 |
| 235 /** | 234 /** |
| 236 * Requests the network's privet print destinations. A number of | 235 * Requests the network's privet print destinations. After this is called, |
| 237 * PRIVET_PRINTER_CHANGED events will be fired in response, followed by a | 236 * a number of privet-printer-changed events may be fired. |
| 238 * PRIVET_SEARCH_ENDED. | 237 * @return {!Promise} Resolves when privet printer search is completed. |
| 238 * Rejected if privet printers are not enabled. |
| 239 */ | 239 */ |
| 240 startGetPrivetDestinations: function() { | 240 getPrivetPrinters: function() { |
| 241 chrome.send('getPrivetPrinters'); | 241 return cr.sendWithPromise('getPrivetPrinters'); |
| 242 }, | 242 }, |
| 243 | 243 |
| 244 /** | 244 /** |
| 245 * Requests that the privet print stack stop searching for privet print | |
| 246 * destinations. | |
| 247 */ | |
| 248 stopGetPrivetDestinations: function() { | |
| 249 chrome.send('stopGetPrivetPrinters'); | |
| 250 }, | |
| 251 | |
| 252 /** | |
| 253 * Requests the privet destination's printing capabilities. A | 245 * Requests the privet destination's printing capabilities. A |
| 254 * PRIVET_CAPABILITIES_SET event will be dispatched in response. | 246 * PRIVET_CAPABILITIES_SET event will be dispatched in response. |
| 255 * @param {string} destinationId ID of the destination. | 247 * @param {string} destinationId ID of the destination. |
| 256 */ | 248 */ |
| 257 startGetPrivetDestinationCapabilities: function(destinationId) { | 249 startGetPrivetDestinationCapabilities: function(destinationId) { |
| 258 chrome.send('getPrivetPrinterCapabilities', [destinationId]); | 250 chrome.send('getPrivetPrinterCapabilities', [destinationId]); |
| 259 }, | 251 }, |
| 260 | 252 |
| 261 /** | 253 /** |
| 262 * Request a list of extension printers. Printers are reported as they are | 254 * Request a list of extension printers. Printers are reported as they are |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 * @private | 768 * @private |
| 777 */ | 769 */ |
| 778 onPrintPresetOptionsFromDocument_: function(options) { | 770 onPrintPresetOptionsFromDocument_: function(options) { |
| 779 var printPresetOptionsEvent = new Event( | 771 var printPresetOptionsEvent = new Event( |
| 780 NativeLayer.EventType.PRINT_PRESET_OPTIONS); | 772 NativeLayer.EventType.PRINT_PRESET_OPTIONS); |
| 781 printPresetOptionsEvent.optionsFromDocument = options; | 773 printPresetOptionsEvent.optionsFromDocument = options; |
| 782 this.eventTarget_.dispatchEvent(printPresetOptionsEvent); | 774 this.eventTarget_.dispatchEvent(printPresetOptionsEvent); |
| 783 }, | 775 }, |
| 784 | 776 |
| 785 /** | 777 /** |
| 786 * @param {{serviceName: string, name: string}} printer Specifies | |
| 787 * information about the printer that was added. | |
| 788 * @private | |
| 789 */ | |
| 790 onPrivetPrinterChanged_: function(printer) { | |
| 791 var privetPrinterChangedEvent = | |
| 792 new Event(NativeLayer.EventType.PRIVET_PRINTER_CHANGED); | |
| 793 privetPrinterChangedEvent.printer = printer; | |
| 794 this.eventTarget_.dispatchEvent(privetPrinterChangedEvent); | |
| 795 }, | |
| 796 | |
| 797 /** | |
| 798 * @param {Object} printer Specifies information about the printer that was | 778 * @param {Object} printer Specifies information about the printer that was |
| 799 * added. | 779 * added. |
| 800 * @private | 780 * @private |
| 801 */ | 781 */ |
| 802 onPrivetCapabilitiesSet_: function(printer, capabilities) { | 782 onPrivetCapabilitiesSet_: function(printer, capabilities) { |
| 803 var privetCapabilitiesSetEvent = | 783 var privetCapabilitiesSetEvent = |
| 804 new Event(NativeLayer.EventType.PRIVET_CAPABILITIES_SET); | 784 new Event(NativeLayer.EventType.PRIVET_CAPABILITIES_SET); |
| 805 privetCapabilitiesSetEvent.printer = printer; | 785 privetCapabilitiesSetEvent.printer = printer; |
| 806 privetCapabilitiesSetEvent.capabilities = capabilities; | 786 privetCapabilitiesSetEvent.capabilities = capabilities; |
| 807 this.eventTarget_.dispatchEvent(privetCapabilitiesSetEvent); | 787 this.eventTarget_.dispatchEvent(privetCapabilitiesSetEvent); |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1094 return this.serializedDefaultDestinationSelectionRulesStr_; | 1074 return this.serializedDefaultDestinationSelectionRulesStr_; |
| 1095 } | 1075 } |
| 1096 }; | 1076 }; |
| 1097 | 1077 |
| 1098 // Export | 1078 // Export |
| 1099 return { | 1079 return { |
| 1100 NativeInitialSettings: NativeInitialSettings, | 1080 NativeInitialSettings: NativeInitialSettings, |
| 1101 NativeLayer: NativeLayer | 1081 NativeLayer: NativeLayer |
| 1102 }; | 1082 }; |
| 1103 }); | 1083 }); |
| OLD | NEW |