Chromium Code Reviews| Index: chrome/browser/printing/print_view_manager.cc |
| diff --git a/chrome/browser/printing/print_view_manager.cc b/chrome/browser/printing/print_view_manager.cc |
| index 65b63f0e4e34ab0989f4ed0b11a03b234e9b57ad..f8546b9be3d4d80f7719d4a1752bea11a9724b7a 100644 |
| --- a/chrome/browser/printing/print_view_manager.cc |
| +++ b/chrome/browser/printing/print_view_manager.cc |
| @@ -11,6 +11,7 @@ |
| #include "chrome/browser/printing/print_job_manager.h" |
| #include "chrome/browser/printing/print_preview_tab_controller.h" |
| #include "chrome/browser/printing/printer_query.h" |
| +#include "chrome/browser/printing/print_view_manager_delegate.h" |
| #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| #include "chrome/browser/ui/webui/print_preview_ui.h" |
| #include "chrome/common/print_messages.h" |
| @@ -47,7 +48,8 @@ PrintViewManager::PrintViewManager(TabContentsWrapper* tab) |
| number_pages_(0), |
| printing_succeeded_(false), |
| inside_inner_message_loop_(false), |
| - is_title_overridden_(false) { |
| + is_title_overridden_(false), |
| + delegate_(NULL) { |
| #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| expecting_first_page_ = true; |
| #endif |
| @@ -57,7 +59,9 @@ PrintViewManager::~PrintViewManager() { |
| DisconnectFromCurrentPrintJob(); |
| } |
| -bool PrintViewManager::PrintNow() { |
| +bool PrintViewManager::PrintNow(PrintViewManagerDelegate* delegate) { |
| + delegate_ = delegate; |
| + |
| // Don't print interstitials. |
| if (tab_contents()->showing_interstitial_page()) |
| return false; |
| @@ -123,6 +127,11 @@ void PrintViewManager::OnDidGetPrintedPagesCount(int cookie, int number_pages) { |
| OpportunisticallyCreatePrintJob(cookie); |
| } |
| +void PrintViewManager::OnDidShowPrintDialog() { |
| + if (delegate_) |
| + delegate_->OnPrintDialogShown(); |
|
Lei Zhang
2011/06/21 01:54:46
set |delegate_| to NULL here instead of below?
James Hawkins
2011/06/22 23:47:24
No, why would we remove the delegate here? That's
|
| +} |
| + |
| void PrintViewManager::OnDidPrintPage( |
| const PrintHostMsg_DidPrintPage_Params& params) { |
| if (!OpportunisticallyCreatePrintJob(params.document_cookie)) |
| @@ -205,6 +214,7 @@ bool PrintViewManager::OnMessageReceived(const IPC::Message& message) { |
| IPC_BEGIN_MESSAGE_MAP(PrintViewManager, message) |
| IPC_MESSAGE_HANDLER(PrintHostMsg_DidGetPrintedPagesCount, |
| OnDidGetPrintedPagesCount) |
| + IPC_MESSAGE_HANDLER(PrintHostMsg_DidShowPrintDialog, OnDidShowPrintDialog) |
| IPC_MESSAGE_HANDLER(PrintHostMsg_DidPrintPage, OnDidPrintPage) |
| IPC_MESSAGE_HANDLER(PrintHostMsg_PrintingFailed, OnPrintingFailed) |
| IPC_MESSAGE_UNHANDLED(handled = false) |
| @@ -384,6 +394,8 @@ void PrintViewManager::TerminatePrintJob(bool cancel) { |
| if (!print_job_.get()) |
| return; |
| + delegate_ = NULL; |
| + |
| if (cancel) { |
| // We don't need the metafile data anymore because the printing is canceled. |
| print_job_->Cancel(); |