Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1215)

Side by Side Diff: chrome/browser/resources/print_preview/print_preview.js

Issue 7792085: Print Preview: Handling pending print to pdf requests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebasing Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 * Asks the browser to print the preview PDF based on current print 429 * Asks the browser to print the preview PDF based on current print
430 * settings. If the preview is still loading, printPendingFile() will get 430 * settings. If the preview is still loading, printPendingFile() will get
431 * called once the preview loads. 431 * called once the preview loads.
432 */ 432 */
433 function requestToPrintDocument() { 433 function requestToPrintDocument() {
434 hasPendingPrintDocumentRequest = !isPrintReadyMetafileReady; 434 hasPendingPrintDocumentRequest = !isPrintReadyMetafileReady;
435 var printToPDF = getSelectedPrinterName() == PRINT_TO_PDF; 435 var printToPDF = getSelectedPrinterName() == PRINT_TO_PDF;
436 436
437 if (hasPendingPrintDocumentRequest) { 437 if (hasPendingPrintDocumentRequest) {
438 if (printToPDF) { 438 if (printToPDF) {
439 // TODO(thestig) disable controls here. 439 sendPrintDocumentRequest();
440 } else { 440 } else {
441 isTabHidden = true; 441 isTabHidden = true;
442 chrome.send('hidePreview'); 442 chrome.send('hidePreview');
443 } 443 }
444 return; 444 return;
445 } 445 }
446 446
447 if (printToPDF) { 447 if (printToPDF) {
448 sendPrintDocumentRequest(); 448 sendPrintDocumentRequest();
449 } else { 449 } else {
450 window.setTimeout(function() { sendPrintDocumentRequest(); }, 1000); 450 window.setTimeout(function() { sendPrintDocumentRequest(); }, 1000);
451 } 451 }
452 } 452 }
453 453
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 533
534 /** 534 /**
535 * Called from PrintPreviewUI::OnFileSelectionCancelled to notify the print 535 * Called from PrintPreviewUI::OnFileSelectionCancelled to notify the print
536 * preview tab regarding the file selection cancel event. 536 * preview tab regarding the file selection cancel event.
537 */ 537 */
538 function fileSelectionCancelled() { 538 function fileSelectionCancelled() {
539 // TODO(thestig) re-enable controls here. 539 // TODO(thestig) re-enable controls here.
540 } 540 }
541 541
542 /** 542 /**
543 * Called from PrintPreviewUI::OnFileSelectionCompleted to notify the print
544 * preview tab regarding the file selection completed event.
545 */
546 function fileSelectionCompleted() {
547 // If the file selection is completed and the tab is not already closed it
548 // means that a pending print to pdf request exists.
549 disableInputElementsInSidebar();
550 showCustomMessage(localStrings.getString('printingToPDFInProgress'));
551 }
552
553 /**
543 * Set the default printer. If there is one, generate a print preview. 554 * Set the default printer. If there is one, generate a print preview.
544 * @param {string} printer Name of the default printer. Empty if none. 555 * @param {string} printer Name of the default printer. Empty if none.
545 * @param {string} cloudPrintData Cloud print related data to restore if 556 * @param {string} cloudPrintData Cloud print related data to restore if
546 * the default printer is a cloud printer. 557 * the default printer is a cloud printer.
547 */ 558 */
548 function setDefaultPrinter(printer_name, cloudPrintData) { 559 function setDefaultPrinter(printer_name, cloudPrintData) {
549 // Add a placeholder value so the printer list looks valid. 560 // Add a placeholder value so the printer list looks valid.
550 addDestinationListOption('', '', true, true, true); 561 addDestinationListOption('', '', true, true, true);
551 if (printer_name) { 562 if (printer_name) {
552 defaultOrLastUsedPrinterName = printer_name; 563 defaultOrLastUsedPrinterName = printer_name;
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 cloudprint.setColor(printerList[printerList.selectedIndex], color); 828 cloudprint.setColor(printerList[printerList.selectedIndex], color);
818 } 829 }
819 830
820 /** 831 /**
821 * Display an error message in the center of the preview area. 832 * Display an error message in the center of the preview area.
822 * @param {string} errorMessage The error message to be displayed. 833 * @param {string} errorMessage The error message to be displayed.
823 */ 834 */
824 function displayErrorMessage(errorMessage) { 835 function displayErrorMessage(errorMessage) {
825 $('print-button').disabled = true; 836 $('print-button').disabled = true;
826 $('overlay-layer').classList.remove('invisible'); 837 $('overlay-layer').classList.remove('invisible');
827 $('dancing-dots-text').classList.add('hidden'); 838 var customMessage = $('custom-message');
828 $('error-text').innerHTML = errorMessage; 839 customMessage.textContent = errorMessage;
829 $('error-text').classList.remove('hidden'); 840 customMessage.hidden = false;
841 var customMessageWithDots = $('custom-message-with-dots');
842 customMessageWithDots.innerHTML = '';
843 customMessageWithDots.hidden = true;;
830 var pdfViewer = $('pdf-viewer'); 844 var pdfViewer = $('pdf-viewer');
831 if (pdfViewer) 845 if (pdfViewer)
832 $('mainview').removeChild(pdfViewer); 846 $('mainview').removeChild(pdfViewer);
833 847
834 if (isTabHidden) 848 if (isTabHidden)
835 cancelPendingPrintRequest(); 849 cancelPendingPrintRequest();
836 } 850 }
837 851
838 /** 852 /**
839 * Display an error message in the center of the preview area followed by a 853 * Display an error message in the center of the preview area followed by a
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 889
876 /** 890 /**
877 * Called when the PDF plugin loads its document. 891 * Called when the PDF plugin loads its document.
878 */ 892 */
879 function onPDFLoad() { 893 function onPDFLoad() {
880 if (previewModifiable) { 894 if (previewModifiable) {
881 setPluginPreviewPageCount(); 895 setPluginPreviewPageCount();
882 } 896 }
883 $('pdf-viewer').fitToHeight(); 897 $('pdf-viewer').fitToHeight();
884 cr.dispatchSimpleEvent(document, 'PDFLoaded'); 898 cr.dispatchSimpleEvent(document, 'PDFLoaded');
885 hideLoadingAnimation(); 899 hideOverlayLayer();
886 } 900 }
887 901
888 function setPluginPreviewPageCount() { 902 function setPluginPreviewPageCount() {
889 $('pdf-viewer').printPreviewPageCount( 903 $('pdf-viewer').printPreviewPageCount(
890 pageSettings.previouslySelectedPages.length); 904 pageSettings.previouslySelectedPages.length);
891 } 905 }
892 906
893 /** 907 /**
894 * Update the page count and check the page range. 908 * Update the page count and check the page range.
895 * Called from PrintPreviewUI::OnDidGetPreviewPageCount(). 909 * Called from PrintPreviewUI::OnDidGetPreviewPageCount().
(...skipping 24 matching lines...) Expand all
920 * @param {number} previewResponseId The preview request id that resulted in 934 * @param {number} previewResponseId The preview request id that resulted in
921 * this response. 935 * this response.
922 */ 936 */
923 function reloadPreviewPages(previewUid, previewResponseId) { 937 function reloadPreviewPages(previewUid, previewResponseId) {
924 if (!isExpectedPreviewResponse(previewResponseId)) 938 if (!isExpectedPreviewResponse(previewResponseId))
925 return; 939 return;
926 hasPendingPreviewRequest = false; 940 hasPendingPreviewRequest = false;
927 isPrintReadyMetafileReady = true; 941 isPrintReadyMetafileReady = true;
928 942
929 cr.dispatchSimpleEvent(document, 'updatePrintButton'); 943 cr.dispatchSimpleEvent(document, 'updatePrintButton');
930 hideLoadingAnimation(); 944 hideOverlayLayer();
931 var pageSet = pageSettings.previouslySelectedPages; 945 var pageSet = pageSettings.previouslySelectedPages;
932 for (var i = 0; i < pageSet.length; i++) 946 for (var i = 0; i < pageSet.length; i++)
933 $('pdf-viewer').loadPreviewPage(getPageSrcURL(previewUid, pageSet[i]-1), i); 947 $('pdf-viewer').loadPreviewPage(getPageSrcURL(previewUid, pageSet[i]-1), i);
934 // TODO(dpapad): handle pending print file requests. 948 // TODO(dpapad): handle pending print file requests.
935 } 949 }
936 950
937 /** 951 /**
938 * Notification that a print preview page has been rendered. 952 * Notification that a print preview page has been rendered.
939 * Check if the settings have changed and request a regeneration if needed. 953 * Check if the settings have changed and request a regeneration if needed.
940 * Called from PrintPreviewUI::OnDidPreviewPage(). 954 * Called from PrintPreviewUI::OnDidPreviewPage().
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1102 <include src="print_preview_animations.js"/> 1116 <include src="print_preview_animations.js"/>
1103 <include src="print_preview_cloud.js"/> 1117 <include src="print_preview_cloud.js"/>
1104 <include src="print_preview_utils.js"/> 1118 <include src="print_preview_utils.js"/>
1105 <include src="print_header.js"/> 1119 <include src="print_header.js"/>
1106 <include src="page_settings.js"/> 1120 <include src="page_settings.js"/>
1107 <include src="copies_settings.js"/> 1121 <include src="copies_settings.js"/>
1108 <include src="header_footer_settings.js"/> 1122 <include src="header_footer_settings.js"/>
1109 <include src="layout_settings.js"/> 1123 <include src="layout_settings.js"/>
1110 <include src="color_settings.js"/> 1124 <include src="color_settings.js"/>
1111 <include src="margin_settings.js"/> 1125 <include src="margin_settings.js"/>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698