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

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

Issue 7550063: Print Preview: Handle a crashed initiator tab by showing a message in PP. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix a style issue Created 9 years, 4 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 /** 80 /**
81 * Window onload handler, sets up the page and starts print preview by getting 81 * Window onload handler, sets up the page and starts print preview by getting
82 * the printer list. 82 * the printer list.
83 */ 83 */
84 function onLoad() { 84 function onLoad() {
85 cr.enablePlatformSpecificCSSRules(); 85 cr.enablePlatformSpecificCSSRules();
86 initialPreviewRequestID = randomInteger(MIN_REQUEST_ID, MAX_REQUEST_ID); 86 initialPreviewRequestID = randomInteger(MIN_REQUEST_ID, MAX_REQUEST_ID);
87 lastPreviewRequestID = initialPreviewRequestID; 87 lastPreviewRequestID = initialPreviewRequestID;
88 88
89 if (!checkCompatiblePluginExists()) { 89 if (!checkCompatiblePluginExists()) {
90 disableInputElementsInSidebar();
91 displayErrorMessageWithButton(localStrings.getString('noPlugin'), 90 displayErrorMessageWithButton(localStrings.getString('noPlugin'),
92 localStrings.getString('launchNativeDialog'), 91 localStrings.getString('launchNativeDialog'),
93 launchNativePrintDialog); 92 launchNativePrintDialog);
94 $('mainview').parentElement.removeChild($('dummy-viewer')); 93 $('mainview').parentElement.removeChild($('dummy-viewer'));
95 return; 94 return;
96 } 95 }
97 96
98 $('system-dialog-link').addEventListener('click', onSystemDialogLinkClicked); 97 $('system-dialog-link').addEventListener('click', onSystemDialogLinkClicked);
99 $('mainview').parentElement.removeChild($('dummy-viewer')); 98 $('mainview').parentElement.removeChild($('dummy-viewer'));
100 99
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 */ 141 */
143 function launchNativePrintDialog() { 142 function launchNativePrintDialog() {
144 showingSystemDialog = true; 143 showingSystemDialog = true;
145 $('error-button').disabled = true; 144 $('error-button').disabled = true;
146 $('native-print-dialog-throbber').classList.remove('hidden'); 145 $('native-print-dialog-throbber').classList.remove('hidden');
147 chrome.send('showSystemDialog'); 146 chrome.send('showSystemDialog');
148 } 147 }
149 148
150 /** 149 /**
151 * Disables the controls which need the initiator tab to generate preview 150 * Disables the controls which need the initiator tab to generate preview
151 * data. This function is called when the initiator tab has crashed.
152 * @param {string} initiatorTabURL The URL of the initiator tab.
153 */
154 function onInitiatorTabCrashed(initiatorTabURL) {
155 displayErrorMessageWithButton(
156 localStrings.getString('initiatorTabCrashed'),
157 localStrings.getString('reopenPage'),
158 function() { chrome.send('reloadCrashedInitiatorTab'); });
159 }
160
161 /**
162 * Disables the controls which need the initiator tab to generate preview
152 * data. This function is called when the initiator tab is closed. 163 * data. This function is called when the initiator tab is closed.
153 * @param {string} initiatorTabURL The URL of the initiator tab. 164 * @param {string} initiatorTabURL The URL of the initiator tab.
154 */ 165 */
155 function onInitiatorTabClosed(initiatorTabURL) { 166 function onInitiatorTabClosed(initiatorTabURL) {
156 disableInputElementsInSidebar();
157 displayErrorMessageWithButton( 167 displayErrorMessageWithButton(
158 localStrings.getString('initiatorTabClosed'), 168 localStrings.getString('initiatorTabClosed'),
159 localStrings.getString('reopenPage'), 169 localStrings.getString('reopenPage'),
160 function() { window.location = initiatorTabURL; }); 170 function() { window.location = initiatorTabURL; });
161 } 171 }
162 172
163 /** 173 /**
164 * Gets the selected printer capabilities and updates the controls accordingly. 174 * Gets the selected printer capabilities and updates the controls accordingly.
165 */ 175 */
166 function updateControlsWithSelectedPrinterCapabilities() { 176 function updateControlsWithSelectedPrinterCapabilities() {
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 pdfViewer.grayscale(!color); 735 pdfViewer.grayscale(!color);
726 var printerList = $('printer-list'); 736 var printerList = $('printer-list');
727 cloudprint.setColor(printerList[printerList.selectedIndex], color); 737 cloudprint.setColor(printerList[printerList.selectedIndex], color);
728 } 738 }
729 739
730 /** 740 /**
731 * Display an error message in the center of the preview area. 741 * Display an error message in the center of the preview area.
732 * @param {string} errorMessage The error message to be displayed. 742 * @param {string} errorMessage The error message to be displayed.
733 */ 743 */
734 function displayErrorMessage(errorMessage) { 744 function displayErrorMessage(errorMessage) {
745 disableInputElementsInSidebar();
Lei Zhang 2011/08/16 00:59:23 This will change the behavior for printPreviewFail
kmadhusu 2011/08/16 01:31:37 Done.
746
735 $('print-button').disabled = true; 747 $('print-button').disabled = true;
736 $('overlay-layer').classList.remove('invisible'); 748 $('overlay-layer').classList.remove('invisible');
737 $('dancing-dots-text').classList.add('hidden'); 749 $('dancing-dots-text').classList.add('hidden');
738 $('error-text').innerHTML = errorMessage; 750 $('error-text').innerHTML = errorMessage;
739 $('error-text').classList.remove('hidden'); 751 $('error-text').classList.remove('hidden');
740 var pdfViewer = $('pdf-viewer'); 752 var pdfViewer = $('pdf-viewer');
741 if (pdfViewer) 753 if (pdfViewer)
742 $('mainview').removeChild(pdfViewer); 754 $('mainview').removeChild(pdfViewer);
743 755
744 if (isTabHidden) 756 if (isTabHidden)
745 cancelPendingPrintRequest(); 757 cancelPendingPrintRequest();
746 } 758 }
747 759
748 /** 760 /**
749 * Display an error message in the center of the preview area followed by a 761 * Display an error message in the center of the preview area followed by a
750 * button. 762 * button.
751 * @param {string} errorMessage The error message to be displayed. 763 * @param {string} errorMessage The error message to be displayed.
752 * @param {string} buttonText The text to be displayed within the button. 764 * @param {string} buttonText The text to be displayed within the button.
753 * @param {string} buttonListener The listener to be executed when the button is 765 * @param {string} buttonListener The listener to be executed when the button is
754 * clicked. 766 * clicked.
755 */ 767 */
756 function displayErrorMessageWithButton( 768 function displayErrorMessageWithButton(
757 errorMessage, buttonText, buttonListener) { 769 errorMessage, buttonText, buttonListener) {
770 disableInputElementsInSidebar();
771
758 var errorButton = $('error-button'); 772 var errorButton = $('error-button');
759 errorButton.disabled = false; 773 errorButton.disabled = false;
760 errorButton.textContent = buttonText; 774 errorButton.textContent = buttonText;
761 errorButton.onclick = buttonListener; 775 errorButton.onclick = buttonListener;
762 errorButton.classList.remove('hidden'); 776 errorButton.classList.remove('hidden');
763 $('system-dialog-throbber').classList.add('hidden'); 777 $('system-dialog-throbber').classList.add('hidden');
764 $('native-print-dialog-throbber').classList.add('hidden'); 778 $('native-print-dialog-throbber').classList.add('hidden');
765 displayErrorMessage(errorMessage); 779 displayErrorMessage(errorMessage);
766 } 780 }
767 781
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 953
940 /// Pull in all other scripts in a single shot. 954 /// Pull in all other scripts in a single shot.
941 <include src="print_preview_animations.js"/> 955 <include src="print_preview_animations.js"/>
942 <include src="print_preview_cloud.js"/> 956 <include src="print_preview_cloud.js"/>
943 <include src="print_preview_utils.js"/> 957 <include src="print_preview_utils.js"/>
944 <include src="print_header.js"/> 958 <include src="print_header.js"/>
945 <include src="page_settings.js"/> 959 <include src="page_settings.js"/>
946 <include src="copies_settings.js"/> 960 <include src="copies_settings.js"/>
947 <include src="layout_settings.js"/> 961 <include src="layout_settings.js"/>
948 <include src="color_settings.js"/> 962 <include src="color_settings.js"/>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698