Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(928)

Unified Diff: chrome/browser/printing/print_preview_message_handler.cc

Issue 7747033: Merge 97702, 97820, 97976 (Closed) Base URL: svn://chrome-svn/chrome/branches/835/src/
Patch Set: Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/printing/print_preview_message_handler.cc
===================================================================
--- chrome/browser/printing/print_preview_message_handler.cc (revision 98330)
+++ chrome/browser/printing/print_preview_message_handler.cc (working copy)
@@ -82,8 +82,10 @@
void PrintPreviewMessageHandler::OnDidGetPreviewPageCount(
const PrintHostMsg_DidGetPreviewPageCount_Params& params) {
- if (params.page_count <= 0)
+ if (params.page_count <= 0) {
+ NOTREACHED();
return;
+ }
TabContents* print_preview_tab = GetPrintPreviewTab();
if (!print_preview_tab)
return;
@@ -95,26 +97,12 @@
void PrintPreviewMessageHandler::OnDidPreviewPage(
const PrintHostMsg_DidPreviewPage_Params& params) {
- RenderViewHost* rvh = tab_contents()->render_view_host();
TabContents* print_preview_tab = GetPrintPreviewTab();
- if (!(print_preview_tab && print_preview_tab->web_ui())) {
- // Can't find print preview tab means we should abort.
- rvh->Send(new PrintMsg_AbortPreview(rvh->routing_id()));
+ if (!print_preview_tab || !print_preview_tab->web_ui())
return;
- }
PrintPreviewUI* print_preview_ui =
static_cast<PrintPreviewUI*>(print_preview_tab->web_ui());
- bool has_pending = print_preview_ui->HasPendingRequests();
- if (has_pending) {
- // Cancel. Next print preview request will cancel the current one.
- // Just do the required maintainance work here.
- StopWorker(print_preview_ui->document_cookie());
- print_preview_ui->OnPrintPreviewCancelled();
- return;
- }
-
- int requested_preview_page_index = INVALID_PAGE_INDEX;
int page_number = params.page_number;
if (page_number == FIRST_PAGE_INDEX)
@@ -127,18 +115,19 @@
print_preview_ui->SetPrintPreviewDataForIndex(page_number, data_bytes);
print_preview_ui->OnDidPreviewPage(page_number, params.preview_request_id);
- // TODO(kmadhusu): Query |PrintPreviewUI| and update
- // |requested_preview_page_index| accordingly.
}
-
- rvh->Send(new PrintMsg_ContinuePreview(rvh->routing_id(),
- requested_preview_page_index));
}
void PrintPreviewMessageHandler::OnPagesReadyForPreview(
const PrintHostMsg_DidPreviewDocument_Params& params) {
+ // Always try to stop the worker.
StopWorker(params.document_cookie);
+ if (params.expected_pages_count <= 0) {
+ NOTREACHED();
+ return;
+ }
+
// Get the print preview tab.
TabContents* print_preview_tab = GetPrintPreviewTab();
// User might have closed it already.
@@ -205,6 +194,11 @@
}
}
+void PrintPreviewMessageHandler::OnPrintPreviewCancelled(int document_cookie) {
+ // Always need to stop the worker.
+ StopWorker(document_cookie);
+}
+
bool PrintPreviewMessageHandler::OnMessageReceived(
const IPC::Message& message) {
bool handled = true;
@@ -219,6 +213,8 @@
OnPagesReadyForPreview)
IPC_MESSAGE_HANDLER(PrintHostMsg_PrintPreviewFailed,
OnPrintPreviewFailed)
+ IPC_MESSAGE_HANDLER(PrintHostMsg_PrintPreviewCancelled,
+ OnPrintPreviewCancelled)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
« no previous file with comments | « chrome/browser/printing/print_preview_message_handler.h ('k') | chrome/browser/printing/printing_message_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698