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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
72 global.onExtensionCapabilitiesSet = | 72 global.onExtensionCapabilitiesSet = |
73 this.onExtensionCapabilitiesSet_.bind(this); | 73 this.onExtensionCapabilitiesSet_.bind(this); |
74 global.onEnableManipulateSettingsForTest = | 74 global.onEnableManipulateSettingsForTest = |
75 this.onEnableManipulateSettingsForTest_.bind(this); | 75 this.onEnableManipulateSettingsForTest_.bind(this); |
76 global.printPresetOptionsFromDocument = | 76 global.printPresetOptionsFromDocument = |
77 this.onPrintPresetOptionsFromDocument_.bind(this); | 77 this.onPrintPresetOptionsFromDocument_.bind(this); |
78 global.onProvisionalPrinterResolved = | 78 global.onProvisionalPrinterResolved = |
79 this.onProvisionalDestinationResolved_.bind(this); | 79 this.onProvisionalDestinationResolved_.bind(this); |
80 global.failedToResolveProvisionalPrinter = | 80 global.failedToResolveProvisionalPrinter = |
81 this.failedToResolveProvisionalDestination_.bind(this); | 81 this.failedToResolveProvisionalDestination_.bind(this); |
82 }; | 82 } |
83 | 83 |
84 /** | 84 /** |
85 * Event types dispatched from the Chromium native layer. | 85 * Event types dispatched from the Chromium native layer. |
86 * @enum {string} | 86 * @enum {string} |
87 * @const | 87 * @const |
88 */ | 88 */ |
89 NativeLayer.EventType = { | 89 NativeLayer.EventType = { |
90 ACCESS_TOKEN_READY: 'print_preview.NativeLayer.ACCESS_TOKEN_READY', | 90 ACCESS_TOKEN_READY: 'print_preview.NativeLayer.ACCESS_TOKEN_READY', |
91 CAPABILITIES_SET: 'print_preview.NativeLayer.CAPABILITIES_SET', | 91 CAPABILITIES_SET: 'print_preview.NativeLayer.CAPABILITIES_SET', |
92 CLOUD_PRINT_ENABLE: 'print_preview.NativeLayer.CLOUD_PRINT_ENABLE', | 92 CLOUD_PRINT_ENABLE: 'print_preview.NativeLayer.CLOUD_PRINT_ENABLE', |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
296 'previewModifiable': documentInfo.isModifiable, | 296 'previewModifiable': documentInfo.isModifiable, |
297 'generateDraftData': documentInfo.isModifiable, | 297 'generateDraftData': documentInfo.isModifiable, |
298 'fitToPageEnabled': printTicketStore.fitToPage.getValue(), | 298 'fitToPageEnabled': printTicketStore.fitToPage.getValue(), |
299 'scaleFactor': printTicketStore.scaling.getValueAsNumber(), | 299 'scaleFactor': printTicketStore.scaling.getValueAsNumber(), |
300 // NOTE: Even though the following fields don't directly relate to the | 300 // NOTE: Even though the following fields don't directly relate to the |
301 // preview, they still need to be included. | 301 // preview, they still need to be included. |
302 // e.g. printing::PrintSettingsFromJobSettings() still checks for them. | 302 // e.g. printing::PrintSettingsFromJobSettings() still checks for them. |
303 'collate': true, | 303 'collate': true, |
304 'copies': 1, | 304 'copies': 1, |
305 'deviceName': destination.id, | 305 'deviceName': destination.id, |
306 'dpiHorizontal': "horizontal_dpi" in printTicketStore.dpi.getValue() ? | 306 'dpiHorizontal': 'horizontal_dpi' in printTicketStore.dpi.getValue() ? |
307 printTicketStore.dpi.getValue().horizontal_dpi : 0, | 307 printTicketStore.dpi.getValue().horizontal_dpi : 0, |
308 'dpiVertical': "vertical_dpi" in printTicketStore.dpi.getValue() ? | 308 'dpiVertical': 'vertical_dpi' in printTicketStore.dpi.getValue() ? |
309 printTicketStore.dpi.getValue().vertical_dpi : 0, | 309 printTicketStore.dpi.getValue().vertical_dpi : 0, |
310 'duplex': printTicketStore.duplex.getValue() ? | 310 'duplex': printTicketStore.duplex.getValue() ? |
311 NativeLayer.DuplexMode.LONG_EDGE : NativeLayer.DuplexMode.SIMPLEX, | 311 NativeLayer.DuplexMode.LONG_EDGE : NativeLayer.DuplexMode.SIMPLEX, |
312 'printToPDF': destination.id == | 312 'printToPDF': destination.id == |
313 print_preview.Destination.GooglePromotedId.SAVE_AS_PDF, | 313 print_preview.Destination.GooglePromotedId.SAVE_AS_PDF, |
314 'printWithCloudPrint': !destination.isLocal, | 314 'printWithCloudPrint': !destination.isLocal, |
315 'printWithPrivet': destination.isPrivet, | 315 'printWithPrivet': destination.isPrivet, |
316 'printWithExtension': destination.isExtension, | 316 'printWithExtension': destination.isExtension, |
317 'rasterizePDF': false, | 317 'rasterizePDF': false, |
318 'shouldPrintBackgrounds': printTicketStore.cssBackground.getValue(), | 318 'shouldPrintBackgrounds': printTicketStore.cssBackground.getValue(), |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
381 'shouldPrintBackgrounds': printTicketStore.cssBackground.getValue(), | 381 'shouldPrintBackgrounds': printTicketStore.cssBackground.getValue(), |
382 'shouldPrintSelectionOnly': false, // Only used in print preview | 382 'shouldPrintSelectionOnly': false, // Only used in print preview |
383 'previewModifiable': documentInfo.isModifiable, | 383 'previewModifiable': documentInfo.isModifiable, |
384 'printToPDF': destination.id == | 384 'printToPDF': destination.id == |
385 print_preview.Destination.GooglePromotedId.SAVE_AS_PDF, | 385 print_preview.Destination.GooglePromotedId.SAVE_AS_PDF, |
386 'printWithCloudPrint': !destination.isLocal, | 386 'printWithCloudPrint': !destination.isLocal, |
387 'printWithPrivet': destination.isPrivet, | 387 'printWithPrivet': destination.isPrivet, |
388 'printWithExtension': destination.isExtension, | 388 'printWithExtension': destination.isExtension, |
389 'rasterizePDF': printTicketStore.rasterize.getValue(), | 389 'rasterizePDF': printTicketStore.rasterize.getValue(), |
390 'scaleFactor': printTicketStore.scaling.getValueAsNumber(), | 390 'scaleFactor': printTicketStore.scaling.getValueAsNumber(), |
391 'dpiHorizontal': "horizontal_dpi" in printTicketStore.dpi.getValue() ? | 391 'dpiHorizontal': 'horizontal_dpi' in printTicketStore.dpi.getValue() ? |
392 printTicketStore.dpi.getValue().horizontal_dpi : 0, | 392 printTicketStore.dpi.getValue().horizontal_dpi : 0, |
393 'dpiVertical': "vertical_dpi" in printTicketStore.dpi.getValue() ? | 393 'dpiVertical': 'vertical_dpi' in printTicketStore.dpi.getValue() ? |
394 printTicketStore.dpi.getValue().vertical_dpi : 0, | 394 printTicketStore.dpi.getValue().vertical_dpi : 0, |
395 'deviceName': destination.id, | 395 'deviceName': destination.id, |
396 'fitToPageEnabled': printTicketStore.fitToPage.getValue(), | 396 'fitToPageEnabled': printTicketStore.fitToPage.getValue(), |
397 'pageWidth': documentInfo.pageSize.width, | 397 'pageWidth': documentInfo.pageSize.width, |
398 'pageHeight': documentInfo.pageSize.height, | 398 'pageHeight': documentInfo.pageSize.height, |
399 'showSystemDialog': opt_showSystemDialog | 399 'showSystemDialog': opt_showSystemDialog |
400 }; | 400 }; |
401 | 401 |
402 if (!destination.isLocal) { | 402 if (!destination.isLocal) { |
403 // We can't set cloudPrintID if the destination is "Print with Cloud | 403 // We can't set cloudPrintID if the destination is "Print with Cloud |
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
995 | 995 |
996 /** | 996 /** |
997 * Title of the document. | 997 * Title of the document. |
998 * @type {string} | 998 * @type {string} |
999 * @private | 999 * @private |
1000 */ | 1000 */ |
1001 this.documentTitle_ = documentTitle; | 1001 this.documentTitle_ = documentTitle; |
1002 | 1002 |
1003 /** | 1003 /** |
1004 * Whether the document has selection. | 1004 * Whether the document has selection. |
1005 * @type {string} | 1005 * @type {boolean} |
dpapad
2017/05/05 23:30:29
Nit (optional): Since you are already doing small
rbpotter
2017/05/06 00:02:19
Done.
| |
1006 * @private | 1006 * @private |
1007 */ | 1007 */ |
1008 this.documentHasSelection_ = documentHasSelection; | 1008 this.documentHasSelection_ = documentHasSelection; |
1009 | 1009 |
1010 /** | 1010 /** |
1011 * Whether selection only should be printed. | 1011 * Whether selection only should be printed. |
1012 * @type {string} | 1012 * @type {boolean} |
1013 * @private | 1013 * @private |
1014 */ | 1014 */ |
1015 this.selectionOnly_ = selectionOnly; | 1015 this.selectionOnly_ = selectionOnly; |
1016 | 1016 |
1017 /** | 1017 /** |
1018 * ID of the system default destination. | 1018 * ID of the system default destination. |
1019 * @type {?string} | 1019 * @type {?string} |
1020 * @private | 1020 * @private |
1021 */ | 1021 */ |
1022 this.systemDefaultDestinationId_ = systemDefaultDestinationId; | 1022 this.systemDefaultDestinationId_ = systemDefaultDestinationId; |
1023 | 1023 |
1024 /** | 1024 /** |
1025 * Serialized app state. | 1025 * Serialized app state. |
1026 * @type {?string} | 1026 * @type {?string} |
1027 * @private | 1027 * @private |
1028 */ | 1028 */ |
1029 this.serializedAppStateStr_ = serializedAppStateStr; | 1029 this.serializedAppStateStr_ = serializedAppStateStr; |
1030 | 1030 |
1031 /** | 1031 /** |
1032 * Serialized default destination selection rules. | 1032 * Serialized default destination selection rules. |
1033 * @type {?string} | 1033 * @type {?string} |
1034 * @private | 1034 * @private |
1035 */ | 1035 */ |
1036 this.serializedDefaultDestinationSelectionRulesStr_ = | 1036 this.serializedDefaultDestinationSelectionRulesStr_ = |
1037 serializedDefaultDestinationSelectionRulesStr; | 1037 serializedDefaultDestinationSelectionRulesStr; |
1038 }; | 1038 } |
1039 | 1039 |
1040 NativeInitialSettings.prototype = { | 1040 NativeInitialSettings.prototype = { |
1041 /** | 1041 /** |
1042 * @return {boolean} Whether the print preview should be in auto-print mode. | 1042 * @return {boolean} Whether the print preview should be in auto-print mode. |
1043 */ | 1043 */ |
1044 get isInKioskAutoPrintMode() { | 1044 get isInKioskAutoPrintMode() { |
1045 return this.isInKioskAutoPrintMode_; | 1045 return this.isInKioskAutoPrintMode_; |
1046 }, | 1046 }, |
1047 | 1047 |
1048 /** | 1048 /** |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1106 return this.serializedDefaultDestinationSelectionRulesStr_; | 1106 return this.serializedDefaultDestinationSelectionRulesStr_; |
1107 } | 1107 } |
1108 }; | 1108 }; |
1109 | 1109 |
1110 // Export | 1110 // Export |
1111 return { | 1111 return { |
1112 NativeInitialSettings: NativeInitialSettings, | 1112 NativeInitialSettings: NativeInitialSettings, |
1113 NativeLayer: NativeLayer | 1113 NativeLayer: NativeLayer |
1114 }; | 1114 }; |
1115 }); | 1115 }); |
OLD | NEW |