diff options
Diffstat (limited to 'chrome/browser')
5 files changed, 74 insertions, 9 deletions
diff --git a/chrome/browser/printing/print_view_manager.cc b/chrome/browser/printing/print_view_manager.cc index 07e754d..43a760c 100644 --- a/chrome/browser/printing/print_view_manager.cc +++ b/chrome/browser/printing/print_view_manager.cc @@ -48,6 +48,9 @@ PrintViewManager::~PrintViewManager() { } bool PrintViewManager::PrintForSystemDialogNow() { +#if defined(OS_WIN) + NOTREACHED(); +#endif return PrintNowInternal(new PrintMsg_PrintForSystemDialog(routing_id())); } diff --git a/chrome/browser/printing/printing_message_filter.cc b/chrome/browser/printing/printing_message_filter.cc index 57db11b..b1d003f 100644 --- a/chrome/browser/printing/printing_message_filter.cc +++ b/chrome/browser/printing/printing_message_filter.cc @@ -424,7 +424,11 @@ void PrintingMessageFilter::OnUpdatePrintSettingsReply( params.params.document_cookie = printer_query->cookie(); params.pages = PageRange::GetPages(printer_query->settings().ranges()); } - PrintHostMsg_UpdatePrintSettings::WriteReplyParams(reply_msg, params); + PrintHostMsg_UpdatePrintSettings::WriteReplyParams( + reply_msg, + params, + printer_query && + (printer_query->last_status() == printing::PrintingContext::CANCEL)); Send(reply_msg); // If user hasn't cancelled. if (printer_query.get()) { diff --git a/chrome/browser/resources/print_preview/native_layer.js b/chrome/browser/resources/print_preview/native_layer.js index 308c9c2..5da08fc 100644 --- a/chrome/browser/resources/print_preview/native_layer.js +++ b/chrome/browser/resources/print_preview/native_layer.js @@ -273,12 +273,18 @@ cr.define('print_preview', function() { * @param {!print_preview.DocumentInfo} documentInfo Document data model. * @param {boolean=} opt_isOpenPdfInPreview Whether to open the PDF in the * system's preview application. + * @param {boolean=} opt_showSystemDialog Whether to open system dialog for + * advanced settings. */ startPrint: function(destination, printTicketStore, cloudPrintInterface, - documentInfo, opt_isOpenPdfInPreview) { + documentInfo, opt_isOpenPdfInPreview, + opt_showSystemDialog) { assert(printTicketStore.isTicketValid(), 'Trying to print when ticket is not valid'); + assert(!opt_showSystemDialog || (cr.isWindows && destination.isLocal), + 'Implemented for Windows only'); + var ticket = { 'pageRange': printTicketStore.pageRange.getDocumentPageRanges(), 'mediaSize': printTicketStore.mediaSize.getValue(), @@ -304,7 +310,8 @@ cr.define('print_preview', function() { 'requestID': -1, 'fitToPageEnabled': printTicketStore.fitToPage.getValue(), 'pageWidth': documentInfo.pageSize.width, - 'pageHeight': documentInfo.pageSize.height + 'pageHeight': documentInfo.pageSize.height, + 'showSystemDialog': opt_showSystemDialog }; if (!destination.isLocal) { @@ -347,6 +354,7 @@ cr.define('print_preview', function() { /** Shows the system's native printing dialog. */ startShowSystemDialog: function() { + assert(!cr.isWindows); chrome.send('showSystemDialog'); }, diff --git a/chrome/browser/resources/print_preview/print_preview.js b/chrome/browser/resources/print_preview/print_preview.js index 7e25e22..6c16537 100644 --- a/chrome/browser/resources/print_preview/print_preview.js +++ b/chrome/browser/resources/print_preview/print_preview.js @@ -231,6 +231,13 @@ cr.define('print_preview', function() { this.isInAppKioskMode_ = false; /** + * Whether Print with System Dialog option is available. + * @type {boolean} + * @private + */ + this.isSystemDialogAvailable_ = false; + + /** * State of the print preview UI. * @type {print_preview.PrintPreview.UiState_} * @private @@ -243,6 +250,13 @@ cr.define('print_preview', function() { * @private */ this.isPreviewGenerationInProgress_ = true; + + /** + * Whether to show system dialog before next printing. + * @type {boolean} + * @private + */ + this.showSystemDialogBeforeNextPrint_ = false; }; /** @@ -538,7 +552,9 @@ 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.showSystemDialogBeforeNextPrint_); + this.showSystemDialogBeforeNextPrint_ = false; } return PrintPreview.PrintAttemptResult_.PRINTED; }, @@ -558,6 +574,13 @@ cr.define('print_preview', function() { * @private */ openSystemPrintDialog_: function() { + if (!this.shouldShowSystemDialogLink_()) + return; + if (cr.isWindows) { + this.showSystemDialogBeforeNextPrint_ = true; + this.printDocumentOrOpenPdfPreview_(false /*isPdfPreview*/); + return; + } setIsVisible($('system-dialog-throbber'), true); this.setIsEnabled_(false); this.uiState_ = PrintPreview.UiState_.OPENING_NATIVE_PRINT_DIALOG; @@ -599,9 +622,9 @@ cr.define('print_preview', function() { this.appState_.setInitialized(); $('document-title').innerText = settings.documentTitle; - setIsVisible($('system-dialog-link'), - !settings.hidePrintWithSystemDialogLink && - !settings.isInAppKioskMode); + this.isSystemDialogAvailable_ = !settings.hidePrintWithSystemDialogLink && + !settings.isInAppKioskMode; + setIsVisible($('system-dialog-link'), this.shouldShowSystemDialogLink_()); }, /** @@ -1081,6 +1104,23 @@ 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 (!this.isSystemDialogAvailable_) + return false; + 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 @@ -1105,6 +1145,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_(); } diff --git a/chrome/browser/ui/webui/print_preview/print_preview_handler.cc b/chrome/browser/ui/webui/print_preview/print_preview_handler.cc index f872501..9a1159d 100644 --- a/chrome/browser/ui/webui/print_preview/print_preview_handler.cc +++ b/chrome/browser/ui/webui/print_preview/print_preview_handler.cc @@ -832,8 +832,15 @@ void PrintPreviewHandler::HandlePrint(const base::ListValue* args) { ReportUserActionHistogram(PRINT_WITH_CLOUD_PRINT); SendCloudPrintJob(data.get()); } else { - UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.PrintToPrinter", page_count); - ReportUserActionHistogram(PRINT_TO_PRINTER); + bool system_dialog = false; + settings->GetBoolean(printing::kSettingShowSystemDialog, &system_dialog); + if (system_dialog) { + UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.SystemDialog", page_count); + ReportUserActionHistogram(FALLBACK_TO_ADVANCED_SETTINGS_DIALOG); + } else { + UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.PrintToPrinter", page_count); + ReportUserActionHistogram(PRINT_TO_PRINTER); + } ReportPrintSettingsStats(*settings); // This tries to activate the initiator as well, so do not clear the |