OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 var localStrings = new LocalStrings(); | 5 var localStrings = new LocalStrings(); |
6 | 6 |
7 // The total page count of the previewed document regardless of which pages the | 7 // The total page count of the previewed document regardless of which pages the |
8 // user has selected. | 8 // user has selected. |
9 var totalPageCount = -1; | 9 var totalPageCount = -1; |
10 | 10 |
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
485 updateCopiesButtonsState(); | 485 updateCopiesButtonsState(); |
486 } | 486 } |
487 | 487 |
488 /** | 488 /** |
489 * Update the print preview when new preview data is available. | 489 * Update the print preview when new preview data is available. |
490 * Create the PDF plugin as needed. | 490 * Create the PDF plugin as needed. |
491 * Called from PrintPreviewUI::PreviewDataIsAvailable(). | 491 * Called from PrintPreviewUI::PreviewDataIsAvailable(). |
492 * @param {number} pageCount The expected total pages count. | 492 * @param {number} pageCount The expected total pages count. |
493 * @param {string} jobTitle The print job title. | 493 * @param {string} jobTitle The print job title. |
494 * @param {boolean} modifiable If the preview is modifiable. | 494 * @param {boolean} modifiable If the preview is modifiable. |
495 * | 495 * @param {string} previewUIId Preview UI identifier. |
Lei Zhang
2011/05/27 17:26:53
nit: can you just call this "previewUid" here and
kmadhusu
2011/05/27 23:44:42
Done.
| |
496 */ | 496 */ |
497 function updatePrintPreview(pageCount, jobTitle, modifiable) { | 497 function updatePrintPreview(pageCount, jobTitle, modifiable, previewUIId) { |
498 var tempPrintSettings = new PrintSettings(); | 498 var tempPrintSettings = new PrintSettings(); |
499 tempPrintSettings.save(); | 499 tempPrintSettings.save(); |
500 | 500 |
501 previewModifiable = modifiable; | 501 previewModifiable = modifiable; |
502 | 502 |
503 if (totalPageCount == -1) | 503 if (totalPageCount == -1) |
504 totalPageCount = pageCount; | 504 totalPageCount = pageCount; |
505 | 505 |
506 if (previouslySelectedPages.length == 0) | 506 if (previouslySelectedPages.length == 0) |
507 for (var i = 0; i < totalPageCount; i++) | 507 for (var i = 0; i < totalPageCount; i++) |
(...skipping 13 matching lines...) Expand all Loading... | |
521 return; | 521 return; |
522 } | 522 } |
523 } | 523 } |
524 | 524 |
525 if (getSelectedPagesValidityLevel() != 1) | 525 if (getSelectedPagesValidityLevel() != 1) |
526 pageRangesFieldChanged(); | 526 pageRangesFieldChanged(); |
527 | 527 |
528 // Update the current tab title. | 528 // Update the current tab title. |
529 document.title = localStrings.getStringF('printPreviewTitleFormat', jobTitle); | 529 document.title = localStrings.getStringF('printPreviewTitleFormat', jobTitle); |
530 | 530 |
531 createPDFPlugin(); | 531 createPDFPlugin(previewUIId); |
532 updatePrintSummary(); | 532 updatePrintSummary(); |
533 updatePrintButtonState(); | 533 updatePrintButtonState(); |
534 addEventListeners(); | 534 addEventListeners(); |
535 } | 535 } |
536 | 536 |
537 /** | 537 /** |
538 * Create the PDF plugin or reload the existing one. | 538 * Create the PDF plugin or reload the existing one. |
539 * @param {string} previewUIId Preview UI identifier. | |
539 */ | 540 */ |
540 function createPDFPlugin() { | 541 function createPDFPlugin(previewUIId) { |
541 // Enable the print button. | 542 // Enable the print button. |
542 if (!$('printer-list').disabled) { | 543 if (!$('printer-list').disabled) { |
543 $('print-button').disabled = false; | 544 $('print-button').disabled = false; |
544 } | 545 } |
545 | 546 |
546 var pdfViewer = $('pdf-viewer'); | 547 var pdfViewer = $('pdf-viewer'); |
547 if (pdfViewer) { | 548 if (pdfViewer) { |
548 // Older version of the PDF plugin may not have this method. | 549 // Older version of the PDF plugin may not have this method. |
549 // TODO(thestig) Eventually remove this check. | 550 // TODO(thestig) Eventually remove this check. |
550 if (pdfViewer.goToPage) { | 551 if (pdfViewer.goToPage) { |
551 // Need to call this before the reload(), where the plugin resets its | 552 // Need to call this before the reload(), where the plugin resets its |
552 // internal page count. | 553 // internal page count. |
553 pdfViewer.goToPage('0'); | 554 pdfViewer.goToPage('0'); |
554 } | 555 } |
555 pdfViewer.reload(); | 556 pdfViewer.reload(); |
556 pdfViewer.grayscale(!isColor()); | 557 pdfViewer.grayscale(!isColor()); |
557 return; | 558 return; |
558 } | 559 } |
559 | 560 |
560 var pdfPlugin = document.createElement('embed'); | 561 var pdfPlugin = document.createElement('embed'); |
561 pdfPlugin.setAttribute('id', 'pdf-viewer'); | 562 pdfPlugin.setAttribute('id', 'pdf-viewer'); |
562 pdfPlugin.setAttribute('type', 'application/pdf'); | 563 pdfPlugin.setAttribute('type', 'application/pdf'); |
563 pdfPlugin.setAttribute('src', 'chrome://print/print.pdf'); | 564 pdfPlugin.setAttribute('src', 'chrome://print/print.pdf/' + previewUIId); |
Lei Zhang
2011/05/27 17:26:53
I thought we were going to do chrome://print/print
kmadhusu
2011/05/27 23:44:42
(repeating our in-person conversation) There is no
| |
564 var mainView = $('mainview'); | 565 var mainView = $('mainview'); |
565 mainView.appendChild(pdfPlugin); | 566 mainView.appendChild(pdfPlugin); |
566 pdfPlugin.onload('onPDFLoad()'); | 567 pdfPlugin.onload('onPDFLoad()'); |
567 | 568 |
568 // Older version of the PDF plugin may not have this method. | 569 // Older version of the PDF plugin may not have this method. |
569 // TODO(thestig) Eventually remove this check. | 570 // TODO(thestig) Eventually remove this check. |
570 if (pdfPlugin.removePrintButton) { | 571 if (pdfPlugin.removePrintButton) { |
571 pdfPlugin.removePrintButton(); | 572 pdfPlugin.removePrintButton(); |
572 } | 573 } |
573 | 574 |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
976 this.isLandscape = ''; | 977 this.isLandscape = ''; |
977 } | 978 } |
978 | 979 |
979 /** | 980 /** |
980 * Takes a snapshot of the print settings. | 981 * Takes a snapshot of the print settings. |
981 */ | 982 */ |
982 PrintSettings.prototype.save = function() { | 983 PrintSettings.prototype.save = function() { |
983 this.deviceName = getSelectedPrinterName(); | 984 this.deviceName = getSelectedPrinterName(); |
984 this.isLandscape = isLandscape(); | 985 this.isLandscape = isLandscape(); |
985 } | 986 } |
OLD | NEW |