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

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

Issue 6899051: Print Preview: Get rid of the loading div on failure. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // Whether or not the PDF plugin supports all the capabilities needed for 7 // Whether or not the PDF plugin supports all the capabilities needed for
8 // print preview. 8 // print preview.
9 var hasCompatiblePDFPlugin = true; 9 var hasCompatiblePDFPlugin = true;
10 10
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 * Asks the browser to print the preview PDF based on current print settings. 300 * Asks the browser to print the preview PDF based on current print settings.
301 */ 301 */
302 function printFile() { 302 function printFile() {
303 chrome.send('print', [getSettingsJSON()]); 303 chrome.send('print', [getSettingsJSON()]);
304 } 304 }
305 305
306 /** 306 /**
307 * Asks the browser to generate a preview PDF based on current print settings. 307 * Asks the browser to generate a preview PDF based on current print settings.
308 */ 308 */
309 function requestPrintPreview() { 309 function requestPrintPreview() {
310 $('dancing-dots').classList.remove('hidden');
310 $('dancing-dots').classList.remove('invisible'); 311 $('dancing-dots').classList.remove('invisible');
311 chrome.send('getPreview', [getSettingsJSON()]); 312 chrome.send('getPreview', [getSettingsJSON()]);
312 } 313 }
313 314
314 /** 315 /**
315 * Fill the printer list drop down. 316 * Fill the printer list drop down.
316 * Called from PrintPreviewHandler::SendPrinterList(). 317 * Called from PrintPreviewHandler::SendPrinterList().
317 * @param {Array} printers Array of printer names. 318 * @param {Array} printers Array of printer names.
318 * @param {number} defaultPrinterIndex The index of the default printer. 319 * @param {number} defaultPrinterIndex The index of the default printer.
319 */ 320 */
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 return; 354 return;
354 } 355 }
355 pdfViewer.grayscale(!color); 356 pdfViewer.grayscale(!color);
356 } 357 }
357 358
358 /** 359 /**
359 * Display an error message when print preview fails. 360 * Display an error message when print preview fails.
360 * Called from PrintPreviewMessageHandler::OnPrintPreviewFailed(). 361 * Called from PrintPreviewMessageHandler::OnPrintPreviewFailed().
361 */ 362 */
362 function printPreviewFailed() { 363 function printPreviewFailed() {
364 $('dancing-dots').classList.add('hidden');
363 $('preview-failed').classList.remove('hidden'); 365 $('preview-failed').classList.remove('hidden');
364 366
365 var pdfViewer = $('pdf-viewer'); 367 var pdfViewer = $('pdf-viewer');
366 if (pdfViewer) 368 if (pdfViewer)
367 $('mainview').removeChild(pdfViewer); 369 $('mainview').removeChild(pdfViewer);
368 } 370 }
369 371
370 /** 372 /**
371 * Called when the PDF plugin loads its document. 373 * Called when the PDF plugin loads its document.
372 */ 374 */
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 pdfPlugin.setAttribute('id', 'pdf-viewer'); 436 pdfPlugin.setAttribute('id', 'pdf-viewer');
435 pdfPlugin.setAttribute('type', 'application/pdf'); 437 pdfPlugin.setAttribute('type', 'application/pdf');
436 pdfPlugin.setAttribute('src', 'chrome://print/print.pdf'); 438 pdfPlugin.setAttribute('src', 'chrome://print/print.pdf');
437 var mainView = $('mainview'); 439 var mainView = $('mainview');
438 mainView.appendChild(pdfPlugin); 440 mainView.appendChild(pdfPlugin);
439 441
440 // Check to see if the PDF plugin is our PDF plugin. (or compatible) 442 // Check to see if the PDF plugin is our PDF plugin. (or compatible)
441 if (!pdfPlugin.onload) { 443 if (!pdfPlugin.onload) {
442 hasCompatiblePDFPlugin = false; 444 hasCompatiblePDFPlugin = false;
443 mainView.removeChild(pdfPlugin); 445 mainView.removeChild(pdfPlugin);
446 $('dancing-dots').classList.add('hidden');
444 $('no-plugin').classList.remove('hidden'); 447 $('no-plugin').classList.remove('hidden');
445 return; 448 return;
446 } 449 }
447 pdfPlugin.onload('onPDFLoad()'); 450 pdfPlugin.onload('onPDFLoad()');
448 451
449 // Older version of the PDF plugin may not have this method. 452 // Older version of the PDF plugin may not have this method.
450 // TODO(thestig) Eventually remove this. 453 // TODO(thestig) Eventually remove this.
451 if (pdfPlugin.removePrintButton) { 454 if (pdfPlugin.removePrintButton) {
452 pdfPlugin.removePrintButton(); 455 pdfPlugin.removePrintButton();
453 } 456 }
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 * Returns true if the contents of the two arrays are equal. 709 * Returns true if the contents of the two arrays are equal.
707 */ 710 */
708 function areArraysEqual(array1, array2) { 711 function areArraysEqual(array1, array2) {
709 if (array1.length != array2.length) 712 if (array1.length != array2.length)
710 return false; 713 return false;
711 for (var i = 0; i < array1.length; i++) 714 for (var i = 0; i < array1.length; i++)
712 if(array1[i] != array2[i]) 715 if(array1[i] != array2[i])
713 return false; 716 return false;
714 return true; 717 return true;
715 } 718 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698