Commit 5fd82d91 authored by thestig@chromium.org's avatar thestig@chromium.org

Print Preview: Provide a link to try printing with the system dialog when...

Print Preview: Provide a link to try printing with the system dialog when print preview fails. Also fix an initiator tab closed case that is being misreported as a failure.

BUG=92599
TEST=none

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98400 0039d316-1c4b-4281-b951-d872f2087c98
parent aafc3e9c
...@@ -566,8 +566,8 @@ be available for now. --> ...@@ -566,8 +566,8 @@ be available for now. -->
<message name="IDS_PRINT_PREVIEW_NO_PLUGIN" desc="Message to display when the PDF viewer is missing."> <message name="IDS_PRINT_PREVIEW_NO_PLUGIN" desc="Message to display when the PDF viewer is missing.">
Chromium does not include the PDF viewer which is required for Print Preview to function. Chromium does not include the PDF viewer which is required for Print Preview to function.
</message> </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."> <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 or when print preview fails.">
Launch native print dialog Print using system dialog…
</message> </message>
<if expr="is_macosx"> <if expr="is_macosx">
......
...@@ -541,8 +541,8 @@ Chrome supports. --> ...@@ -541,8 +541,8 @@ Chrome supports. -->
<message name="IDS_PRINT_PREVIEW_NO_PLUGIN" desc="Message to display when the PDF viewer is missing."> <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">&lt;a target="_blank" rel="noreferrer" href="$1"&gt;</ph>$1<ph name="END_LINK">&lt;/a&gt;</ph>, enable the "Chrome PDF Viewer", and try again. 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">&lt;a target="_blank" rel="noreferrer" href="$1"&gt;</ph>$1<ph name="END_LINK">&lt;/a&gt;</ph>, enable the "Chrome PDF Viewer", and try again.
</message> </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."> <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 or when print preview fails.">
Launch native print dialog Print using system dialog…
</message> </message>
<if expr="is_macosx"> <if expr="is_macosx">
......
...@@ -808,7 +808,9 @@ function displayErrorMessageWithButton( ...@@ -808,7 +808,9 @@ function displayErrorMessageWithButton(
* Called from PrintPreviewMessageHandler::OnPrintPreviewFailed(). * Called from PrintPreviewMessageHandler::OnPrintPreviewFailed().
*/ */
function printPreviewFailed() { function printPreviewFailed() {
displayErrorMessage(localStrings.getString('previewFailed')); displayErrorMessageWithButton(localStrings.getString('previewFailed'),
localStrings.getString('launchNativeDialog'),
launchNativePrintDialog);
} }
/** /**
......
...@@ -76,6 +76,7 @@ enum UserActionBuckets { ...@@ -76,6 +76,7 @@ enum UserActionBuckets {
PREVIEW_FAILED, PREVIEW_FAILED,
PREVIEW_STARTED, PREVIEW_STARTED,
INITIATOR_TAB_CRASHED, INITIATOR_TAB_CRASHED,
INITIATOR_TAB_CLOSED,
USERACTION_BUCKET_BOUNDARY USERACTION_BUCKET_BOUNDARY
}; };
...@@ -495,11 +496,8 @@ void PrintPreviewHandler::HandleGetPreview(const ListValue* args) { ...@@ -495,11 +496,8 @@ void PrintPreviewHandler::HandleGetPreview(const ListValue* args) {
TabContents* initiator_tab = GetInitiatorTab(); TabContents* initiator_tab = GetInitiatorTab();
if (!initiator_tab) { if (!initiator_tab) {
if (!reported_failed_preview_) { ReportUserActionHistogram(INITIATOR_TAB_CLOSED);
ReportUserActionHistogram(PREVIEW_FAILED); print_preview_ui->OnInitiatorTabClosed();
reported_failed_preview_ = true;
}
print_preview_ui->OnPrintPreviewFailed();
return; return;
} }
...@@ -890,6 +888,13 @@ void PrintPreviewHandler::OnTabDestroyed() { ...@@ -890,6 +888,13 @@ void PrintPreviewHandler::OnTabDestroyed() {
wrapper->print_view_manager()->set_observer(NULL); wrapper->print_view_manager()->set_observer(NULL);
} }
void PrintPreviewHandler::OnPrintPreviewFailed() {
if (reported_failed_preview_)
return;
reported_failed_preview_ = true;
ReportUserActionHistogram(PREVIEW_FAILED);
}
void PrintPreviewHandler::FileSelected(const FilePath& path, void PrintPreviewHandler::FileSelected(const FilePath& path,
int index, void* params) { int index, void* params) {
PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>(web_ui_); PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>(web_ui_);
......
...@@ -55,6 +55,9 @@ class PrintPreviewHandler : public WebUIMessageHandler, ...@@ -55,6 +55,9 @@ class PrintPreviewHandler : public WebUIMessageHandler,
// observer. // observer.
void OnTabDestroyed(); void OnTabDestroyed();
// Called when print preview failed.
void OnPrintPreviewFailed();
private: private:
friend class PrintSystemTaskProxy; friend class PrintSystemTaskProxy;
......
...@@ -224,6 +224,7 @@ void PrintPreviewUI::OnCancelPendingPreviewRequest() { ...@@ -224,6 +224,7 @@ void PrintPreviewUI::OnCancelPendingPreviewRequest() {
} }
void PrintPreviewUI::OnPrintPreviewFailed() { void PrintPreviewUI::OnPrintPreviewFailed() {
handler_->OnPrintPreviewFailed();
CallJavascriptFunction("printPreviewFailed"); CallJavascriptFunction("printPreviewFailed");
} }
......
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