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

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

Issue 8343017: Print Preview: Hiding margins UI if an error occurs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments Created 9 years, 2 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
« no previous file with comments | « chrome/browser/resources/print_preview/print_header.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 * Window onload handler, sets up the page and starts print preview by getting 107 * Window onload handler, sets up the page and starts print preview by getting
108 * the printer list. 108 * the printer list.
109 */ 109 */
110 function onLoad() { 110 function onLoad() {
111 cr.enablePlatformSpecificCSSRules(); 111 cr.enablePlatformSpecificCSSRules();
112 initialPreviewRequestID = randomInteger(MIN_REQUEST_ID, MAX_REQUEST_ID); 112 initialPreviewRequestID = randomInteger(MIN_REQUEST_ID, MAX_REQUEST_ID);
113 lastPreviewRequestID = initialPreviewRequestID; 113 lastPreviewRequestID = initialPreviewRequestID;
114 114
115 previewArea = print_preview.PreviewArea.getInstance(); 115 previewArea = print_preview.PreviewArea.getInstance();
116 printHeader = print_preview.PrintHeader.getInstance(); 116 printHeader = print_preview.PrintHeader.getInstance();
117 document.addEventListener('PDFGenerationError', cancelPendingPrintRequest);
117 118
118 if (!checkCompatiblePluginExists()) { 119 if (!checkCompatiblePluginExists()) {
119 disableInputElementsInSidebar(); 120 disableInputElementsInSidebar();
120 previewArea.displayErrorMessageWithButton( 121 previewArea.displayErrorMessageWithButtonAndNotify(
121 localStrings.getString('noPlugin'), 122 localStrings.getString('noPlugin'),
122 localStrings.getString('launchNativeDialog'), 123 localStrings.getString('launchNativeDialog'),
123 launchNativePrintDialog); 124 launchNativePrintDialog);
124 cancelPendingPrintRequest();
125 $('mainview').parentElement.removeChild($('dummy-viewer')); 125 $('mainview').parentElement.removeChild($('dummy-viewer'));
126 return; 126 return;
127 } 127 }
128 128
129 $('system-dialog-link').addEventListener('click', onSystemDialogLinkClicked); 129 $('system-dialog-link').addEventListener('click', onSystemDialogLinkClicked);
130 $('mainview').parentElement.removeChild($('dummy-viewer')); 130 $('mainview').parentElement.removeChild($('dummy-viewer'));
131 131
132 $('printer-list').disabled = true; 132 $('printer-list').disabled = true;
133 133
134 pageSettings = print_preview.PageSettings.getInstance(); 134 pageSettings = print_preview.PageSettings.getInstance();
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 } 184 }
185 185
186 /** 186 /**
187 * Disables the controls which need the initiator tab to generate preview 187 * Disables the controls which need the initiator tab to generate preview
188 * data. This function is called when the initiator tab has crashed. 188 * data. This function is called when the initiator tab has crashed.
189 * @param {string} initiatorTabURL The URL of the initiator tab. 189 * @param {string} initiatorTabURL The URL of the initiator tab.
190 */ 190 */
191 function onInitiatorTabCrashed(initiatorTabURL) { 191 function onInitiatorTabCrashed(initiatorTabURL) {
192 disableInputElementsInSidebar(); 192 disableInputElementsInSidebar();
193 if (initiatorTabURL) { 193 if (initiatorTabURL) {
194 previewArea.displayErrorMessageWithButton( 194 previewArea.displayErrorMessageWithButtonAndNotify(
195 localStrings.getString('initiatorTabCrashed'), 195 localStrings.getString('initiatorTabCrashed'),
196 localStrings.getString('reopenPage'), 196 localStrings.getString('reopenPage'),
197 function() { chrome.send('reloadCrashedInitiatorTab'); }); 197 function() { chrome.send('reloadCrashedInitiatorTab'); });
198 cancelPendingPrintRequest();
199 } else { 198 } else {
200 previewArea.displayErrorMessage( 199 previewArea.displayErrorMessageAndNotify(
201 localStrings.getString('initiatorTabCrashed')); 200 localStrings.getString('initiatorTabCrashed'));
202 cancelPendingPrintRequest();
203 } 201 }
204 } 202 }
205 203
206 /** 204 /**
207 * Disables the controls which need the initiator tab to generate preview 205 * Disables the controls which need the initiator tab to generate preview
208 * data. This function is called when the initiator tab is closed. 206 * data. This function is called when the initiator tab is closed.
209 * @param {string} initiatorTabURL The URL of the initiator tab. 207 * @param {string} initiatorTabURL The URL of the initiator tab.
210 */ 208 */
211 function onInitiatorTabClosed(initiatorTabURL) { 209 function onInitiatorTabClosed(initiatorTabURL) {
212 disableInputElementsInSidebar(); 210 disableInputElementsInSidebar();
213 if (initiatorTabURL) { 211 if (initiatorTabURL) {
214 previewArea.displayErrorMessageWithButton( 212 previewArea.displayErrorMessageWithButtonAndNotify(
215 localStrings.getString('initiatorTabClosed'), 213 localStrings.getString('initiatorTabClosed'),
216 localStrings.getString('reopenPage'), 214 localStrings.getString('reopenPage'),
217 function() { window.location = initiatorTabURL; }); 215 function() { window.location = initiatorTabURL; });
218 cancelPendingPrintRequest();
219 } else { 216 } else {
220 previewArea.displayErrorMessage( 217 previewArea.displayErrorMessageAndNotify(
221 localStrings.getString('initiatorTabClosed')); 218 localStrings.getString('initiatorTabClosed'));
222 cancelPendingPrintRequest();
223 } 219 }
224 } 220 }
225 221
226 /** 222 /**
227 * Gets the selected printer capabilities and updates the controls accordingly. 223 * Gets the selected printer capabilities and updates the controls accordingly.
228 */ 224 */
229 function updateControlsWithSelectedPrinterCapabilities() { 225 function updateControlsWithSelectedPrinterCapabilities() {
230 var printerList = $('printer-list'); 226 var printerList = $('printer-list');
231 var selectedIndex = printerList.selectedIndex; 227 var selectedIndex = printerList.selectedIndex;
232 if (selectedIndex < 0) 228 if (selectedIndex < 0)
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 pdfViewer.grayscale(!color); 703 pdfViewer.grayscale(!color);
708 var printerList = $('printer-list'); 704 var printerList = $('printer-list');
709 cloudprint.setColor(printerList[printerList.selectedIndex], color); 705 cloudprint.setColor(printerList[printerList.selectedIndex], color);
710 } 706 }
711 707
712 /** 708 /**
713 * Display an error message when print preview fails. 709 * Display an error message when print preview fails.
714 * Called from PrintPreviewMessageHandler::OnPrintPreviewFailed(). 710 * Called from PrintPreviewMessageHandler::OnPrintPreviewFailed().
715 */ 711 */
716 function printPreviewFailed() { 712 function printPreviewFailed() {
717 previewArea.displayErrorMessageWithButton( 713 previewArea.displayErrorMessageWithButtonAndNotify(
718 localStrings.getString('previewFailed'), 714 localStrings.getString('previewFailed'),
719 localStrings.getString('launchNativeDialog'), 715 localStrings.getString('launchNativeDialog'),
720 launchNativePrintDialog); 716 launchNativePrintDialog);
721 cancelPendingPrintRequest();
722 } 717 }
723 718
724 /** 719 /**
725 * Display an error message when encountered invalid printer settings. 720 * Display an error message when encountered invalid printer settings.
726 * Called from PrintPreviewMessageHandler::OnInvalidPrinterSettings(). 721 * Called from PrintPreviewMessageHandler::OnInvalidPrinterSettings().
727 */ 722 */
728 function invalidPrinterSettings() { 723 function invalidPrinterSettings() {
729 previewArea.displayErrorMessage( 724 previewArea.displayErrorMessageAndNotify(
730 localStrings.getString('invalidPrinterSettings')); 725 localStrings.getString('invalidPrinterSettings'));
731 cancelPendingPrintRequest();
732 } 726 }
733 727
734 /** 728 /**
735 * Called when the PDF plugin loads its document. 729 * Called when the PDF plugin loads its document.
736 */ 730 */
737 function onPDFLoad() { 731 function onPDFLoad() {
738 if (previewModifiable) { 732 if (previewModifiable) {
739 setPluginPreviewPageCount(); 733 setPluginPreviewPageCount();
740 } 734 }
741 cr.dispatchSimpleEvent(document, 'PDFLoaded'); 735 cr.dispatchSimpleEvent(document, 'PDFLoaded');
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
1073 <include src="copies_settings.js"/> 1067 <include src="copies_settings.js"/>
1074 <include src="header_footer_settings.js"/> 1068 <include src="header_footer_settings.js"/>
1075 <include src="layout_settings.js"/> 1069 <include src="layout_settings.js"/>
1076 <include src="color_settings.js"/> 1070 <include src="color_settings.js"/>
1077 <include src="margin_settings.js"/> 1071 <include src="margin_settings.js"/>
1078 <include src="margin_textbox.js"/> 1072 <include src="margin_textbox.js"/>
1079 <include src="margin_utils.js"/> 1073 <include src="margin_utils.js"/>
1080 <include src="margins_ui.js"/> 1074 <include src="margins_ui.js"/>
1081 <include src="margins_ui_pair.js"/> 1075 <include src="margins_ui_pair.js"/>
1082 <include src="preview_area.js"/> 1076 <include src="preview_area.js"/>
OLDNEW
« no previous file with comments | « chrome/browser/resources/print_preview/print_header.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698