summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authordpapad@chromium.org <dpapad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-09 23:28:35 +0000
committerdpapad@chromium.org <dpapad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-09 23:28:35 +0000
commit8692570a7f01059eb5c3bd9a197558f9e056eb26 (patch)
tree6537f6b545c866976865573984a4ba346cc78874 /chrome
parent1330544623496a2ecf13056478ddb04c8e51ca59 (diff)
downloadchromium_src-8692570a7f01059eb5c3bd9a197558f9e056eb26.zip
chromium_src-8692570a7f01059eb5c3bd9a197558f9e056eb26.tar.gz
chromium_src-8692570a7f01059eb5c3bd9a197558f9e056eb26.tar.bz2
Print Preview: Changing displayed error message when PDF Viewer is missing.
BUG=85383 TEST=Launch print preview without having the plugin. A new error message should be displayed, including a button offering to launch the native print dialog. Review URL: http://codereview.chromium.org/7003089 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@88611 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/app/chromium_strings.grd5
-rw-r--r--chrome/browser/resources/print_preview.html3
-rw-r--r--chrome/browser/resources/print_preview.js40
-rw-r--r--chrome/browser/ui/webui/print_preview_data_source.cc2
4 files changed, 33 insertions, 17 deletions
diff --git a/chrome/app/chromium_strings.grd b/chrome/app/chromium_strings.grd
index 0f84059..5e2b3eb 100644
--- a/chrome/app/chromium_strings.grd
+++ b/chrome/app/chromium_strings.grd
@@ -530,7 +530,10 @@ be available for now. -->
</message>
<!-- Print Preview -->
<message name="IDS_PRINT_PREVIEW_NO_PLUGIN" desc="Message to display when the PDF viewer is missing.">
- Sorry! Chromium does not include the PDF viewer built into Google Chrome, which is required to show the print preview.
+ Chromium does not include the PDF viewer which is required for Print Preview to function.
+ </message>
+ <message name="IDS_PRINT_PREVIEW_NATIVE_DIALOG" desc="Option offering the user to open the native print dialog, displayed when the PDF viewer is missing.">
+ Launch native print dialog
</message>
<if expr="os == 'darwin'">
diff --git a/chrome/browser/resources/print_preview.html b/chrome/browser/resources/print_preview.html
index e7b33e6..289ad0b 100644
--- a/chrome/browser/resources/print_preview.html
+++ b/chrome/browser/resources/print_preview.html
@@ -119,8 +119,7 @@
</div>
<div id="error-text" class="hidden"></div>
<br>
- <button id="reopen-page" class="hidden"
- i18n-content="reopenPage"></button>
+ <button id="error-button" class="hidden"></button>
</div>
</div>
</div>
diff --git a/chrome/browser/resources/print_preview.js b/chrome/browser/resources/print_preview.js
index 2b5d938..1c7e18e 100644
--- a/chrome/browser/resources/print_preview.js
+++ b/chrome/browser/resources/print_preview.js
@@ -42,7 +42,9 @@ function onLoad() {
$('cancel-button').addEventListener('click', handleCancelButtonClick);
if (!checkCompatiblePluginExists()) {
- displayErrorMessage(localStrings.getString('noPlugin'), false);
+ displayErrorMessageWithButton(localStrings.getString('noPlugin'),
+ localStrings.getString('launchNativeDialog'),
+ showSystemDialog);
$('mainview').parentElement.removeChild($('dummy-viewer'));
return;
}
@@ -141,10 +143,10 @@ function showSystemDialog() {
* @param {string} initiatorTabURL The URL of the initiator tab.
*/
function onInitiatorTabClosed(initiatorTabURL) {
- $('reopen-page').addEventListener('click', function() {
- window.location = initiatorTabURL;
- });
- displayErrorMessage(localStrings.getString('initiatorTabClosed'), true);
+ displayErrorMessageWithButton(
+ localStrings.getString('initiatorTabClosed'),
+ localStrings.getString('reopenPage'),
+ function() { window.location = initiatorTabURL; });
}
/**
@@ -437,19 +439,12 @@ function setColor(color) {
/**
* Display an error message in the center of the preview area.
* @param {string} errorMessage The error message to be displayed.
- * @param {boolean} showButton Indivates whether the "Reopen the page" button
- * should be displayed.
*/
-function displayErrorMessage(errorMessage, showButton) {
+function displayErrorMessage(errorMessage) {
$('overlay-layer').classList.remove('invisible');
$('dancing-dots-text').classList.add('hidden');
$('error-text').innerHTML = errorMessage;
$('error-text').classList.remove('hidden');
- if (showButton)
- $('reopen-page').classList.remove('hidden');
- else
- $('reopen-page').classList.add('hidden');
-
removeEventListeners();
var pdfViewer = $('pdf-viewer');
if (pdfViewer)
@@ -457,11 +452,28 @@ function displayErrorMessage(errorMessage, showButton) {
}
/**
+ * Display an error message in the center of the preview area followed by a
+ * button.
+ * @param {string} errorMessage The error message to be displayed.
+ * @param {string} buttonText The text to be displayed within the button.
+ * @param {string} buttonListener The listener to be executed when the button is
+ * clicked.
+ */
+function displayErrorMessageWithButton(
+ errorMessage, buttonText, buttonListener) {
+ var errorButton = $('error-button');
+ errorButton.innerHTML = buttonText;
+ errorButton.onclick = buttonListener;
+ errorButton.classList.remove('hidden');
+ displayErrorMessage(errorMessage);
+}
+
+/**
* Display an error message when print preview fails.
* Called from PrintPreviewMessageHandler::OnPrintPreviewFailed().
*/
function printPreviewFailed() {
- displayErrorMessage(localStrings.getString('previewFailed'), false);
+ displayErrorMessage(localStrings.getString('previewFailed'));
}
/**
diff --git a/chrome/browser/ui/webui/print_preview_data_source.cc b/chrome/browser/ui/webui/print_preview_data_source.cc
index 3c5fb71..351fbe8 100644
--- a/chrome/browser/ui/webui/print_preview_data_source.cc
+++ b/chrome/browser/ui/webui/print_preview_data_source.cc
@@ -36,6 +36,8 @@ void SetLocalizedStrings(DictionaryValue* localized_strings) {
localized_strings->SetString(std::string("noPlugin"),
l10n_util::GetStringUTF8(IDS_PRINT_PREVIEW_NO_PLUGIN));
#endif
+ localized_strings->SetString(std::string("launchNativeDialog"),
+ l10n_util::GetStringUTF8(IDS_PRINT_PREVIEW_NATIVE_DIALOG));
localized_strings->SetString(std::string("previewFailed"),
l10n_util::GetStringUTF8(IDS_PRINT_PREVIEW_FAILED));
localized_strings->SetString(std::string("initiatorTabClosed"),