diff options
author | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-17 22:13:57 +0000 |
---|---|---|
committer | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-17 22:13:57 +0000 |
commit | 000527504bd13181abdb70119269f3da13de32a4 (patch) | |
tree | db9088a207178e1e5a6ec4870f0aa4dbada09d77 /chrome | |
parent | 9e480f17a7888e8534d3daa27098ffe533b853b3 (diff) | |
download | chromium_src-000527504bd13181abdb70119269f3da13de32a4.zip chromium_src-000527504bd13181abdb70119269f3da13de32a4.tar.gz chromium_src-000527504bd13181abdb70119269f3da13de32a4.tar.bz2 |
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
Diffstat (limited to 'chrome')
-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); } |