| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 global.printPreviewFailed = this.onPrintPreviewFailed_.bind(this); | 56 global.printPreviewFailed = this.onPrintPreviewFailed_.bind(this); |
| 57 global.invalidPrinterSettings = | 57 global.invalidPrinterSettings = |
| 58 this.onInvalidPrinterSettings_.bind(this); | 58 this.onInvalidPrinterSettings_.bind(this); |
| 59 global.onDidGetDefaultPageLayout = | 59 global.onDidGetDefaultPageLayout = |
| 60 this.onDidGetDefaultPageLayout_.bind(this); | 60 this.onDidGetDefaultPageLayout_.bind(this); |
| 61 global.onDidGetPreviewPageCount = | 61 global.onDidGetPreviewPageCount = |
| 62 this.onDidGetPreviewPageCount_.bind(this); | 62 this.onDidGetPreviewPageCount_.bind(this); |
| 63 global.onDidPreviewPage = this.onDidPreviewPage_.bind(this); | 63 global.onDidPreviewPage = this.onDidPreviewPage_.bind(this); |
| 64 global.updatePrintPreview = this.onUpdatePrintPreview_.bind(this); | 64 global.updatePrintPreview = this.onUpdatePrintPreview_.bind(this); |
| 65 global.onDidGetAccessToken = this.onDidGetAccessToken_.bind(this); | 65 global.onDidGetAccessToken = this.onDidGetAccessToken_.bind(this); |
| 66 global.autoCancelForTesting = this.autoCancelForTesting_.bind(this); | |
| 67 global.onPrivetPrinterChanged = this.onPrivetPrinterChanged_.bind(this); | 66 global.onPrivetPrinterChanged = this.onPrivetPrinterChanged_.bind(this); |
| 68 global.onPrivetCapabilitiesSet = | 67 global.onPrivetCapabilitiesSet = |
| 69 this.onPrivetCapabilitiesSet_.bind(this); | 68 this.onPrivetCapabilitiesSet_.bind(this); |
| 70 global.onPrivetPrintFailed = this.onPrivetPrintFailed_.bind(this); | 69 global.onPrivetPrintFailed = this.onPrivetPrintFailed_.bind(this); |
| 71 global.onExtensionPrintersAdded = | 70 global.onExtensionPrintersAdded = |
| 72 this.onExtensionPrintersAdded_.bind(this); | 71 this.onExtensionPrintersAdded_.bind(this); |
| 73 global.onExtensionCapabilitiesSet = | 72 global.onExtensionCapabilitiesSet = |
| 74 this.onExtensionCapabilitiesSet_.bind(this); | 73 this.onExtensionCapabilitiesSet_.bind(this); |
| 75 global.onEnableManipulateSettingsForTest = | 74 global.onEnableManipulateSettingsForTest = |
| 76 this.onEnableManipulateSettingsForTest_.bind(this); | 75 this.onEnableManipulateSettingsForTest_.bind(this); |
| (...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 * @private | 753 * @private |
| 755 */ | 754 */ |
| 756 onPrintPresetOptionsFromDocument_: function(options) { | 755 onPrintPresetOptionsFromDocument_: function(options) { |
| 757 var printPresetOptionsEvent = new Event( | 756 var printPresetOptionsEvent = new Event( |
| 758 NativeLayer.EventType.PRINT_PRESET_OPTIONS); | 757 NativeLayer.EventType.PRINT_PRESET_OPTIONS); |
| 759 printPresetOptionsEvent.optionsFromDocument = options; | 758 printPresetOptionsEvent.optionsFromDocument = options; |
| 760 this.dispatchEvent(printPresetOptionsEvent); | 759 this.dispatchEvent(printPresetOptionsEvent); |
| 761 }, | 760 }, |
| 762 | 761 |
| 763 /** | 762 /** |
| 764 * Simulates a user click on the print preview dialog cancel button. Used | |
| 765 * only for testing. | |
| 766 * @private | |
| 767 */ | |
| 768 autoCancelForTesting_: function() { | |
| 769 var properties = {view: window, bubbles: true, cancelable: true}; | |
| 770 var click = new MouseEvent('click', properties); | |
| 771 document.querySelector('#print-header .cancel').dispatchEvent(click); | |
| 772 }, | |
| 773 | |
| 774 /** | |
| 775 * @param {{serviceName: string, name: string}} printer Specifies | 763 * @param {{serviceName: string, name: string}} printer Specifies |
| 776 * information about the printer that was added. | 764 * information about the printer that was added. |
| 777 * @private | 765 * @private |
| 778 */ | 766 */ |
| 779 onPrivetPrinterChanged_: function(printer) { | 767 onPrivetPrinterChanged_: function(printer) { |
| 780 var privetPrinterChangedEvent = | 768 var privetPrinterChangedEvent = |
| 781 new Event(NativeLayer.EventType.PRIVET_PRINTER_CHANGED); | 769 new Event(NativeLayer.EventType.PRIVET_PRINTER_CHANGED); |
| 782 privetPrinterChangedEvent.printer = printer; | 770 privetPrinterChangedEvent.printer = printer; |
| 783 this.dispatchEvent(privetPrinterChangedEvent); | 771 this.dispatchEvent(privetPrinterChangedEvent); |
| 784 }, | 772 }, |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1113 return this.serializedDefaultDestinationSelectionRulesStr_; | 1101 return this.serializedDefaultDestinationSelectionRulesStr_; |
| 1114 } | 1102 } |
| 1115 }; | 1103 }; |
| 1116 | 1104 |
| 1117 // Export | 1105 // Export |
| 1118 return { | 1106 return { |
| 1119 NativeInitialSettings: NativeInitialSettings, | 1107 NativeInitialSettings: NativeInitialSettings, |
| 1120 NativeLayer: NativeLayer | 1108 NativeLayer: NativeLayer |
| 1121 }; | 1109 }; |
| 1122 }); | 1110 }); |
| OLD | NEW |