Index: chrome/renderer/print_web_view_helper.cc |
diff --git a/chrome/renderer/print_web_view_helper.cc b/chrome/renderer/print_web_view_helper.cc |
index 7692ec216b8bdefc333519bb3e8a489851fa748f..94a1259188b3011961ce57ad3d0d6d332e68e515 100644 |
--- a/chrome/renderer/print_web_view_helper.cc |
+++ b/chrome/renderer/print_web_view_helper.cc |
@@ -630,21 +630,13 @@ void PrintWebViewHelper::OnPrintPreview(const DictionaryValue& settings) { |
DCHECK(is_preview_); |
print_preview_context_.OnPrintPreview(); |
- if (!InitPrintSettings(print_preview_context_.frame(), |
Lei Zhang
2011/09/13 20:09:53
Since you are removing this, nobody will call Init
arthurhsu
2011/09/14 01:08:03
Done.
|
- print_preview_context_.node(), |
- true)) { |
+ if (!UpdatePrintSettings(settings, true)) { |
Send(new PrintHostMsg_PrintPreviewInvalidPrinterSettings( |
routing_id(), |
print_pages_params_->params.document_cookie)); |
return; |
kmadhusu
2011/09/13 20:01:33
Do you want to clear print_pages_params_ ??
arthurhsu
2011/09/14 01:08:03
Done.
|
} |
- if (!UpdatePrintSettings(settings, true)) { |
- LOG(ERROR) << "UpdatePrintSettings failed"; |
- DidFinishPrinting(FAIL_PREVIEW); |
- return; |
- } |
- |
if (!print_pages_params_->params.is_first_request && |
old_print_pages_params_.get() && |
PrintMsg_Print_Params_IsEqual(*old_print_pages_params_, |
@@ -1066,15 +1058,6 @@ bool PrintWebViewHelper::InitPrintSettings(WebKit::WebFrame* frame, |
// can safely assume there are no printer drivers configured. So we safely |
// terminate. |
bool result = true; |
- if (PrintMsg_Print_Params_IsEmpty(settings.params)) { |
kmadhusu
2011/09/13 20:01:33
You still need this code. This function is used by
Lei Zhang
2011/09/13 20:09:53
I don't think you can remove this for the native d
arthurhsu
2011/09/14 01:08:03
Done.
arthurhsu
2011/09/14 01:08:03
Done.
|
- if (!is_preview) { |
- render_view()->runModalAlertDialog( |
- frame, |
- l10n_util::GetStringUTF16( |
- IDS_PRINT_PREVIEW_INVALID_PRINTER_SETTINGS)); |
- } |
- result = false; |
- } |
if (result && |
(settings.params.dpi < kMinDpi || settings.params.document_cookie == 0)) { |
@@ -1108,8 +1091,22 @@ bool PrintWebViewHelper::UpdatePrintSettings( |
const DictionaryValue& job_settings, bool is_preview) { |
PrintMsg_PrintPages_Params settings; |
+ print_pages_params_.reset(new PrintMsg_PrintPages_Params(settings)); |
Lei Zhang
2011/09/13 20:09:53
This basically resets |print_pages_params_| to all
arthurhsu
2011/09/14 01:08:03
Done.
|
+ Send(new PrintHostMsg_DidGetDocumentCookie( |
kmadhusu
2011/09/13 20:01:33
You need to send this message only during the prev
arthurhsu
2011/09/14 01:08:03
Done.
|
+ routing_id(), print_pages_params_->params.document_cookie)); |
Lei Zhang
2011/09/13 20:09:53
This will always send a value of 0 for the cookie.
arthurhsu
2011/09/14 01:08:03
Done.
|
Send(new PrintHostMsg_UpdatePrintSettings(routing_id(), |
- print_pages_params_->params.document_cookie, job_settings, &settings)); |
+ print_pages_params_->params.document_cookie, job_settings, &settings)); |
+ |
+ if (PrintMsg_Print_Params_IsEmpty(settings.params)) { |
+ if (!is_preview) { |
+ render_view()->runModalAlertDialog( |
+ print_preview_context_.frame(), |
+ l10n_util::GetStringUTF16( |
+ IDS_PRINT_PREVIEW_INVALID_PRINTER_SETTINGS)); |
+ } |
+ return false; |
+ } |
+ |
if (settings.params.dpi < kMinDpi || !settings.params.document_cookie) |
return false; |