Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Side by Side Diff: chrome/browser/resources/print_preview.js

Issue 7063030: PrintPreview: Print Preview is not staying associated with initiator renderer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated the CL Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 12 matching lines...) Expand all
23 // Used to disable some printing options when the preview is not modifiable. 23 // Used to disable some printing options when the preview is not modifiable.
24 var previewModifiable = false; 24 var previewModifiable = false;
25 25
26 // Destination list special value constants. 26 // Destination list special value constants.
27 const PRINT_TO_PDF = 'Print To PDF'; 27 const PRINT_TO_PDF = 'Print To PDF';
28 const MANAGE_PRINTERS = 'Manage Printers'; 28 const MANAGE_PRINTERS = 'Manage Printers';
29 29
30 // State of the print preview settings. 30 // State of the print preview settings.
31 var printSettings = new PrintSettings(); 31 var printSettings = new PrintSettings();
32 32
33 // Preview UI identifier.
34 var previewUIIdentifier = null;
35
33 /** 36 /**
34 * Window onload handler, sets up the page and starts print preview by getting 37 * Window onload handler, sets up the page and starts print preview by getting
35 * the printer list. 38 * the printer list.
36 */ 39 */
37 function onLoad() { 40 function onLoad() {
38 $('system-dialog-link').addEventListener('click', showSystemDialog); 41 $('system-dialog-link').addEventListener('click', showSystemDialog);
39 $('cancel-button').addEventListener('click', handleCancelButtonClick); 42 $('cancel-button').addEventListener('click', handleCancelButtonClick);
40 43
41 if (!checkCompatiblePluginExists()) { 44 if (!checkCompatiblePluginExists()) {
42 displayErrorMessage(localStrings.getString('noPlugin'), false); 45 displayErrorMessage(localStrings.getString('noPlugin'), false);
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 updateCopiesButtonsState(); 489 updateCopiesButtonsState();
487 } 490 }
488 491
489 /** 492 /**
490 * Update the print preview when new preview data is available. 493 * Update the print preview when new preview data is available.
491 * Create the PDF plugin as needed. 494 * Create the PDF plugin as needed.
492 * Called from PrintPreviewUI::PreviewDataIsAvailable(). 495 * Called from PrintPreviewUI::PreviewDataIsAvailable().
493 * @param {number} pageCount The expected total pages count. 496 * @param {number} pageCount The expected total pages count.
494 * @param {string} jobTitle The print job title. 497 * @param {string} jobTitle The print job title.
495 * @param {boolean} modifiable If the preview is modifiable. 498 * @param {boolean} modifiable If the preview is modifiable.
496 * 499 * @param {string} previewUIId Preview UI identifier.
497 */ 500 */
498 function updatePrintPreview(pageCount, jobTitle, modifiable) { 501 function updatePrintPreview(pageCount, jobTitle, modifiable, previewUIId) {
499 var tempPrintSettings = new PrintSettings(); 502 var tempPrintSettings = new PrintSettings();
500 tempPrintSettings.save(); 503 tempPrintSettings.save();
501
502 previewModifiable = modifiable; 504 previewModifiable = modifiable;
503 505
504 if (totalPageCount == -1) 506 if (totalPageCount == -1)
505 totalPageCount = pageCount; 507 totalPageCount = pageCount;
506 508
507 if (previouslySelectedPages.length == 0) 509 if (previouslySelectedPages.length == 0)
508 for (var i = 0; i < totalPageCount; i++) 510 for (var i = 0; i < totalPageCount; i++)
509 previouslySelectedPages.push(i+1); 511 previouslySelectedPages.push(i+1);
510 512
511 if (printSettings.deviceName != tempPrintSettings.deviceName) { 513 if (printSettings.deviceName != tempPrintSettings.deviceName) {
(...skipping 10 matching lines...) Expand all
522 return; 524 return;
523 } 525 }
524 } 526 }
525 527
526 if (getSelectedPagesValidityLevel() != 1) 528 if (getSelectedPagesValidityLevel() != 1)
527 pageRangesFieldChanged(); 529 pageRangesFieldChanged();
528 530
529 // Update the current tab title. 531 // Update the current tab title.
530 document.title = localStrings.getStringF('printPreviewTitleFormat', jobTitle); 532 document.title = localStrings.getStringF('printPreviewTitleFormat', jobTitle);
531 533
534 // Store the preview tab identifier.
535 previewUIIdentifier = previewUIId;
536
532 createPDFPlugin(); 537 createPDFPlugin();
533 updatePrintSummary(); 538 updatePrintSummary();
534 updatePrintButtonState(); 539 updatePrintButtonState();
535 addEventListeners(); 540 addEventListeners();
536 } 541 }
537 542
538 /** 543 /**
539 * Create the PDF plugin or reload the existing one. 544 * Create the PDF plugin or reload the existing one.
540 */ 545 */
541 function createPDFPlugin() { 546 function createPDFPlugin() {
(...skipping 12 matching lines...) Expand all
554 pdfViewer.goToPage('0'); 559 pdfViewer.goToPage('0');
555 } 560 }
556 pdfViewer.reload(); 561 pdfViewer.reload();
557 pdfViewer.grayscale(!isColor()); 562 pdfViewer.grayscale(!isColor());
558 return; 563 return;
559 } 564 }
560 565
561 var pdfPlugin = document.createElement('embed'); 566 var pdfPlugin = document.createElement('embed');
562 pdfPlugin.setAttribute('id', 'pdf-viewer'); 567 pdfPlugin.setAttribute('id', 'pdf-viewer');
563 pdfPlugin.setAttribute('type', 'application/pdf'); 568 pdfPlugin.setAttribute('type', 'application/pdf');
564 pdfPlugin.setAttribute('src', 'chrome://print/print.pdf'); 569 pdfPlugin.setAttribute('src',
570 'chrome://print/print.pdf/' + previewUIIdentifier);
565 var mainView = $('mainview'); 571 var mainView = $('mainview');
566 mainView.appendChild(pdfPlugin); 572 mainView.appendChild(pdfPlugin);
567 pdfPlugin.onload('onPDFLoad()'); 573 pdfPlugin.onload('onPDFLoad()');
568 574
569 // Older version of the PDF plugin may not have this method. 575 // Older version of the PDF plugin may not have this method.
570 // TODO(thestig) Eventually remove this check. 576 // TODO(thestig) Eventually remove this check.
571 if (pdfPlugin.removePrintButton) { 577 if (pdfPlugin.removePrintButton) {
572 pdfPlugin.removePrintButton(); 578 pdfPlugin.removePrintButton();
573 } 579 }
574 580
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
985 this.isLandscape = ''; 991 this.isLandscape = '';
986 } 992 }
987 993
988 /** 994 /**
989 * Takes a snapshot of the print settings. 995 * Takes a snapshot of the print settings.
990 */ 996 */
991 PrintSettings.prototype.save = function() { 997 PrintSettings.prototype.save = function() {
992 this.deviceName = getSelectedPrinterName(); 998 this.deviceName = getSelectedPrinterName();
993 this.isLandscape = isLandscape(); 999 this.isLandscape = isLandscape();
994 } 1000 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698