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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 destination, printTicketStore, documentInfo, requestId) { | 248 destination, printTicketStore, documentInfo, requestId) { |
249 assert(printTicketStore.isTicketValidForPreview(), | 249 assert(printTicketStore.isTicketValidForPreview(), |
250 'Trying to generate preview when ticket is not valid'); | 250 'Trying to generate preview when ticket is not valid'); |
251 | 251 |
252 var ticket = { | 252 var ticket = { |
253 'pageRange': printTicketStore.pageRange.getDocumentPageRanges(), | 253 'pageRange': printTicketStore.pageRange.getDocumentPageRanges(), |
254 'mediaSize': printTicketStore.mediaSize.getValue(), | 254 'mediaSize': printTicketStore.mediaSize.getValue(), |
255 'landscape': printTicketStore.landscape.getValue(), | 255 'landscape': printTicketStore.landscape.getValue(), |
256 'color': this.getNativeColorModel_(destination, printTicketStore.color), | 256 'color': this.getNativeColorModel_(destination, printTicketStore.color), |
257 'headerFooterEnabled': printTicketStore.headerFooter.getValue(), | 257 'headerFooterEnabled': printTicketStore.headerFooter.getValue(), |
| 258 'printFriendly': printTicketStore.printFriendly.getValue(), |
258 'marginsType': printTicketStore.marginsType.getValue(), | 259 'marginsType': printTicketStore.marginsType.getValue(), |
259 'isFirstRequest': requestId == 0, | 260 'isFirstRequest': requestId == 0, |
260 'requestID': requestId, | 261 'requestID': requestId, |
261 'previewModifiable': documentInfo.isModifiable, | 262 'previewModifiable': documentInfo.isModifiable, |
262 'printToPDF': | 263 'printToPDF': |
263 destination != null && | 264 destination != null && |
264 destination.id == | 265 destination.id == |
265 print_preview.Destination.GooglePromotedId.SAVE_AS_PDF, | 266 print_preview.Destination.GooglePromotedId.SAVE_AS_PDF, |
266 'printWithCloudPrint': destination != null && !destination.isLocal, | 267 'printWithCloudPrint': destination != null && !destination.isLocal, |
267 'printWithPrivet': destination != null && destination.isPrivet, | 268 'printWithPrivet': destination != null && destination.isPrivet, |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 initialSettings['appKioskMode'] || false, | 461 initialSettings['appKioskMode'] || false, |
461 initialSettings['hidePrintWithSystemDialogLink'] || false, | 462 initialSettings['hidePrintWithSystemDialogLink'] || false, |
462 numberFormatSymbols[0] || ',', | 463 numberFormatSymbols[0] || ',', |
463 numberFormatSymbols[1] || '.', | 464 numberFormatSymbols[1] || '.', |
464 unitType, | 465 unitType, |
465 initialSettings['previewModifiable'] || false, | 466 initialSettings['previewModifiable'] || false, |
466 initialSettings['initiatorTitle'] || '', | 467 initialSettings['initiatorTitle'] || '', |
467 initialSettings['documentHasSelection'] || false, | 468 initialSettings['documentHasSelection'] || false, |
468 initialSettings['shouldPrintSelectionOnly'] || false, | 469 initialSettings['shouldPrintSelectionOnly'] || false, |
469 initialSettings['printerName'] || null, | 470 initialSettings['printerName'] || null, |
470 initialSettings['appState'] || null); | 471 initialSettings['appState'] || null, |
| 472 initialSettings['printFriendlyEnabled'] || false); |
471 | 473 |
472 var initialSettingsSetEvent = new Event( | 474 var initialSettingsSetEvent = new Event( |
473 NativeLayer.EventType.INITIAL_SETTINGS_SET); | 475 NativeLayer.EventType.INITIAL_SETTINGS_SET); |
474 initialSettingsSetEvent.initialSettings = nativeInitialSettings; | 476 initialSettingsSetEvent.initialSettings = nativeInitialSettings; |
475 this.dispatchEvent(initialSettingsSetEvent); | 477 this.dispatchEvent(initialSettingsSetEvent); |
476 }, | 478 }, |
477 | 479 |
478 /** | 480 /** |
479 * Turn on the integration of Cloud Print. | 481 * Turn on the integration of Cloud Print. |
480 * @param {{cloudPrintURL: string, appKioskMode: string}} settings | 482 * @param {{cloudPrintURL: string, appKioskMode: string}} settings |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 * @param {boolean} isDocumentModifiable Whether the document to print is | 855 * @param {boolean} isDocumentModifiable Whether the document to print is |
854 * modifiable. | 856 * modifiable. |
855 * @param {string} documentTitle Title of the document. | 857 * @param {string} documentTitle Title of the document. |
856 * @param {boolean} documentHasSelection Whether the document has selected | 858 * @param {boolean} documentHasSelection Whether the document has selected |
857 * content. | 859 * content. |
858 * @param {boolean} selectionOnly Whether only selected content should be | 860 * @param {boolean} selectionOnly Whether only selected content should be |
859 * printed. | 861 * printed. |
860 * @param {?string} systemDefaultDestinationId ID of the system default | 862 * @param {?string} systemDefaultDestinationId ID of the system default |
861 * destination. | 863 * destination. |
862 * @param {?string} serializedAppStateStr Serialized app state. | 864 * @param {?string} serializedAppStateStr Serialized app state. |
| 865 * @param {boolean} printFriendlyEnabled Whether the print friendly setting is |
| 866 * enabled. |
863 * @constructor | 867 * @constructor |
864 */ | 868 */ |
865 function NativeInitialSettings( | 869 function NativeInitialSettings( |
866 isInKioskAutoPrintMode, | 870 isInKioskAutoPrintMode, |
867 isInAppKioskMode, | 871 isInAppKioskMode, |
868 hidePrintWithSystemDialogLink, | 872 hidePrintWithSystemDialogLink, |
869 thousandsDelimeter, | 873 thousandsDelimeter, |
870 decimalDelimeter, | 874 decimalDelimeter, |
871 unitType, | 875 unitType, |
872 isDocumentModifiable, | 876 isDocumentModifiable, |
873 documentTitle, | 877 documentTitle, |
874 documentHasSelection, | 878 documentHasSelection, |
875 selectionOnly, | 879 selectionOnly, |
876 systemDefaultDestinationId, | 880 systemDefaultDestinationId, |
877 serializedAppStateStr) { | 881 serializedAppStateStr, |
| 882 printFriendlyEnabled) { |
878 | 883 |
879 /** | 884 /** |
880 * Whether the print preview should be in auto-print mode. | 885 * Whether the print preview should be in auto-print mode. |
881 * @type {boolean} | 886 * @type {boolean} |
882 * @private | 887 * @private |
883 */ | 888 */ |
884 this.isInKioskAutoPrintMode_ = isInKioskAutoPrintMode; | 889 this.isInKioskAutoPrintMode_ = isInKioskAutoPrintMode; |
885 | 890 |
886 /** | 891 /** |
887 * Whether the print preview should switch to App Kiosk mode. | 892 * Whether the print preview should switch to App Kiosk mode. |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
952 * @private | 957 * @private |
953 */ | 958 */ |
954 this.systemDefaultDestinationId_ = systemDefaultDestinationId; | 959 this.systemDefaultDestinationId_ = systemDefaultDestinationId; |
955 | 960 |
956 /** | 961 /** |
957 * Serialized app state. | 962 * Serialized app state. |
958 * @type {?string} | 963 * @type {?string} |
959 * @private | 964 * @private |
960 */ | 965 */ |
961 this.serializedAppStateStr_ = serializedAppStateStr; | 966 this.serializedAppStateStr_ = serializedAppStateStr; |
| 967 |
| 968 /** |
| 969 * Whether the print friendly setting is enabled. |
| 970 * @type {boolean} |
| 971 * @private |
| 972 */ |
| 973 this.printFriendlyEnabled_ = printFriendlyEnabled; |
962 }; | 974 }; |
963 | 975 |
964 NativeInitialSettings.prototype = { | 976 NativeInitialSettings.prototype = { |
965 /** | 977 /** |
966 * @return {boolean} Whether the print preview should be in auto-print mode. | 978 * @return {boolean} Whether the print preview should be in auto-print mode. |
967 */ | 979 */ |
968 get isInKioskAutoPrintMode() { | 980 get isInKioskAutoPrintMode() { |
969 return this.isInKioskAutoPrintMode_; | 981 return this.isInKioskAutoPrintMode_; |
970 }, | 982 }, |
971 | 983 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1024 }, | 1036 }, |
1025 | 1037 |
1026 /** @return {?string} ID of the system default destination. */ | 1038 /** @return {?string} ID of the system default destination. */ |
1027 get systemDefaultDestinationId() { | 1039 get systemDefaultDestinationId() { |
1028 return this.systemDefaultDestinationId_; | 1040 return this.systemDefaultDestinationId_; |
1029 }, | 1041 }, |
1030 | 1042 |
1031 /** @return {?string} Serialized app state. */ | 1043 /** @return {?string} Serialized app state. */ |
1032 get serializedAppStateStr() { | 1044 get serializedAppStateStr() { |
1033 return this.serializedAppStateStr_; | 1045 return this.serializedAppStateStr_; |
1034 } | 1046 }, |
| 1047 |
| 1048 /** |
| 1049 * @return {boolean} Whether the print friendly setting is enabled. |
| 1050 */ |
| 1051 get printFriendlyEnabled() { |
| 1052 return this.printFriendlyEnabled_; |
| 1053 }, |
| 1054 |
1035 }; | 1055 }; |
1036 | 1056 |
1037 // Export | 1057 // Export |
1038 return { | 1058 return { |
1039 NativeInitialSettings: NativeInitialSettings, | 1059 NativeInitialSettings: NativeInitialSettings, |
1040 NativeLayer: NativeLayer | 1060 NativeLayer: NativeLayer |
1041 }; | 1061 }; |
1042 }); | 1062 }); |
OLD | NEW |