summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralekseys@chromium.org <alekseys@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-01 04:28:09 +0000
committeralekseys@chromium.org <alekseys@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-01 04:28:09 +0000
commit7b285e6a3a63efa842bd61feddc1f151f99a7580 (patch)
tree617720650f34c6ded3defd9c93b3c7f87422d163
parent5b7ab8f43f1ca0eb0c8a1ac1da4e03d7a4140952 (diff)
downloadchromium_src-7b285e6a3a63efa842bd61feddc1f151f99a7580.zip
chromium_src-7b285e6a3a63efa842bd61feddc1f151f99a7580.tar.gz
chromium_src-7b285e6a3a63efa842bd61feddc1f151f99a7580.tar.bz2
Wait for the print preview generation in progress before submitting the print job.
BUG=141426 Review URL: https://codereview.chromium.org/179233003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@254346 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/resources/print_preview/previewarea/preview_area.js2
-rw-r--r--chrome/browser/resources/print_preview/print_preview.js66
2 files changed, 44 insertions, 24 deletions
diff --git a/chrome/browser/resources/print_preview/previewarea/preview_area.js b/chrome/browser/resources/print_preview/previewarea/preview_area.js
index 66bd7dc..231e4af 100644
--- a/chrome/browser/resources/print_preview/previewarea/preview_area.js
+++ b/chrome/browser/resources/print_preview/previewarea/preview_area.js
@@ -520,6 +520,8 @@ cr.define('print_preview', function() {
*/
onTicketChange_: function() {
if (this.previewGenerator_ && this.previewGenerator_.requestPreview()) {
+ cr.dispatchSimpleEvent(
+ this, PreviewArea.EventType.PREVIEW_GENERATION_IN_PROGRESS);
if (this.loadingTimeout_ == null) {
this.loadingTimeout_ = setTimeout(
this.showMessage_.bind(this, PreviewArea.MessageId_.LOADING),
diff --git a/chrome/browser/resources/print_preview/print_preview.js b/chrome/browser/resources/print_preview/print_preview.js
index 471d2a3..9aca101 100644
--- a/chrome/browser/resources/print_preview/print_preview.js
+++ b/chrome/browser/resources/print_preview/print_preview.js
@@ -215,6 +215,17 @@ cr.define('print_preview', function() {
ERROR: 'error'
};
+ /**
+ * What can happen when print preview tries to print.
+ * @enum {string}
+ * @private
+ */
+ PrintPreview.PrintAttemptResult_ = {
+ NOT_READY: 'not-ready',
+ PRINTED: 'printed',
+ READY_WAITING_FOR_PREVIEW: 'ready-waiting-for-preview'
+ };
+
PrintPreview.prototype = {
__proto__: print_preview.Component.prototype,
@@ -414,43 +425,50 @@ cr.define('print_preview', function() {
}
this.setIsEnabled_(false);
this.printHeader_.isCancelButtonEnabled = true;
- if (this.printIfReady_() &&
- ((this.destinationStore_.selectedDestination.isLocal &&
- !this.destinationStore_.selectedDestination.isPrivet &&
- this.destinationStore_.selectedDestination.id !=
- print_preview.Destination.GooglePromotedId.SAVE_AS_PDF) ||
- this.uiState_ == PrintPreview.UiState_.OPENING_PDF_PREVIEW)) {
- // Hide the dialog for now. The actual print command will be issued when
- // the preview generation is done.
- this.nativeLayer_.startHideDialog();
+ var printAttemptResult = this.printIfReady_();
+ if (printAttemptResult == PrintPreview.PrintAttemptResult_.PRINTED ||
+ printAttemptResult ==
+ PrintPreview.PrintAttemptResult_.READY_WAITING_FOR_PREVIEW) {
+ if ((this.destinationStore_.selectedDestination.isLocal &&
+ !this.destinationStore_.selectedDestination.isPrivet &&
+ this.destinationStore_.selectedDestination.id !=
+ print_preview.Destination.GooglePromotedId.SAVE_AS_PDF) ||
+ this.uiState_ == PrintPreview.UiState_.OPENING_PDF_PREVIEW) {
+ // Hide the dialog for now. The actual print command will be issued
+ // when the preview generation is done.
+ this.nativeLayer_.startHideDialog();
+ }
}
},
/**
* Attempts to print if needed and if ready.
- * @return {boolean} Whether a print request was issued.
+ * @return {PrintPreview.PrintAttemptResult_} Attempt result.
* @private
*/
printIfReady_: function() {
- if ((this.uiState_ == PrintPreview.UiState_.PRINTING ||
+ var okToPrint =
+ (this.uiState_ == PrintPreview.UiState_.PRINTING ||
this.uiState_ == PrintPreview.UiState_.OPENING_PDF_PREVIEW ||
this.uiState_ == PrintPreview.UiState_.FILE_SELECTION ||
this.isInKioskAutoPrintMode_) &&
- !this.isPreviewGenerationInProgress_ &&
this.destinationStore_.selectedDestination &&
- this.destinationStore_.selectedDestination.capabilities) {
- assert(this.printTicketStore_.isTicketValid(),
- 'Trying to print with invalid ticket');
- this.nativeLayer_.startPrint(
- this.destinationStore_.selectedDestination,
- this.printTicketStore_,
- this.cloudPrintInterface_,
- this.documentInfo_,
- this.uiState_ == PrintPreview.UiState_.OPENING_PDF_PREVIEW);
- return true;
- } else {
- return false;
+ this.destinationStore_.selectedDestination.capabilities;
+ if (!okToPrint) {
+ return PrintPreview.PrintAttemptResult_.NOT_READY;
+ }
+ if (this.isPreviewGenerationInProgress_) {
+ return PrintPreview.PrintAttemptResult_.READY_WAITING_FOR_PREVIEW;
}
+ assert(this.printTicketStore_.isTicketValid(),
+ 'Trying to print with invalid ticket');
+ this.nativeLayer_.startPrint(
+ this.destinationStore_.selectedDestination,
+ this.printTicketStore_,
+ this.cloudPrintInterface_,
+ this.documentInfo_,
+ this.uiState_ == PrintPreview.UiState_.OPENING_PDF_PREVIEW);
+ return PrintPreview.PrintAttemptResult_.PRINTED;
},
/**