Chromium Code Reviews| 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 5d43e211e03b06547efc591f6b8772f2f88e4497..9a59e803640881d11c2da7a56f2c796c02d24ae1 100644 |
| --- a/chrome/browser/resources/print_preview/print_preview.js |
| +++ b/chrome/browser/resources/print_preview/print_preview.js |
| @@ -226,6 +226,13 @@ cr.define('print_preview', function() { |
| * @private |
| */ |
| this.isPreviewGenerationInProgress_ = true; |
| + |
| + /** |
| + * Whether to show system dialog before next printing. |
| + * @type {boolean} |
| + * @private |
| + */ |
| + this.showSystemDialog_ = false; |
| }; |
| /** |
| @@ -520,7 +527,8 @@ cr.define('print_preview', function() { |
| this.printTicketStore_, |
| this.cloudPrintInterface_, |
| this.documentInfo_, |
| - this.uiState_ == PrintPreview.UiState_.OPENING_PDF_PREVIEW); |
| + this.uiState_ == PrintPreview.UiState_.OPENING_PDF_PREVIEW, |
| + this.showSystemDialog_); |
| } |
| return PrintPreview.PrintAttemptResult_.PRINTED; |
| }, |
| @@ -540,6 +548,8 @@ cr.define('print_preview', function() { |
| * @private |
| */ |
| openSystemPrintDialog_: function() { |
| + if (!this.shouldShowSystemDialogLink_()) |
| + return; |
| setIsVisible($('system-dialog-throbber'), true); |
| this.setIsEnabled_(false); |
| this.uiState_ = PrintPreview.UiState_.OPENING_NATIVE_PRINT_DIALOG; |
| @@ -581,9 +591,9 @@ cr.define('print_preview', function() { |
| this.appState_.setInitialized(); |
| $('document-title').innerText = settings.documentTitle; |
| - setIsVisible($('system-dialog-link'), |
| - !settings.hidePrintWithSystemDialogLink && |
| - !settings.isInAppKioskMode); |
| + if (settings.hidePrintWithSystemDialogLink || settings.isInAppKioskMode) |
| + this.shouldShowSystemDialogLink_ = function() { return false; }; |
|
Noam Samuel
2014/08/20 00:04:17
This seems like it could become fairly unreadable
Vitaly Buka (NO REVIEWS)
2014/08/20 02:42:55
Done.
|
| + setIsVisible($('system-dialog-link'), this.shouldShowSystemDialogLink_()); |
| }, |
| /** |
| @@ -1063,6 +1073,21 @@ cr.define('print_preview', function() { |
| }, |
| /** |
| + * Returns true if "Print using system dialog" link should be shown for |
| + * current destination. |
| + * @return {boolean} Returns true if link should be shown. |
| + */ |
| + shouldShowSystemDialogLink_: function() { |
| + if (!cr.isWindows) |
| + return true; |
| + var selectedDest = this.destinationStore_.selectedDestination; |
| + return selectedDest && |
| + selectedDest.origin == print_preview.Destination.Origin.LOCAL && |
| + selectedDest.id != |
| + print_preview.Destination.GooglePromotedId.SAVE_AS_PDF; |
| + }, |
| + |
| + /** |
| * Called when the open-cloud-print-dialog link is clicked. Opens the Google |
| * Cloud Print web dialog. |
| * @private |
| @@ -1087,6 +1112,9 @@ cr.define('print_preview', function() { |
| setIsVisible( |
| $('cloud-print-dialog-link'), |
| selectedDest && !cr.isChromeOS && !selectedDest.isLocal); |
| + setIsVisible( |
| + $('system-dialog-link'), |
| + this.shouldShowSystemDialogLink_()); |
| if (selectedDest && this.isInKioskAutoPrintMode_) { |
| this.onPrintButtonClick_(); |
| } |