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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 this.onFileSelectionCompleted_.bind(this); | 44 this.onFileSelectionCompleted_.bind(this); |
45 global.printPreviewFailed = this.onPrintPreviewFailed_.bind(this); | 45 global.printPreviewFailed = this.onPrintPreviewFailed_.bind(this); |
46 global.invalidPrinterSettings = | 46 global.invalidPrinterSettings = |
47 this.onInvalidPrinterSettings_.bind(this); | 47 this.onInvalidPrinterSettings_.bind(this); |
48 global.onDidGetDefaultPageLayout = | 48 global.onDidGetDefaultPageLayout = |
49 this.onDidGetDefaultPageLayout_.bind(this); | 49 this.onDidGetDefaultPageLayout_.bind(this); |
50 global.onDidGetPreviewPageCount = | 50 global.onDidGetPreviewPageCount = |
51 this.onDidGetPreviewPageCount_.bind(this); | 51 this.onDidGetPreviewPageCount_.bind(this); |
52 global.onDidPreviewPage = this.onDidPreviewPage_.bind(this); | 52 global.onDidPreviewPage = this.onDidPreviewPage_.bind(this); |
53 global.updatePrintPreview = this.onUpdatePrintPreview_.bind(this); | 53 global.updatePrintPreview = this.onUpdatePrintPreview_.bind(this); |
54 global.printScalingDisabledForSourcePDF = | |
55 this.onPrintScalingDisabledForSourcePDF_.bind(this); | |
56 global.onDidGetAccessToken = this.onDidGetAccessToken_.bind(this); | 54 global.onDidGetAccessToken = this.onDidGetAccessToken_.bind(this); |
57 global.autoCancelForTesting = this.autoCancelForTesting_.bind(this); | 55 global.autoCancelForTesting = this.autoCancelForTesting_.bind(this); |
58 global.onPrivetPrinterChanged = this.onPrivetPrinterChanged_.bind(this); | 56 global.onPrivetPrinterChanged = this.onPrivetPrinterChanged_.bind(this); |
59 global.onPrivetCapabilitiesSet = | 57 global.onPrivetCapabilitiesSet = |
60 this.onPrivetCapabilitiesSet_.bind(this); | 58 this.onPrivetCapabilitiesSet_.bind(this); |
61 global.onPrivetPrintFailed = this.onPrivetPrintFailed_.bind(this); | 59 global.onPrivetPrintFailed = this.onPrivetPrintFailed_.bind(this); |
62 global.onEnableManipulateSettingsForTest = | 60 global.onEnableManipulateSettingsForTest = |
63 this.onEnableManipulateSettingsForTest_.bind(this); | 61 this.onEnableManipulateSettingsForTest_.bind(this); |
| 62 global.printPresetOptionsFromDocument = |
| 63 this.onPrintPresetOptionsFromDocument_.bind(this); |
64 }; | 64 }; |
65 | 65 |
66 /** | 66 /** |
67 * Event types dispatched from the Chromium native layer. | 67 * Event types dispatched from the Chromium native layer. |
68 * @enum {string} | 68 * @enum {string} |
69 * @const | 69 * @const |
70 */ | 70 */ |
71 NativeLayer.EventType = { | 71 NativeLayer.EventType = { |
72 ACCESS_TOKEN_READY: 'print_preview.NativeLayer.ACCESS_TOKEN_READY', | 72 ACCESS_TOKEN_READY: 'print_preview.NativeLayer.ACCESS_TOKEN_READY', |
73 CAPABILITIES_SET: 'print_preview.NativeLayer.CAPABILITIES_SET', | 73 CAPABILITIES_SET: 'print_preview.NativeLayer.CAPABILITIES_SET', |
(...skipping 14 matching lines...) Expand all Loading... |
88 PREVIEW_GENERATION_DONE: | 88 PREVIEW_GENERATION_DONE: |
89 'print_preview.NativeLayer.PREVIEW_GENERATION_DONE', | 89 'print_preview.NativeLayer.PREVIEW_GENERATION_DONE', |
90 PREVIEW_GENERATION_FAIL: | 90 PREVIEW_GENERATION_FAIL: |
91 'print_preview.NativeLayer.PREVIEW_GENERATION_FAIL', | 91 'print_preview.NativeLayer.PREVIEW_GENERATION_FAIL', |
92 PRINT_TO_CLOUD: 'print_preview.NativeLayer.PRINT_TO_CLOUD', | 92 PRINT_TO_CLOUD: 'print_preview.NativeLayer.PRINT_TO_CLOUD', |
93 SETTINGS_INVALID: 'print_preview.NativeLayer.SETTINGS_INVALID', | 93 SETTINGS_INVALID: 'print_preview.NativeLayer.SETTINGS_INVALID', |
94 PRIVET_PRINTER_CHANGED: 'print_preview.NativeLayer.PRIVET_PRINTER_CHANGED', | 94 PRIVET_PRINTER_CHANGED: 'print_preview.NativeLayer.PRIVET_PRINTER_CHANGED', |
95 PRIVET_CAPABILITIES_SET: | 95 PRIVET_CAPABILITIES_SET: |
96 'print_preview.NativeLayer.PRIVET_CAPABILITIES_SET', | 96 'print_preview.NativeLayer.PRIVET_CAPABILITIES_SET', |
97 PRIVET_PRINT_FAILED: 'print_preview.NativeLayer.PRIVET_PRINT_FAILED', | 97 PRIVET_PRINT_FAILED: 'print_preview.NativeLayer.PRIVET_PRINT_FAILED', |
| 98 PRINT_PRESET_OPTIONS: 'print_preview.NativeLayer.PRINT_PRESET_OPTIONS', |
98 }; | 99 }; |
99 | 100 |
100 /** | 101 /** |
101 * Constant values matching printing::DuplexMode enum. | 102 * Constant values matching printing::DuplexMode enum. |
102 * @enum {number} | 103 * @enum {number} |
103 */ | 104 */ |
104 NativeLayer.DuplexMode = { | 105 NativeLayer.DuplexMode = { |
105 SIMPLEX: 0, | 106 SIMPLEX: 0, |
106 LONG_EDGE: 1, | 107 LONG_EDGE: 1, |
107 UNKNOWN_DUPLEX_MODE: -1 | 108 UNKNOWN_DUPLEX_MODE: -1 |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 */ | 646 */ |
646 onUpdatePrintPreview_: function(previewUid, previewResponseId) { | 647 onUpdatePrintPreview_: function(previewUid, previewResponseId) { |
647 var previewGenDoneEvent = new Event( | 648 var previewGenDoneEvent = new Event( |
648 NativeLayer.EventType.PREVIEW_GENERATION_DONE); | 649 NativeLayer.EventType.PREVIEW_GENERATION_DONE); |
649 previewGenDoneEvent.previewUid = previewUid; | 650 previewGenDoneEvent.previewUid = previewUid; |
650 previewGenDoneEvent.previewResponseId = previewResponseId; | 651 previewGenDoneEvent.previewResponseId = previewResponseId; |
651 this.dispatchEvent(previewGenDoneEvent); | 652 this.dispatchEvent(previewGenDoneEvent); |
652 }, | 653 }, |
653 | 654 |
654 /** | 655 /** |
655 * Updates the fit to page option state based on the print scaling option of | 656 * Updates print preset options from source PDF document. |
656 * source pdf. PDF's have an option to enable/disable print scaling. When we | 657 * Called from PrintPreviewUI::OnSetOptionsFromDocument(). |
657 * find out that the print scaling option is disabled for the source pdf, we | 658 * @param {{disableScaling: boolean, copies: number}} options Specifies |
658 * uncheck the fitToPage_ to page checkbox. This function is called from C++ | 659 * printing options according to source document presets. |
659 * code. | |
660 * @private | 660 * @private |
661 */ | 661 */ |
662 onPrintScalingDisabledForSourcePDF_: function() { | 662 onPrintPresetOptionsFromDocument_: function(options) { |
663 cr.dispatchSimpleEvent(this, NativeLayer.EventType.DISABLE_SCALING); | 663 var printPresetOptionsEvent = new Event( |
| 664 NativeLayer.EventType.PRINT_PRESET_OPTIONS); |
| 665 printPresetOptionsEvent.optionsFromDocument = options; |
| 666 this.dispatchEvent(printPresetOptionsEvent); |
664 }, | 667 }, |
665 | 668 |
666 /** | 669 /** |
667 * Simulates a user click on the print preview dialog cancel button. Used | 670 * Simulates a user click on the print preview dialog cancel button. Used |
668 * only for testing. | 671 * only for testing. |
669 * @private | 672 * @private |
670 */ | 673 */ |
671 autoCancelForTesting_: function() { | 674 autoCancelForTesting_: function() { |
672 var properties = {view: window, bubbles: true, cancelable: true}; | 675 var properties = {view: window, bubbles: true, cancelable: true}; |
673 var click = new MouseEvent('click', properties); | 676 var click = new MouseEvent('click', properties); |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
948 return this.serializedAppStateStr_; | 951 return this.serializedAppStateStr_; |
949 } | 952 } |
950 }; | 953 }; |
951 | 954 |
952 // Export | 955 // Export |
953 return { | 956 return { |
954 NativeInitialSettings: NativeInitialSettings, | 957 NativeInitialSettings: NativeInitialSettings, |
955 NativeLayer: NativeLayer | 958 NativeLayer: NativeLayer |
956 }; | 959 }; |
957 }); | 960 }); |
OLD | NEW |