Chromium Code Reviews| Index: chrome/browser/printing/print_job_worker.cc |
| diff --git a/chrome/browser/printing/print_job_worker.cc b/chrome/browser/printing/print_job_worker.cc |
| index 1162cc5426117ccb9b3289386f035350812fb777..a0f6fcdb770ce5558b81ebc290ad4c984872dd2d 100644 |
| --- a/chrome/browser/printing/print_job_worker.cc |
| +++ b/chrome/browser/printing/print_job_worker.cc |
| @@ -69,6 +69,12 @@ void PrintJobWorker::SetNewOwner(PrintJobWorkerOwner* new_owner) { |
| owner_ = new_owner; |
| } |
| +void PrintJobWorker::SetPrintDestination( |
| + PrintDestinationInterface* destination) { |
| + DCHECK(destination_.get() == NULL); |
|
robertshield
2012/06/28 17:48:54
Why is this DCHECK present?
If it needs to be he
MAD
2012/06/28 19:05:51
It was just for debugging, forgot to remove... Tha
|
| + destination_ = destination; |
| +} |
| + |
| void PrintJobWorker::GetSettings(bool ask_user_for_settings, |
| gfx::NativeView parent_view, |
| int document_page_count, |
| @@ -85,7 +91,9 @@ void PrintJobWorker::GetSettings(bool ask_user_for_settings, |
| // MessageLoop::current()->SetNestableTasksAllowed(true); |
| printing_context_->set_margin_type(margin_type); |
| - if (ask_user_for_settings) { |
| + // When we delegate to a destination, we don't ask the user for settings. |
| + // TODO(mad): Ask the destination for settings. |
| + if (ask_user_for_settings && destination_.get() == NULL) { |
| BrowserThread::PostTask( |
| BrowserThread::UI, FROM_HERE, |
| base::Bind(&HoldRefCallback, make_scoped_refptr(owner_), |
| @@ -241,6 +249,8 @@ void PrintJobWorker::OnNewPage() { |
| } |
| // We have enough information to initialize page_number_. |
| page_number_.Init(document_->settings(), page_count); |
| + if (destination_.get() != NULL) |
| + destination_->SetPageCount(page_count); |
| } |
| DCHECK_NE(page_number_, PageNumber::npos()); |
| @@ -308,6 +318,17 @@ void PrintJobWorker::SpoolPage(PrintedPage* page) { |
| return; |
| } |
| + if (destination_.get() != NULL) { |
| + std::vector<uint8> metabytes(page->metafile()->GetDataSize()); |
| + bool success = page->metafile()->GetData( |
| + reinterpret_cast<void*>(&metabytes[0]), metabytes.size()); |
| + destination_->SetPageContent( |
| + page->page_number(), |
| + reinterpret_cast<void*>(&metabytes[0]), |
| + metabytes.size()); |
| + return; |
| + } |
| + |
| // Actual printing. |
| #if defined(OS_WIN) || defined(OS_MACOSX) |
| document_->RenderPrintedPage(*page, printing_context_->context()); |