summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-06 21:21:27 +0000
committerthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-06 21:21:27 +0000
commit430fca7d550cc15779a214abe9fa31ce0b8d3e9c (patch)
tree682b9fa96bf12e0c240aa26127ee24922f826322 /chrome
parent88e6577f7fd716a7f0d9f0590d030af6372c6333 (diff)
downloadchromium_src-430fca7d550cc15779a214abe9fa31ce0b8d3e9c.zip
chromium_src-430fca7d550cc15779a214abe9fa31ce0b8d3e9c.tar.gz
chromium_src-430fca7d550cc15779a214abe9fa31ce0b8d3e9c.tar.bz2
Print preview: Display a message when the PDF viewer is missing.
BUG=none TEST=none Review URL: http://codereview.chromium.org/5574003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68380 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/app/generated_resources.grd3
-rw-r--r--chrome/browser/dom_ui/print_preview_ui.cc2
-rw-r--r--chrome/browser/resources/print_preview.html1
-rw-r--r--chrome/browser/resources/print_preview.js17
4 files changed, 20 insertions, 3 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 090970d..aee6b0a 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -5492,6 +5492,9 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_PRINT_PREVIEW_LOADING" desc="Message to display while the print preview renders.">
Loading...
</message>
+ <message name="IDS_PRINT_PREVIEW_NO_PLUGIN" desc="Message to display when the PDF viewer is missing.">
+ PDF viewer is not available.
+ </message>
<message name="IDS_PRINT_PREVIEW_NO_PRINTER" desc="Select box entry when there is no printer.">
No printers found
</message>
diff --git a/chrome/browser/dom_ui/print_preview_ui.cc b/chrome/browser/dom_ui/print_preview_ui.cc
index 6e78be6..91032a7 100644
--- a/chrome/browser/dom_ui/print_preview_ui.cc
+++ b/chrome/browser/dom_ui/print_preview_ui.cc
@@ -31,6 +31,8 @@ void SetLocalizedStrings(DictionaryValue* localized_strings) {
l10n_util::GetStringUTF8(IDS_PRINT_PREVIEW_TITLE));
localized_strings->SetString(std::string("loading"),
l10n_util::GetStringUTF8(IDS_PRINT_PREVIEW_LOADING));
+ localized_strings->SetString(std::string("noPlugin"),
+ l10n_util::GetStringUTF8(IDS_PRINT_PREVIEW_NO_PLUGIN));
localized_strings->SetString(std::string("noPrinter"),
l10n_util::GetStringUTF8(IDS_PRINT_PREVIEW_NO_PRINTER));
diff --git a/chrome/browser/resources/print_preview.html b/chrome/browser/resources/print_preview.html
index e5aee65..b916331 100644
--- a/chrome/browser/resources/print_preview.html
+++ b/chrome/browser/resources/print_preview.html
@@ -76,6 +76,7 @@
<div id="separator"></div>
<div id="mainview">
<p id="loading" i18n-content="loading"></p>
+ <p id="no-plugin" class="hidden" i18n-content="noPlugin"></p>
</div>
<script>
diff --git a/chrome/browser/resources/print_preview.js b/chrome/browser/resources/print_preview.js
index 6af5dd4..38694ea 100644
--- a/chrome/browser/resources/print_preview.js
+++ b/chrome/browser/resources/print_preview.js
@@ -3,6 +3,7 @@
// found in the LICENSE file.
var localStrings = new LocalStrings();
+var hasPDFPlugin = true;
/**
* Window onload handler, sets up the page.
@@ -43,20 +44,30 @@ function onPDFLoad() {
* Create the PDF plugin or reload the existing one.
*/
function createPDFPlugin(url) {
+ if (!hasPDFPlugin) {
+ return;
+ }
+
if ($('pdf-viewer')) {
- pdfPlugin.reload();
+ $('pdf-viewer').reload();
return;
}
var loadingElement = $('loading');
+ loadingElement.classList.add('hidden');
var mainView = loadingElement.parentNode;
- mainView.removeChild(loadingElement);
- pdfPlugin = document.createElement('object');
+ var pdfPlugin = document.createElement('object');
pdfPlugin.setAttribute('id', 'pdf-viewer');
pdfPlugin.setAttribute('type', 'application/pdf');
pdfPlugin.setAttribute('src', url);
mainView.appendChild(pdfPlugin);
+ if (!pdfPlugin.onload) {
+ hasPDFPlugin = false;
+ mainView.removeChild(pdfPlugin);
+ $('no-plugin').classList.remove('hidden');
+ return;
+ }
pdfPlugin.onload('onPDFLoad()');
}