| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // require: cr/ui/print_preview_cloud.js | 5 // require: cr/ui/print_preview_cloud.js |
| 6 | 6 |
| 7 var localStrings = new LocalStrings(); | 7 var localStrings = new LocalStrings(); |
| 8 | 8 |
| 9 // If useCloudPrint is true we attempt to connect to cloud print | 9 // If useCloudPrint is true we attempt to connect to cloud print |
| 10 // and populate the list of printers with cloud print printers. | 10 // and populate the list of printers with cloud print printers. |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 chrome.send(selectedValue); | 230 chrome.send(selectedValue); |
| 231 skip_refresh = true; | 231 skip_refresh = true; |
| 232 } else if (selectedValue == MORE_PRINTERS) { | 232 } else if (selectedValue == MORE_PRINTERS) { |
| 233 onSystemDialogLinkClicked(); | 233 onSystemDialogLinkClicked(); |
| 234 skip_refresh = true; | 234 skip_refresh = true; |
| 235 } else if (selectedValue == PRINT_TO_PDF) { | 235 } else if (selectedValue == PRINT_TO_PDF) { |
| 236 updateWithPrinterCapabilities({ | 236 updateWithPrinterCapabilities({ |
| 237 'disableColorOption': true, | 237 'disableColorOption': true, |
| 238 'setColorAsDefault': true, | 238 'setColorAsDefault': true, |
| 239 'setDuplexAsDefault': false, | 239 'setDuplexAsDefault': false, |
| 240 'printerColorModelForColor': colorSettings.COLOR, |
| 240 'disableCopiesOption': true}); | 241 'disableCopiesOption': true}); |
| 241 } else { | 242 } else { |
| 242 // This message will call back to 'updateWithPrinterCapabilities' | 243 // This message will call back to 'updateWithPrinterCapabilities' |
| 243 // function. | 244 // function. |
| 244 chrome.send('getPrinterCapabilities', [selectedValue]); | 245 chrome.send('getPrinterCapabilities', [selectedValue]); |
| 245 } | 246 } |
| 246 if (!skip_refresh) { | 247 if (!skip_refresh) { |
| 247 lastSelectedPrinterIndex = selectedIndex; | 248 lastSelectedPrinterIndex = selectedIndex; |
| 248 | 249 |
| 249 // Regenerate the preview data based on selected printer settings. | 250 // Regenerate the preview data based on selected printer settings. |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 var deviceName = getSelectedPrinterName(); | 338 var deviceName = getSelectedPrinterName(); |
| 338 var printToPDF = (deviceName == PRINT_TO_PDF); | 339 var printToPDF = (deviceName == PRINT_TO_PDF); |
| 339 | 340 |
| 340 var settings = | 341 var settings = |
| 341 {'deviceName': deviceName, | 342 {'deviceName': deviceName, |
| 342 'pageRange': pageSettings.selectedPageRanges, | 343 'pageRange': pageSettings.selectedPageRanges, |
| 343 'duplex': copiesSettings.duplexMode, | 344 'duplex': copiesSettings.duplexMode, |
| 344 'copies': copiesSettings.numberOfCopies, | 345 'copies': copiesSettings.numberOfCopies, |
| 345 'collate': copiesSettings.isCollated(), | 346 'collate': copiesSettings.isCollated(), |
| 346 'landscape': layoutSettings.isLandscape(), | 347 'landscape': layoutSettings.isLandscape(), |
| 347 'color': colorSettings.isColor(), | 348 'color': colorSettings.colorMode, |
| 348 'printToPDF': printToPDF, | 349 'printToPDF': printToPDF, |
| 349 'isFirstRequest' : false, | 350 'isFirstRequest' : false, |
| 350 'headerFooterEnabled': headerFooterSettings.hasHeaderFooter(), | 351 'headerFooterEnabled': headerFooterSettings.hasHeaderFooter(), |
| 351 'defaultMarginsSelected': marginSettings.isDefaultMarginsSelected(), | 352 'defaultMarginsSelected': marginSettings.isDefaultMarginsSelected(), |
| 352 'margins': marginSettings.customMargins, | 353 'margins': marginSettings.customMargins, |
| 353 'requestID': -1, | 354 'requestID': -1, |
| 354 'generateDraftData': generateDraftData}; | 355 'generateDraftData': generateDraftData}; |
| 355 | 356 |
| 356 var printerList = $('printer-list'); | 357 var printerList = $('printer-list'); |
| 357 var selectedPrinter = printerList.selectedIndex; | 358 var selectedPrinter = printerList.selectedIndex; |
| (...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1017 */ | 1018 */ |
| 1018 function createPDFPlugin(srcDataIndex) { | 1019 function createPDFPlugin(srcDataIndex) { |
| 1019 var pdfViewer = $('pdf-viewer'); | 1020 var pdfViewer = $('pdf-viewer'); |
| 1020 var srcURL = getPageSrcURL(currentPreviewUid, srcDataIndex); | 1021 var srcURL = getPageSrcURL(currentPreviewUid, srcDataIndex); |
| 1021 if (pdfViewer) { | 1022 if (pdfViewer) { |
| 1022 // Need to call this before the reload(), where the plugin resets its | 1023 // Need to call this before the reload(), where the plugin resets its |
| 1023 // internal page count. | 1024 // internal page count. |
| 1024 pdfViewer.goToPage('0'); | 1025 pdfViewer.goToPage('0'); |
| 1025 pdfViewer.resetPrintPreviewUrl(srcURL); | 1026 pdfViewer.resetPrintPreviewUrl(srcURL); |
| 1026 pdfViewer.reload(); | 1027 pdfViewer.reload(); |
| 1027 pdfViewer.grayscale(!colorSettings.isColor()); | 1028 pdfViewer.grayscale(colorSettings.colorMode == colorSettings.GRAY); |
| 1028 return; | 1029 return; |
| 1029 } | 1030 } |
| 1030 | 1031 |
| 1031 pdfViewer = document.createElement('embed'); | 1032 pdfViewer = document.createElement('embed'); |
| 1032 pdfViewer.setAttribute('id', 'pdf-viewer'); | 1033 pdfViewer.setAttribute('id', 'pdf-viewer'); |
| 1033 pdfViewer.setAttribute('type', | 1034 pdfViewer.setAttribute('type', |
| 1034 'application/x-google-chrome-print-preview-pdf'); | 1035 'application/x-google-chrome-print-preview-pdf'); |
| 1035 pdfViewer.setAttribute('src', srcURL); | 1036 pdfViewer.setAttribute('src', srcURL); |
| 1036 pdfViewer.setAttribute('aria-live', 'polite'); | 1037 pdfViewer.setAttribute('aria-live', 'polite'); |
| 1037 pdfViewer.setAttribute('aria-atomic', 'true'); | 1038 pdfViewer.setAttribute('aria-atomic', 'true'); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1089 <include src="print_preview_animations.js"/> | 1090 <include src="print_preview_animations.js"/> |
| 1090 <include src="print_preview_cloud.js"/> | 1091 <include src="print_preview_cloud.js"/> |
| 1091 <include src="print_preview_utils.js"/> | 1092 <include src="print_preview_utils.js"/> |
| 1092 <include src="print_header.js"/> | 1093 <include src="print_header.js"/> |
| 1093 <include src="page_settings.js"/> | 1094 <include src="page_settings.js"/> |
| 1094 <include src="copies_settings.js"/> | 1095 <include src="copies_settings.js"/> |
| 1095 <include src="header_footer_settings.js"/> | 1096 <include src="header_footer_settings.js"/> |
| 1096 <include src="layout_settings.js"/> | 1097 <include src="layout_settings.js"/> |
| 1097 <include src="color_settings.js"/> | 1098 <include src="color_settings.js"/> |
| 1098 <include src="margin_settings.js"/> | 1099 <include src="margin_settings.js"/> |
| OLD | NEW |