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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 global.printScalingDisabledForSourcePDF = | 54 global.printScalingDisabledForSourcePDF = |
55 this.onPrintScalingDisabledForSourcePDF_.bind(this); | 55 this.onPrintScalingDisabledForSourcePDF_.bind(this); |
56 global.onDidGetAccessToken = this.onDidGetAccessToken_.bind(this); | 56 global.onDidGetAccessToken = this.onDidGetAccessToken_.bind(this); |
57 global.autoCancelForTesting = this.autoCancelForTesting_.bind(this); | 57 global.autoCancelForTesting = this.autoCancelForTesting_.bind(this); |
58 global.onPrivetPrinterChanged = this.onPrivetPrinterChanged_.bind(this); | 58 global.onPrivetPrinterChanged = this.onPrivetPrinterChanged_.bind(this); |
59 global.onPrivetCapabilitiesSet = | 59 global.onPrivetCapabilitiesSet = |
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.onEnableManipulateSettingsForTest = | 62 global.onEnableManipulateSettingsForTest = |
63 this.onEnableManipulateSettingsForTest_.bind(this); | 63 this.onEnableManipulateSettingsForTest_.bind(this); |
| 64 global.printPresetOptionsFromDocument = |
| 65 this.onPrintPresetOptionsFromDocument_.bind(this); |
64 }; | 66 }; |
65 | 67 |
66 /** | 68 /** |
67 * Event types dispatched from the Chromium native layer. | 69 * Event types dispatched from the Chromium native layer. |
68 * @enum {string} | 70 * @enum {string} |
69 * @const | 71 * @const |
70 */ | 72 */ |
71 NativeLayer.EventType = { | 73 NativeLayer.EventType = { |
72 ACCESS_TOKEN_READY: 'print_preview.NativeLayer.ACCESS_TOKEN_READY', | 74 ACCESS_TOKEN_READY: 'print_preview.NativeLayer.ACCESS_TOKEN_READY', |
73 CAPABILITIES_SET: 'print_preview.NativeLayer.CAPABILITIES_SET', | 75 CAPABILITIES_SET: 'print_preview.NativeLayer.CAPABILITIES_SET', |
(...skipping 14 matching lines...) Expand all Loading... |
88 PREVIEW_GENERATION_DONE: | 90 PREVIEW_GENERATION_DONE: |
89 'print_preview.NativeLayer.PREVIEW_GENERATION_DONE', | 91 'print_preview.NativeLayer.PREVIEW_GENERATION_DONE', |
90 PREVIEW_GENERATION_FAIL: | 92 PREVIEW_GENERATION_FAIL: |
91 'print_preview.NativeLayer.PREVIEW_GENERATION_FAIL', | 93 'print_preview.NativeLayer.PREVIEW_GENERATION_FAIL', |
92 PRINT_TO_CLOUD: 'print_preview.NativeLayer.PRINT_TO_CLOUD', | 94 PRINT_TO_CLOUD: 'print_preview.NativeLayer.PRINT_TO_CLOUD', |
93 SETTINGS_INVALID: 'print_preview.NativeLayer.SETTINGS_INVALID', | 95 SETTINGS_INVALID: 'print_preview.NativeLayer.SETTINGS_INVALID', |
94 PRIVET_PRINTER_CHANGED: 'print_preview.NativeLayer.PRIVET_PRINTER_CHANGED', | 96 PRIVET_PRINTER_CHANGED: 'print_preview.NativeLayer.PRIVET_PRINTER_CHANGED', |
95 PRIVET_CAPABILITIES_SET: | 97 PRIVET_CAPABILITIES_SET: |
96 'print_preview.NativeLayer.PRIVET_CAPABILITIES_SET', | 98 'print_preview.NativeLayer.PRIVET_CAPABILITIES_SET', |
97 PRIVET_PRINT_FAILED: 'print_preview.NativeLayer.PRIVET_PRINT_FAILED', | 99 PRIVET_PRINT_FAILED: 'print_preview.NativeLayer.PRIVET_PRINT_FAILED', |
| 100 PRINT_PRESET_OPTIONS: 'print_preview.NativeLayer.PRINT_PRESET_OPTIONS', |
98 }; | 101 }; |
99 | 102 |
100 /** | 103 /** |
101 * Constant values matching printing::DuplexMode enum. | 104 * Constant values matching printing::DuplexMode enum. |
102 * @enum {number} | 105 * @enum {number} |
103 */ | 106 */ |
104 NativeLayer.DuplexMode = { | 107 NativeLayer.DuplexMode = { |
105 SIMPLEX: 0, | 108 SIMPLEX: 0, |
106 LONG_EDGE: 1, | 109 LONG_EDGE: 1, |
107 UNKNOWN_DUPLEX_MODE: -1 | 110 UNKNOWN_DUPLEX_MODE: -1 |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
657 * find out that the print scaling option is disabled for the source pdf, we | 660 * find out that the print scaling option is disabled for the source pdf, we |
658 * uncheck the fitToPage_ to page checkbox. This function is called from C++ | 661 * uncheck the fitToPage_ to page checkbox. This function is called from C++ |
659 * code. | 662 * code. |
660 * @private | 663 * @private |
661 */ | 664 */ |
662 onPrintScalingDisabledForSourcePDF_: function() { | 665 onPrintScalingDisabledForSourcePDF_: function() { |
663 cr.dispatchSimpleEvent(this, NativeLayer.EventType.DISABLE_SCALING); | 666 cr.dispatchSimpleEvent(this, NativeLayer.EventType.DISABLE_SCALING); |
664 }, | 667 }, |
665 | 668 |
666 /** | 669 /** |
| 670 * Update print preset options from source PDF document. |
| 671 * Called from PrintPreviewUI::OnSetOptionsFromDocument(). |
| 672 * @param {object} options Print preset options as mentioned in source |
| 673 * document. |
| 674 * @private |
| 675 */ |
| 676 onPrintPresetOptionsFromDocument_: function(options) { |
| 677 var printPresetOptionsEvent = new Event( |
| 678 NativeLayer.EventType.PRINT_PRESET_OPTIONS); |
| 679 printPresetOptionsEvent.optionsFromDocument = options; |
| 680 this.dispatchEvent(printPresetOptionsEvent); |
| 681 }, |
| 682 |
| 683 /** |
667 * Simulates a user click on the print preview dialog cancel button. Used | 684 * Simulates a user click on the print preview dialog cancel button. Used |
668 * only for testing. | 685 * only for testing. |
669 * @private | 686 * @private |
670 */ | 687 */ |
671 autoCancelForTesting_: function() { | 688 autoCancelForTesting_: function() { |
672 var properties = {view: window, bubbles: true, cancelable: true}; | 689 var properties = {view: window, bubbles: true, cancelable: true}; |
673 var click = new MouseEvent('click', properties); | 690 var click = new MouseEvent('click', properties); |
674 document.querySelector('#print-header .cancel').dispatchEvent(click); | 691 document.querySelector('#print-header .cancel').dispatchEvent(click); |
675 }, | 692 }, |
676 | 693 |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
948 return this.serializedAppStateStr_; | 965 return this.serializedAppStateStr_; |
949 } | 966 } |
950 }; | 967 }; |
951 | 968 |
952 // Export | 969 // Export |
953 return { | 970 return { |
954 NativeInitialSettings: NativeInitialSettings, | 971 NativeInitialSettings: NativeInitialSettings, |
955 NativeLayer: NativeLayer | 972 NativeLayer: NativeLayer |
956 }; | 973 }; |
957 }); | 974 }); |
OLD | NEW |