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

Unified Diff: chrome/browser/resources/print_preview.js

Issue 6982030: Print Preview: Detecting plugin existence before generating the preview. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressing comments 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/print_preview.js
diff --git a/chrome/browser/resources/print_preview.js b/chrome/browser/resources/print_preview.js
index 5c2bb573d08f23304ed4f05c38cf0c3fcf627f2b..84c76984606ecab355c4238574755deebf2f061f 100644
--- a/chrome/browser/resources/print_preview.js
+++ b/chrome/browser/resources/print_preview.js
@@ -48,10 +48,18 @@ const MANAGE_PRINTERS = 'Manage Printers';
* the printer list.
*/
function onLoad() {
+ $('system-dialog-link').addEventListener('click', showSystemDialog);
+ $('cancel-button').addEventListener('click', handleCancelButtonClick);
+ $('dummy-viewer').classList.add('hidden');
+
+ if(!checkCompatiblePluginExists()) {
+ displayErrorMessage(localStrings.getString('noPlugin'));
+ return;
+ }
+
$('printer-list').disabled = true;
$('print-button').disabled = true;
$('print-button').addEventListener('click', printFile);
- $('cancel-button').addEventListener('click', handleCancelButtonClick);
$('all-pages').addEventListener('click', onPageSelectionMayHaveChanged);
$('copies').addEventListener('input', copiesFieldChanged);
$('print-pages').addEventListener('click', handleIndividualPagesCheckbox);
@@ -68,7 +76,6 @@ function onLoad() {
$('bw').addEventListener('click', function() { setColor(false); });
$('printer-list').addEventListener(
'change', updateControlsWithSelectedPrinterCapabilities);
- $('system-dialog-link').addEventListener('click', showSystemDialog);
$('increment').addEventListener('click',
function() { onCopiesButtonsClicked(1); });
$('decrement').addEventListener('click',
@@ -323,7 +330,6 @@ function printFile() {
function requestPrintPreview() {
isPreviewStillLoading = true;
setControlsDisabled(true);
- $('dancing-dots').classList.remove('hidden');
$('dancing-dots').classList.remove('invisible');
chrome.send('getPreview', [getSettingsJSON()]);
}
@@ -390,6 +396,7 @@ function setColor(color) {
*/
function displayErrorMessage(errorMessage) {
isPreviewStillLoading = false;
+ $('dancing-dots').classList.remove('invisible');
$('dancing-dots-text').classList.add('hidden');
$('error-text').innerHTML = errorMessage;
$('error-text').classList.remove('hidden');
@@ -510,6 +517,14 @@ function createPDFPlugin() {
}
/**
+ * Returns true if a compatible pdf plugin exists, false if it doesn't.
+ */
+function checkCompatiblePluginExists() {
+ var dummyPlugin = $('dummy-viewer')
+ return !!dummyPlugin.onload;
+}
+
+/**
* Updates the state of print button depending on the user selection.
* The button is enabled only when the following conditions are true.
* 1) The selected page ranges are valid.

Powered by Google App Engine
This is Rietveld 408576698