diff options
author | dpapad@chromium.org <dpapad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-10 04:04:42 +0000 |
---|---|---|
committer | dpapad@chromium.org <dpapad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-10 04:04:42 +0000 |
commit | 3a683dc45501dd6b13c5510b58686990cc56d5c5 (patch) | |
tree | 9cead7b8e9959792974c399b9a1f73da186c43fb | |
parent | 8c91b2303a0b909b37c75b5742360e302ca955c9 (diff) | |
download | chromium_src-3a683dc45501dd6b13c5510b58686990cc56d5c5.zip chromium_src-3a683dc45501dd6b13c5510b58686990cc56d5c5.tar.gz chromium_src-3a683dc45501dd6b13c5510b58686990cc56d5c5.tar.bz2 |
Print Preview: Changing displayed error message when PDF Viewer is missing (again)
Retrying http://codereview.chromium.org/7003089/, adding new string to google_chrome_strings.grd also.
BUG=See linked CR.
TEST=See lined CR.
Review URL: http://codereview.chromium.org/7041009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@88635 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/app/chromium_strings.grd | 5 | ||||
-rw-r--r-- | chrome/app/google_chrome_strings.grd | 3 | ||||
-rw-r--r-- | chrome/browser/resources/print_preview.html | 3 | ||||
-rw-r--r-- | chrome/browser/resources/print_preview.js | 40 | ||||
-rw-r--r-- | chrome/browser/ui/webui/print_preview_data_source.cc | 2 |
5 files changed, 36 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/app/google_chrome_strings.grd b/chrome/app/google_chrome_strings.grd index e4d2e30..95b6e52 100644 --- a/chrome/app/google_chrome_strings.grd +++ b/chrome/app/google_chrome_strings.grd @@ -526,6 +526,9 @@ Chrome supports. --> <message name="IDS_PRINT_PREVIEW_NO_PLUGIN" desc="Message to display when the PDF viewer is missing."> Google Chrome cannot show the print preview when the built-in PDF viewer is disabled. In order to see the preview, please visit <ph name="BEGIN_LINK"><a target="_blank" rel="noreferrer" href="$1"></ph>$1<ph name="END_LINK"></a></ph>, enable the "Chrome PDF Viewer", and try again. </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'"> <message name="IDS_APP_MENU_PRODUCT_NAME" desc="The application's short name, used for the Mac's application menu, activity monitor, etc. This should be less than 16 characters. Example: Chrome, not Google Chrome."> 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"), |