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

Unified 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: Addressing kmadhusu's and vandebo's comments 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/print_preview/print_preview.js
diff --git a/chrome/browser/resources/print_preview/print_preview.js b/chrome/browser/resources/print_preview/print_preview.js
index b73f6b91197ddca018ddcbf220b551e5e3962d6f..c977f096039280b5198da40f71b3ac75c90b5b15 100644
--- a/chrome/browser/resources/print_preview/print_preview.js
+++ b/chrome/browser/resources/print_preview/print_preview.js
@@ -73,6 +73,10 @@ var colorSettings;
// dialog.
var showingSystemDialog = false;
+// True when there is a pending request to print to pdf. It means that the user
+// has requested to save to pdf but the pdf file is not ready yet.
+var hasPendingPrintToPdfRequest = false;
+
// The range of options in the printer dropdown controlled by cloud print.
var firstCloudPrintOptionPos = 0;
var lastCloudPrintOptionPos = firstCloudPrintOptionPos;
@@ -435,11 +439,11 @@ function requestToPrintDocument() {
if (hasPendingPrintDocumentRequest) {
if (printToPDF) {
- // TODO(thestig) disable controls here.
- } else {
- isTabHidden = true;
- chrome.send('hidePreview');
- }
+ sendPrintDocumentRequest();
+ } else {
+ isTabHidden = true;
+ chrome.send('hidePreview');
+ }
return;
}
@@ -539,6 +543,18 @@ function fileSelectionCancelled() {
}
/**
+ * Called from PrintPreviewUI::OnFileSelectionCompleted to notify the print
+ * preview tab regarding the file selection completed event.
+ */
+function fileSelectionCompleted() {
+ // If the file selection is completed and the tab is not already closed it
+ // means that a pending print to pdf request exists.
+ disableInputElementsInSidebar();
+ hasPendingPrintToPdfRequest = true;
+ showCustomMessage(localStrings.getString('printingToPDFInProgress'));
+}
+
+/**
* Set the default printer. If there is one, generate a print preview.
* @param {string} printer Name of the default printer. Empty if none.
* @param {string} cloudPrintData Cloud print related data to restore if
@@ -823,9 +839,10 @@ function setColor(color) {
function displayErrorMessage(errorMessage) {
$('print-button').disabled = true;
$('overlay-layer').classList.remove('invisible');
- $('dancing-dots-text').classList.add('hidden');
- $('error-text').innerHTML = errorMessage;
- $('error-text').classList.remove('hidden');
+ $('custom-message').innerHTML = errorMessage;
+ $('custom-message').classList.remove('hidden');
+ $('custom-message-with-dots').innerHTML = '';
+ $('custom-message-with-dots').classList.add('hidden');
var pdfViewer = $('pdf-viewer');
if (pdfViewer)
$('mainview').removeChild(pdfViewer);
@@ -881,7 +898,7 @@ function onPDFLoad() {
}
$('pdf-viewer').fitToHeight();
cr.dispatchSimpleEvent(document, 'PDFLoaded');
- hideLoadingAnimation();
+ hideOverlayLayer();
}
function setPluginPreviewPageCount() {
@@ -926,7 +943,7 @@ function reloadPreviewPages(previewUid, previewResponseId) {
isPrintReadyMetafileReady = true;
cr.dispatchSimpleEvent(document, 'updatePrintButton');
- hideLoadingAnimation();
+ hideOverlayLayer();
var pageSet = pageSettings.previouslySelectedPages;
for (var i = 0; i < pageSet.length; i++)
$('pdf-viewer').loadPreviewPage(getPageSrcURL(previewUid, pageSet[i]-1), i);

Powered by Google App Engine
This is Rietveld 408576698