diff options
-rw-r--r-- | chrome/browser/resources/print_preview.js | 28 | ||||
-rw-r--r-- | chrome/browser/ui/webui/print_preview_ui.cc | 5 |
2 files changed, 13 insertions, 20 deletions
diff --git a/chrome/browser/resources/print_preview.js b/chrome/browser/resources/print_preview.js index 9990393..43ad928 100644 --- a/chrome/browser/resources/print_preview.js +++ b/chrome/browser/resources/print_preview.js @@ -133,28 +133,20 @@ function onPDFLoad() { } /** - * Update the print preview when new preview data is available. - * Create the PDF plugin as needed. - * @param {number} pageCount The expected total pages count. - */ -function updatePrintPreview(pageCount) { - // Set the expected page count. - if (expectedPageCount != pageCount) { - expectedPageCount = pageCount; - // Set the initial page range text. - $('pages').value = '1-' + expectedPageCount; - } - - createPDFPlugin(); -} - -/** * Create the PDF plugin or reload the existing one. + * @param {string} url The PdfPlugin data url. + * @param {number} pagesCount The expected total pages count. */ -function createPDFPlugin() { +function createPDFPlugin(url, pagesCount) { if (!hasPDFPlugin) { return; } + // Set the expected pages count. + if (expectedPageCount != pagesCount) { + expectedPageCount = pagesCount; + // Set the initial page range text. + $('pages').value = '1-' + expectedPageCount; + } // Enable the print button. if (!$('printer-list').disabled) { @@ -173,7 +165,7 @@ function createPDFPlugin() { var pdfPlugin = document.createElement('object'); pdfPlugin.setAttribute('id', 'pdf-viewer'); pdfPlugin.setAttribute('type', 'application/pdf'); - pdfPlugin.setAttribute('src', 'chrome://print/print.pdf'); + pdfPlugin.setAttribute('src', url); mainView.appendChild(pdfPlugin); if (!pdfPlugin.onload) { hasPDFPlugin = false; diff --git a/chrome/browser/ui/webui/print_preview_ui.cc b/chrome/browser/ui/webui/print_preview_ui.cc index 8a308f8..d3b243c 100644 --- a/chrome/browser/ui/webui/print_preview_ui.cc +++ b/chrome/browser/ui/webui/print_preview_ui.cc @@ -30,6 +30,7 @@ PrintPreviewUIHTMLSource* PrintPreviewUI::html_source() { } void PrintPreviewUI::PreviewDataIsAvailable(int expected_pages_count) { - CallJavascriptFunction("updatePrintPreview", - FundamentalValue(expected_pages_count)); + StringValue dummy_url("chrome://print/print.pdf"); + FundamentalValue pages_count(expected_pages_count); + CallJavascriptFunction("createPDFPlugin", dummy_url, pages_count); } |