Commit ba693e5a authored by dpapad@chromium.org's avatar dpapad@chromium.org

Print Preview: Changing error message when initiator tab closes.

Adding a button instead of a link to allow the user to reopen the initiator page.

BUG=83244
TEST=See bug description


Review URL: http://codereview.chromium.org/7051026

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86321 0039d316-1c4b-4281-b951-d872f2087c98
parent 4cd82f72
...@@ -5571,8 +5571,11 @@ Keep your key file in a safe place. You will need it to create new versions of y ...@@ -5571,8 +5571,11 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_PRINT_PREVIEW_FAILED" desc="Message to display when print preview fails."> <message name="IDS_PRINT_PREVIEW_FAILED" desc="Message to display when print preview fails.">
Print preview failed. Print preview failed.
</message> </message>
<message name="IDS_PRINT_PREVIEW_INITIATOR_TAB_CLOSED" desc="Message to display when print preview fails, because the user closed the tab that initiated the print preview before the preview was generated."> <message name="IDS_PRINT_PREVIEW_INITIATOR_TAB_CLOSED" desc="Error message displayed when print preview fails because the user closed the tab that initiated the print preview.">
Print preview failed because the page you are trying to print has been closed. Please click &lt;a href="<ph name="INITIATOR_TAB_URL">$1<ex>http://www.google.com</ex></ph>"&gt;here&lt;/a&gt; to reopen the page and try printing again. Print preview failed because the page you were trying to print has been closed.
</message>
<message name="IDS_PRINT_PREVIEW_REOPEN_PAGE" desc="Text for button displayed when print preview fails because the user closed the tab that initiated the print preview. Clicking the button reopens the page that was closed.">
Reopen the page
</message> </message>
<message name="IDS_PRINT_PREVIEW_PRINT_BUTTON" desc="Print button."> <message name="IDS_PRINT_PREVIEW_PRINT_BUTTON" desc="Print button.">
Print Print
......
...@@ -671,7 +671,7 @@ select { ...@@ -671,7 +671,7 @@ select {
pointer-events: none; pointer-events: none;
} }
.messages { #messages {
color: #404040; color: #404040;
font-size: 15px; font-size: 15px;
left: 25%; left: 25%;
......
...@@ -115,11 +115,16 @@ ...@@ -115,11 +115,16 @@
</div> </div>
<div id="mainview"> <div id="mainview">
<div id="dancing-dots" class="invisible"> <div id="dancing-dots" class="invisible">
<div id="dancing-dots-text" class="messages"> <div id="messages">
<span id="loading" i18n-content="loading"></span> <div id="dancing-dots-text">
<span><span>.</span><span>.</span><span>.</span></span> <span id="loading" i18n-content="loading"></span>
<span><span>.</span><span>.</span><span>.</span></span>
</div>
<div id="error-text" class="hidden"></div>
<br>
<button id="reopen-page" class="hidden"
i18n-content="reopenPage"></button>
</div> </div>
<div id="error-text" class="messages hidden"></div>
</div> </div>
</div> </div>
<object id="dummy-viewer" type="application/pdf" <object id="dummy-viewer" type="application/pdf"
......
...@@ -47,7 +47,7 @@ function onLoad() { ...@@ -47,7 +47,7 @@ function onLoad() {
$('cancel-button').addEventListener('click', handleCancelButtonClick); $('cancel-button').addEventListener('click', handleCancelButtonClick);
if (!checkCompatiblePluginExists()) { if (!checkCompatiblePluginExists()) {
displayErrorMessage(localStrings.getString('noPlugin')); displayErrorMessage(localStrings.getString('noPlugin'), false);
$('mainview').parentElement.removeChild($('dummy-viewer')); $('mainview').parentElement.removeChild($('dummy-viewer'));
return; return;
} }
...@@ -101,8 +101,10 @@ function showSystemDialog() { ...@@ -101,8 +101,10 @@ function showSystemDialog() {
* @param {string} initiatorTabURL The URL of the initiator tab. * @param {string} initiatorTabURL The URL of the initiator tab.
*/ */
function onInitiatorTabClosed(initiatorTabURL) { function onInitiatorTabClosed(initiatorTabURL) {
displayErrorMessage(localStrings.getStringF('initiatorTabClosed', $('reopen-page').addEventListener('click', function() {
initiatorTabURL)); window.location = initiatorTabURL;
});
displayErrorMessage(localStrings.getString('initiatorTabClosed'), true);
} }
/** /**
...@@ -383,14 +385,21 @@ function setColor(color) { ...@@ -383,14 +385,21 @@ function setColor(color) {
/** /**
* Display an error message in the center of the preview area. * Display an error message in the center of the preview area.
* @param (string) errorMessage The error message to be displayed. * @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) { function displayErrorMessage(errorMessage, showButton) {
isPreviewStillLoading = false; isPreviewStillLoading = false;
$('dancing-dots').classList.remove('invisible'); $('dancing-dots').classList.remove('invisible');
$('dancing-dots-text').classList.add('hidden'); $('dancing-dots-text').classList.add('hidden');
$('error-text').innerHTML = errorMessage; $('error-text').innerHTML = errorMessage;
$('error-text').classList.remove('hidden'); $('error-text').classList.remove('hidden');
if (showButton)
$('reopen-page').classList.remove('hidden');
else
$('reopen-page').classList.add('hidden');
setControlsDisabled(true); setControlsDisabled(true);
var pdfViewer = $('pdf-viewer'); var pdfViewer = $('pdf-viewer');
...@@ -403,7 +412,7 @@ function displayErrorMessage(errorMessage) { ...@@ -403,7 +412,7 @@ function displayErrorMessage(errorMessage) {
* Called from PrintPreviewMessageHandler::OnPrintPreviewFailed(). * Called from PrintPreviewMessageHandler::OnPrintPreviewFailed().
*/ */
function printPreviewFailed() { function printPreviewFailed() {
displayErrorMessage(localStrings.getString('previewFailed')); displayErrorMessage(localStrings.getString('previewFailed'), false);
} }
/** /**
......
...@@ -40,6 +40,8 @@ void SetLocalizedStrings(DictionaryValue* localized_strings) { ...@@ -40,6 +40,8 @@ void SetLocalizedStrings(DictionaryValue* localized_strings) {
l10n_util::GetStringUTF8(IDS_PRINT_PREVIEW_FAILED)); l10n_util::GetStringUTF8(IDS_PRINT_PREVIEW_FAILED));
localized_strings->SetString(std::string("initiatorTabClosed"), localized_strings->SetString(std::string("initiatorTabClosed"),
l10n_util::GetStringUTF8(IDS_PRINT_PREVIEW_INITIATOR_TAB_CLOSED)); l10n_util::GetStringUTF8(IDS_PRINT_PREVIEW_INITIATOR_TAB_CLOSED));
localized_strings->SetString(std::string("reopenPage"),
l10n_util::GetStringUTF8(IDS_PRINT_PREVIEW_REOPEN_PAGE));
localized_strings->SetString(std::string("printButton"), localized_strings->SetString(std::string("printButton"),
l10n_util::GetStringUTF8(IDS_PRINT_PREVIEW_PRINT_BUTTON)); l10n_util::GetStringUTF8(IDS_PRINT_PREVIEW_PRINT_BUTTON));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment