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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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.onExtensionPrintersAdded = | 62 global.onExtensionPrintersAdded = |
63 this.onExtensionPrintersAdded_.bind(this); | 63 this.onExtensionPrintersAdded_.bind(this); |
64 global.onExtensionCapabilitiesSet = | 64 global.onExtensionCapabilitiesSet = |
65 this.onExtensionCapabilitiesSet_.bind(this); | 65 this.onExtensionCapabilitiesSet_.bind(this); |
66 global.onEnableManipulateSettingsForTest = | 66 global.onEnableManipulateSettingsForTest = |
67 this.onEnableManipulateSettingsForTest_.bind(this); | 67 this.onEnableManipulateSettingsForTest_.bind(this); |
68 global.printPresetOptionsFromDocument = | 68 global.printPresetOptionsFromDocument = |
69 this.onPrintPresetOptionsFromDocument_.bind(this); | 69 this.onPrintPresetOptionsFromDocument_.bind(this); |
| 70 global.detectDistillablePage = |
| 71 this.detectDistillablePage_.bind(this); |
70 global.onProvisionalPrinterResolved = | 72 global.onProvisionalPrinterResolved = |
71 this.onProvisionalDestinationResolved_.bind(this); | 73 this.onProvisionalDestinationResolved_.bind(this); |
72 global.failedToResolveProvisionalPrinter = | 74 global.failedToResolveProvisionalPrinter = |
73 this.failedToResolveProvisionalDestination_.bind(this); | 75 this.failedToResolveProvisionalDestination_.bind(this); |
74 }; | 76 }; |
75 | 77 |
76 /** | 78 /** |
77 * Event types dispatched from the Chromium native layer. | 79 * Event types dispatched from the Chromium native layer. |
78 * @enum {string} | 80 * @enum {string} |
79 * @const | 81 * @const |
80 */ | 82 */ |
81 NativeLayer.EventType = { | 83 NativeLayer.EventType = { |
82 ACCESS_TOKEN_READY: 'print_preview.NativeLayer.ACCESS_TOKEN_READY', | 84 ACCESS_TOKEN_READY: 'print_preview.NativeLayer.ACCESS_TOKEN_READY', |
| 85 ALLOW_DISTILL_PAGE: 'print_preview.NativeLayer.ALLOW_DISTILL_PAGE', |
83 CAPABILITIES_SET: 'print_preview.NativeLayer.CAPABILITIES_SET', | 86 CAPABILITIES_SET: 'print_preview.NativeLayer.CAPABILITIES_SET', |
84 CLOUD_PRINT_ENABLE: 'print_preview.NativeLayer.CLOUD_PRINT_ENABLE', | 87 CLOUD_PRINT_ENABLE: 'print_preview.NativeLayer.CLOUD_PRINT_ENABLE', |
85 DESTINATIONS_RELOAD: 'print_preview.NativeLayer.DESTINATIONS_RELOAD', | 88 DESTINATIONS_RELOAD: 'print_preview.NativeLayer.DESTINATIONS_RELOAD', |
86 DISABLE_SCALING: 'print_preview.NativeLayer.DISABLE_SCALING', | 89 DISABLE_SCALING: 'print_preview.NativeLayer.DISABLE_SCALING', |
87 FILE_SELECTION_CANCEL: 'print_preview.NativeLayer.FILE_SELECTION_CANCEL', | 90 FILE_SELECTION_CANCEL: 'print_preview.NativeLayer.FILE_SELECTION_CANCEL', |
88 FILE_SELECTION_COMPLETE: | 91 FILE_SELECTION_COMPLETE: |
89 'print_preview.NativeLayer.FILE_SELECTION_COMPLETE', | 92 'print_preview.NativeLayer.FILE_SELECTION_COMPLETE', |
90 GET_CAPABILITIES_FAIL: 'print_preview.NativeLayer.GET_CAPABILITIES_FAIL', | 93 GET_CAPABILITIES_FAIL: 'print_preview.NativeLayer.GET_CAPABILITIES_FAIL', |
91 INITIAL_SETTINGS_SET: 'print_preview.NativeLayer.INITIAL_SETTINGS_SET', | 94 INITIAL_SETTINGS_SET: 'print_preview.NativeLayer.INITIAL_SETTINGS_SET', |
92 LOCAL_DESTINATIONS_SET: 'print_preview.NativeLayer.LOCAL_DESTINATIONS_SET', | 95 LOCAL_DESTINATIONS_SET: 'print_preview.NativeLayer.LOCAL_DESTINATIONS_SET', |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 destination, printTicketStore, documentInfo, requestId) { | 269 destination, printTicketStore, documentInfo, requestId) { |
267 assert(printTicketStore.isTicketValidForPreview(), | 270 assert(printTicketStore.isTicketValidForPreview(), |
268 'Trying to generate preview when ticket is not valid'); | 271 'Trying to generate preview when ticket is not valid'); |
269 | 272 |
270 var ticket = { | 273 var ticket = { |
271 'pageRange': printTicketStore.pageRange.getDocumentPageRanges(), | 274 'pageRange': printTicketStore.pageRange.getDocumentPageRanges(), |
272 'mediaSize': printTicketStore.mediaSize.getValue(), | 275 'mediaSize': printTicketStore.mediaSize.getValue(), |
273 'landscape': printTicketStore.landscape.getValue(), | 276 'landscape': printTicketStore.landscape.getValue(), |
274 'color': this.getNativeColorModel_(destination, printTicketStore.color), | 277 'color': this.getNativeColorModel_(destination, printTicketStore.color), |
275 'headerFooterEnabled': printTicketStore.headerFooter.getValue(), | 278 'headerFooterEnabled': printTicketStore.headerFooter.getValue(), |
| 279 'distillPage': printTicketStore.distillPage.getValue(), |
276 'marginsType': printTicketStore.marginsType.getValue(), | 280 'marginsType': printTicketStore.marginsType.getValue(), |
277 'isFirstRequest': requestId == 0, | 281 'isFirstRequest': requestId == 0, |
278 'requestID': requestId, | 282 'requestID': requestId, |
279 'previewModifiable': documentInfo.isModifiable, | 283 'previewModifiable': documentInfo.isModifiable, |
280 'printToPDF': | 284 'printToPDF': |
281 destination != null && | 285 destination != null && |
282 destination.id == | 286 destination.id == |
283 print_preview.Destination.GooglePromotedId.SAVE_AS_PDF, | 287 print_preview.Destination.GooglePromotedId.SAVE_AS_PDF, |
284 'printWithCloudPrint': destination != null && !destination.isLocal, | 288 'printWithCloudPrint': destination != null && !destination.isLocal, |
285 'printWithPrivet': destination != null && destination.isPrivet, | 289 'printWithPrivet': destination != null && destination.isPrivet, |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
729 * @private | 733 * @private |
730 */ | 734 */ |
731 onPrintPresetOptionsFromDocument_: function(options) { | 735 onPrintPresetOptionsFromDocument_: function(options) { |
732 var printPresetOptionsEvent = new Event( | 736 var printPresetOptionsEvent = new Event( |
733 NativeLayer.EventType.PRINT_PRESET_OPTIONS); | 737 NativeLayer.EventType.PRINT_PRESET_OPTIONS); |
734 printPresetOptionsEvent.optionsFromDocument = options; | 738 printPresetOptionsEvent.optionsFromDocument = options; |
735 this.dispatchEvent(printPresetOptionsEvent); | 739 this.dispatchEvent(printPresetOptionsEvent); |
736 }, | 740 }, |
737 | 741 |
738 /** | 742 /** |
| 743 * Updates the interface to show the "Distill Page" option |
| 744 * when PrintPreviewHandler::HandleIsPageDistillableResult |
| 745 * determines that this page can be distilled with the |
| 746 * DOM Distiller. |
| 747 * @private |
| 748 */ |
| 749 detectDistillablePage_: function() { |
| 750 var allowDistillPageEvent = new Event( |
| 751 NativeLayer.EventType.ALLOW_DISTILL_PAGE); |
| 752 this.dispatchEvent(allowDistillPageEvent); |
| 753 }, |
| 754 |
| 755 /** |
739 * Simulates a user click on the print preview dialog cancel button. Used | 756 * Simulates a user click on the print preview dialog cancel button. Used |
740 * only for testing. | 757 * only for testing. |
741 * @private | 758 * @private |
742 */ | 759 */ |
743 autoCancelForTesting_: function() { | 760 autoCancelForTesting_: function() { |
744 var properties = {view: window, bubbles: true, cancelable: true}; | 761 var properties = {view: window, bubbles: true, cancelable: true}; |
745 var click = new MouseEvent('click', properties); | 762 var click = new MouseEvent('click', properties); |
746 document.querySelector('#print-header .cancel').dispatchEvent(click); | 763 document.querySelector('#print-header .cancel').dispatchEvent(click); |
747 }, | 764 }, |
748 | 765 |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1088 return this.serializedAppStateStr_; | 1105 return this.serializedAppStateStr_; |
1089 } | 1106 } |
1090 }; | 1107 }; |
1091 | 1108 |
1092 // Export | 1109 // Export |
1093 return { | 1110 return { |
1094 NativeInitialSettings: NativeInitialSettings, | 1111 NativeInitialSettings: NativeInitialSettings, |
1095 NativeLayer: NativeLayer | 1112 NativeLayer: NativeLayer |
1096 }; | 1113 }; |
1097 }); | 1114 }); |
OLD | NEW |