From 000527504bd13181abdb70119269f3da13de32a4 Mon Sep 17 00:00:00 2001 From: "thestig@chromium.org" Date: Thu, 17 Mar 2011 22:13:57 +0000 Subject: Revert 78614 - Print Preview: Cleanup JS createPDFPlugin() a bit. BUG=none TEST=none Review URL: http://codereview.chromium.org/6710009 TBR=thestig@chromium.org Review URL: http://codereview.chromium.org/6708018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@78615 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/resources/print_preview.js | 28 ++++++++++------------------ chrome/browser/ui/webui/print_preview_ui.cc | 5 +++-- 2 files changed, 13 insertions(+), 20 deletions(-) (limited to 'chrome') 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); } -- cgit v1.1