summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authordpapad@chromium.org <dpapad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-10 16:30:55 +0000
committerdpapad@chromium.org <dpapad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-10 16:30:55 +0000
commit78750dd0542424fdca642c03bbed8841f1d129e0 (patch)
tree1c2a9d2c2ddc2697cc9b1ef21b6db5e23d889ae4 /chrome
parent535773382e9f47db97d83bcbe34cb4b89405cfba (diff)
downloadchromium_src-78750dd0542424fdca642c03bbed8841f1d129e0.zip
chromium_src-78750dd0542424fdca642c03bbed8841f1d129e0.tar.gz
chromium_src-78750dd0542424fdca642c03bbed8841f1d129e0.tar.bz2
Print Preview: Adding more specific error message when initiator tab is closed during rendering.
The error text contains a link to the original page so that the user can easily reload the page. BUG=NONE TEST=Open a large doc in print preview and close the initial tab before the preview is generated. Click on the displayed link. Review URL: http://codereview.chromium.org/6976003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@84792 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/app/generated_resources.grd3
-rw-r--r--chrome/browser/printing/print_preview_tab_controller.cc2
-rw-r--r--chrome/browser/resources/print_preview.js27
-rw-r--r--chrome/browser/ui/webui/print_preview_ui.cc6
-rw-r--r--chrome/browser/ui/webui/print_preview_ui.h6
-rw-r--r--chrome/browser/ui/webui/print_preview_ui_html_source.cc2
6 files changed, 31 insertions, 15 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 6955a71..93e1286 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -5519,6 +5519,9 @@ 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.">
Print preview failed.
</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.">
+ 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.
+ </message>
<message name="IDS_PRINT_PREVIEW_PRINT_BUTTON" desc="Print button.">
Print
</message>
diff --git a/chrome/browser/printing/print_preview_tab_controller.cc b/chrome/browser/printing/print_preview_tab_controller.cc
index f2a8075..c0c274e 100644
--- a/chrome/browser/printing/print_preview_tab_controller.cc
+++ b/chrome/browser/printing/print_preview_tab_controller.cc
@@ -143,7 +143,7 @@ void PrintPreviewTabController::Observe(NotificationType type,
// Initiator tab is closed. Disable the controls in preview tab.
PrintPreviewUI* print_preview_ui =
static_cast<PrintPreviewUI*>(preview_tab->web_ui());
- print_preview_ui->OnInitiatorTabClosed();
+ print_preview_ui->OnInitiatorTabClosed(source_tab->GetURL().spec());
// |source_tab| is an initiator tab, update the map entry.
preview_tab_map_[preview_tab] = NULL;
diff --git a/chrome/browser/resources/print_preview.js b/chrome/browser/resources/print_preview.js
index 03a8200..00478b6 100644
--- a/chrome/browser/resources/print_preview.js
+++ b/chrome/browser/resources/print_preview.js
@@ -94,10 +94,12 @@ function showSystemDialog() {
/**
* Disables the controls which need the initiator tab to generate preview
* data. This function is called when the initiator tab is closed.
+ * @param {string} initiatorTabURL The URL of the initiator tab.
*/
-function onInitiatorTabClosed() {
+function onInitiatorTabClosed(initiatorTabURL) {
if (isPreviewStillLoading)
- printPreviewFailed();
+ displayErrorMessage(localStrings.getStringF('initiatorTabClosed',
+ initiatorTabURL));
var controlIDs = ['landscape', 'portrait', 'all-pages', 'print-pages',
'individual-pages', 'printer-list'];
@@ -383,13 +385,13 @@ function setColor(color) {
}
/**
- * Display an error message when print preview fails.
- * Called from PrintPreviewMessageHandler::OnPrintPreviewFailed().
+ * Display an error message in the center of the preview area.
+ * @param (string) errorMessage The error message to be displayed.
*/
-function printPreviewFailed() {
+function displayErrorMessage(errorMessage) {
isPreviewStillLoading = false;
$('dancing-dots-text').classList.add('hidden');
- $('error-text').innerHTML = localStrings.getString('previewFailed');
+ $('error-text').innerHTML = errorMessage;
$('error-text').classList.remove('hidden');
setControlsDisabled(true);
@@ -399,6 +401,14 @@ function printPreviewFailed() {
}
/**
+ * Display an error message when print preview fails.
+ * Called from PrintPreviewMessageHandler::OnPrintPreviewFailed().
+ */
+function printPreviewFailed() {
+ displayErrorMessage(localStrings.getString('printPreviewFailed'));
+}
+
+/**
* Called when the PDF plugin loads its document.
*/
function onPDFLoad() {
@@ -485,10 +495,7 @@ function createPDFPlugin() {
// Check to see if the PDF plugin is our PDF plugin. (or compatible)
if (!pdfPlugin.onload) {
hasCompatiblePDFPlugin = false;
- mainView.removeChild(pdfPlugin);
- $('dancing-dots-text').classList.add('hidden');
- $('error-text').innerHTML = localStrings.getString('noPlugin');
- $('error-text').classList.remove('hidden');
+ displayErrorMessage(localStrings.getString('noPlugin'));
return;
}
pdfPlugin.onload('onPDFLoad()');
diff --git a/chrome/browser/ui/webui/print_preview_ui.cc b/chrome/browser/ui/webui/print_preview_ui.cc
index 3a381ca..e9afb22 100644
--- a/chrome/browser/ui/webui/print_preview_ui.cc
+++ b/chrome/browser/ui/webui/print_preview_ui.cc
@@ -29,8 +29,10 @@ PrintPreviewUIHTMLSource* PrintPreviewUI::html_source() {
return html_source_.get();
}
-void PrintPreviewUI::OnInitiatorTabClosed() {
- CallJavascriptFunction("onInitiatorTabClosed");
+void PrintPreviewUI::OnInitiatorTabClosed(
+ const std::string& initiator_url) {
+ StringValue initiator_tab_url(initiator_url);
+ CallJavascriptFunction("onInitiatorTabClosed", initiator_tab_url);
}
void PrintPreviewUI::OnPreviewDataIsAvailable(int expected_pages_count,
diff --git a/chrome/browser/ui/webui/print_preview_ui.h b/chrome/browser/ui/webui/print_preview_ui.h
index 12baba5..3e10cab 100644
--- a/chrome/browser/ui/webui/print_preview_ui.h
+++ b/chrome/browser/ui/webui/print_preview_ui.h
@@ -26,8 +26,10 @@ class PrintPreviewUI : public WebUI {
const std::string& mime_type);
// Notify the Web UI that initiator tab is closed, so we can disable all
- // the controls that needs initiator tab for generating the preview data.
- void OnInitiatorTabClosed();
+ // the controls that need the initiator tab for generating the preview data.
+ // |initiator_tab_url| is passed in order to display a more accurate error
+ // message.
+ void OnInitiatorTabClosed(const std::string& initiator_tab_url);
private:
scoped_refptr<PrintPreviewUIHTMLSource> html_source_;
diff --git a/chrome/browser/ui/webui/print_preview_ui_html_source.cc b/chrome/browser/ui/webui/print_preview_ui_html_source.cc
index 1f671a6..be4b583 100644
--- a/chrome/browser/ui/webui/print_preview_ui_html_source.cc
+++ b/chrome/browser/ui/webui/print_preview_ui_html_source.cc
@@ -38,6 +38,8 @@ void SetLocalizedStrings(DictionaryValue* localized_strings) {
#endif
localized_strings->SetString(std::string("previewFailed"),
l10n_util::GetStringUTF8(IDS_PRINT_PREVIEW_FAILED));
+ localized_strings->SetString(std::string("initiatorTabClosed"),
+ l10n_util::GetStringUTF8(IDS_PRINT_PREVIEW_INITIATOR_TAB_CLOSED));
localized_strings->SetString(std::string("printButton"),
l10n_util::GetStringUTF8(IDS_PRINT_PREVIEW_PRINT_BUTTON));