Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 var hasPDFPlugin = true; | |
| 6 | 7 |
| 7 /** | 8 /** |
| 8 * Window onload handler, sets up the page. | 9 * Window onload handler, sets up the page. |
| 9 */ | 10 */ |
| 10 function load() { | 11 function load() { |
| 11 $('cancel-button').addEventListener('click', function(e) { | 12 $('cancel-button').addEventListener('click', function(e) { |
| 12 window.close(); | 13 window.close(); |
| 13 }); | 14 }); |
| 14 | 15 |
| 15 chrome.send('getPrinters'); | 16 chrome.send('getPrinters'); |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 36 } | 37 } |
| 37 | 38 |
| 38 function onPDFLoad() { | 39 function onPDFLoad() { |
| 39 $('pdf-viewer').fitToHeight(); | 40 $('pdf-viewer').fitToHeight(); |
| 40 } | 41 } |
| 41 | 42 |
| 42 /** | 43 /** |
| 43 * Create the PDF plugin or reload the existing one. | 44 * Create the PDF plugin or reload the existing one. |
| 44 */ | 45 */ |
| 45 function createPDFPlugin(url) { | 46 function createPDFPlugin(url) { |
| 47 if (!hasPDFPlugin) { | |
| 48 return; | |
| 49 } | |
| 50 | |
| 46 if ($('pdf-viewer')) { | 51 if ($('pdf-viewer')) { |
| 47 pdfPlugin.reload(); | 52 $('pdf-viewer').reload(); |
|
Lei Zhang
2010/12/06 08:31:55
Typo in previous CL.
| |
| 48 return; | 53 return; |
| 49 } | 54 } |
| 50 | 55 |
| 51 var loadingElement = $('loading'); | 56 var loadingElement = $('loading'); |
| 57 loadingElement.classList.add('hidden'); | |
| 52 var mainView = loadingElement.parentNode; | 58 var mainView = loadingElement.parentNode; |
| 53 mainView.removeChild(loadingElement); | |
| 54 | 59 |
| 55 pdfPlugin = document.createElement('object'); | 60 var pdfPlugin = document.createElement('object'); |
|
Lei Zhang
2010/12/06 08:31:55
Typo in previous CL.
| |
| 56 pdfPlugin.setAttribute('id', 'pdf-viewer'); | 61 pdfPlugin.setAttribute('id', 'pdf-viewer'); |
| 57 pdfPlugin.setAttribute('type', 'application/pdf'); | 62 pdfPlugin.setAttribute('type', 'application/pdf'); |
| 58 pdfPlugin.setAttribute('src', url); | 63 pdfPlugin.setAttribute('src', url); |
| 59 mainView.appendChild(pdfPlugin); | 64 mainView.appendChild(pdfPlugin); |
| 65 if (typeof pdfPlugin.onload != 'function') { | |
|
Lei Zhang
2010/12/06 08:31:55
This check does not work until we add the plugin t
James Hawkins
2010/12/06 18:23:36
You should just be able to check if (pdfPlugin.onl
Lei Zhang
2010/12/06 20:47:14
Done, but this still needs to happen after the plu
| |
| 66 hasPDFPlugin = false; | |
| 67 mainView.removeChild(pdfPlugin); | |
| 68 $('no-plugin').classList.remove('hidden'); | |
|
James Hawkins
2010/12/06 18:23:36
You don't ever set 'hidden' for 'no-plugin', so th
Lei Zhang
2010/12/06 20:47:14
Whoops, added class="hidden" in the html file.
| |
| 69 return; | |
| 70 } | |
| 60 pdfPlugin.onload('onPDFLoad()'); | 71 pdfPlugin.onload('onPDFLoad()'); |
| 61 } | 72 } |
| 62 | 73 |
| 63 window.addEventListener('DOMContentLoaded', load); | 74 window.addEventListener('DOMContentLoaded', load); |
| OLD | NEW |