Index: chrome/browser/printing/print_preview_message_handler.cc |
=================================================================== |
--- chrome/browser/printing/print_preview_message_handler.cc (revision 92494) |
+++ chrome/browser/printing/print_preview_message_handler.cc (working copy) |
@@ -76,20 +76,31 @@ |
} |
void PrintPreviewMessageHandler::OnDidPreviewPage(int page_number, |
- bool* cancel) { |
+ int document_cookie) { |
+ RenderViewHost* rvh = tab_contents()->render_view_host(); |
TabContents* print_preview_tab = GetPrintPreviewTab(); |
if (!print_preview_tab) { |
kmadhusu
2011/07/15 01:22:46
Can you make this if condition (!print_preview_tab
Lei Zhang
2011/07/15 01:48:02
I don't think we need it. I've never seen a crash
kmadhusu
2011/07/15 19:25:46
As we discussed, it can happen. So, modify the if
Lei Zhang
2011/07/15 20:23:35
Done.
|
- // Can't find print preview tab means we should cancel. |
- *cancel = true; |
+ // Can't find print preview tab means we should abort. |
+ StopWorker(document_cookie); |
+ rvh->Send(new PrintMsg_AbortPreview(rvh->routing_id())); |
return; |
} |
PrintPreviewUI* print_preview_ui = |
static_cast<PrintPreviewUI*>(print_preview_tab->web_ui()); |
bool has_pending = print_preview_ui->HasPendingRequests(); |
- if (!has_pending && page_number >= 0) |
+ if (has_pending) { |
+ // Cancel. Next print preview request will cancel the current one. |
+ // Just do the required maintainance work here. |
+ StopWorker(document_cookie); |
+ print_preview_ui->OnPrintPreviewCancelled(); |
+ return; |
+ } |
+ |
+ // Continue |
+ if (page_number >= 0) |
print_preview_ui->OnDidPreviewPage(page_number); |
- *cancel = has_pending; |
+ rvh->Send(new PrintMsg_ContinuePreview(rvh->routing_id())); |
} |
void PrintPreviewMessageHandler::OnPagesReadyForPreview( |
@@ -175,19 +186,6 @@ |
} |
} |
-void PrintPreviewMessageHandler::OnPrintPreviewCancelled(int document_cookie) { |
- // Always need to stop the worker. |
- StopWorker(document_cookie); |
- |
- TabContents* print_preview_tab = GetPrintPreviewTab(); |
- if (!print_preview_tab) |
- return; |
- |
- PrintPreviewUI* print_preview_ui = |
- static_cast<PrintPreviewUI*>(print_preview_tab->web_ui()); |
- print_preview_ui->OnPrintPreviewCancelled(); |
-} |
- |
bool PrintPreviewMessageHandler::OnMessageReceived( |
const IPC::Message& message) { |
bool handled = true; |
@@ -202,8 +200,6 @@ |
OnPagesReadyForPreview) |
IPC_MESSAGE_HANDLER(PrintHostMsg_PrintPreviewFailed, |
OnPrintPreviewFailed) |
- IPC_MESSAGE_HANDLER(PrintHostMsg_PrintPreviewCancelled, |
- OnPrintPreviewCancelled) |
IPC_MESSAGE_UNHANDLED(handled = false) |
IPC_END_MESSAGE_MAP() |
return handled; |