| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/printing/print_view_manager.h" | 5 #include "chrome/browser/printing/print_view_manager.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| 11 #include "chrome/browser/printing/print_job.h" | 11 #include "chrome/browser/printing/print_job.h" |
| 12 #include "chrome/browser/printing/print_job_manager.h" | 12 #include "chrome/browser/printing/print_job_manager.h" |
| 13 #include "chrome/browser/printing/print_preview_tab_controller.h" | 13 #include "chrome/browser/printing/print_preview_tab_controller.h" |
| 14 #include "chrome/browser/printing/printer_query.h" | 14 #include "chrome/browser/printing/printer_query.h" |
| 15 #include "chrome/browser/printing/print_view_manager_observer.h" | 15 #include "chrome/browser/printing/print_view_manager_observer.h" |
| 16 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 16 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 17 #include "chrome/browser/ui/webui/print_preview_ui.h" | 17 #include "chrome/browser/ui/webui/print_preview_ui.h" |
| 18 #include "chrome/common/chrome_notification_types.h" | 18 #include "chrome/common/chrome_notification_types.h" |
| 19 #include "chrome/common/print_messages.h" | 19 #include "chrome/common/print_messages.h" |
| 20 #include "content/browser/renderer_host/render_view_host.h" | 20 #include "content/browser/renderer_host/render_view_host.h" |
| 21 #include "content/browser/tab_contents/tab_contents.h" | 21 #include "content/browser/tab_contents/tab_contents.h" |
| 22 #include "content/common/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
| 23 #include "content/public/browser/notification_details.h" | 23 #include "content/public/browser/notification_details.h" |
| 24 #include "content/public/browser/notification_source.h" | 24 #include "content/public/browser/notification_source.h" |
| 25 #include "grit/generated_resources.h" | 25 #include "grit/generated_resources.h" |
| 26 #include "printing/metafile.h" | 26 #include "printing/metafile.h" |
| 27 #include "printing/metafile_impl.h" | 27 #include "printing/metafile_impl.h" |
| 28 #include "printing/printed_document.h" | 28 #include "printing/printed_document.h" |
| 29 #include "ui/base/l10n/l10n_util.h" | 29 #include "ui/base/l10n/l10n_util.h" |
| 30 | 30 |
| 31 using base::TimeDelta; | 31 using base::TimeDelta; |
| 32 | 32 |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 params.actual_shrink, | 229 params.actual_shrink, |
| 230 params.page_size, | 230 params.page_size, |
| 231 params.content_area); | 231 params.content_area); |
| 232 | 232 |
| 233 ShouldQuitFromInnerMessageLoop(); | 233 ShouldQuitFromInnerMessageLoop(); |
| 234 } | 234 } |
| 235 | 235 |
| 236 void PrintViewManager::OnPrintingFailed(int cookie) { | 236 void PrintViewManager::OnPrintingFailed(int cookie) { |
| 237 ReleasePrinterQuery(cookie); | 237 ReleasePrinterQuery(cookie); |
| 238 | 238 |
| 239 NotificationService::current()->Notify( | 239 content::NotificationService::current()->Notify( |
| 240 chrome::NOTIFICATION_PRINT_JOB_RELEASED, | 240 chrome::NOTIFICATION_PRINT_JOB_RELEASED, |
| 241 content::Source<TabContents>(tab_contents()), | 241 content::Source<TabContents>(tab_contents()), |
| 242 NotificationService::NoDetails()); | 242 content::NotificationService::NoDetails()); |
| 243 } | 243 } |
| 244 | 244 |
| 245 bool PrintViewManager::OnMessageReceived(const IPC::Message& message) { | 245 bool PrintViewManager::OnMessageReceived(const IPC::Message& message) { |
| 246 bool handled = true; | 246 bool handled = true; |
| 247 IPC_BEGIN_MESSAGE_MAP(PrintViewManager, message) | 247 IPC_BEGIN_MESSAGE_MAP(PrintViewManager, message) |
| 248 IPC_MESSAGE_HANDLER(PrintHostMsg_DidGetPrintedPagesCount, | 248 IPC_MESSAGE_HANDLER(PrintHostMsg_DidGetPrintedPagesCount, |
| 249 OnDidGetPrintedPagesCount) | 249 OnDidGetPrintedPagesCount) |
| 250 IPC_MESSAGE_HANDLER(PrintHostMsg_DidGetDocumentCookie, | 250 IPC_MESSAGE_HANDLER(PrintHostMsg_DidGetDocumentCookie, |
| 251 OnDidGetDocumentCookie) | 251 OnDidGetDocumentCookie) |
| 252 IPC_MESSAGE_HANDLER(PrintHostMsg_DidShowPrintDialog, OnDidShowPrintDialog) | 252 IPC_MESSAGE_HANDLER(PrintHostMsg_DidShowPrintDialog, OnDidShowPrintDialog) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 271 } | 271 } |
| 272 } | 272 } |
| 273 } | 273 } |
| 274 | 274 |
| 275 void PrintViewManager::OnNotifyPrintJobEvent( | 275 void PrintViewManager::OnNotifyPrintJobEvent( |
| 276 const JobEventDetails& event_details) { | 276 const JobEventDetails& event_details) { |
| 277 switch (event_details.type()) { | 277 switch (event_details.type()) { |
| 278 case JobEventDetails::FAILED: { | 278 case JobEventDetails::FAILED: { |
| 279 TerminatePrintJob(true); | 279 TerminatePrintJob(true); |
| 280 | 280 |
| 281 NotificationService::current()->Notify( | 281 content::NotificationService::current()->Notify( |
| 282 chrome::NOTIFICATION_PRINT_JOB_RELEASED, | 282 chrome::NOTIFICATION_PRINT_JOB_RELEASED, |
| 283 content::Source<TabContentsWrapper>(tab_), | 283 content::Source<TabContentsWrapper>(tab_), |
| 284 NotificationService::NoDetails()); | 284 content::NotificationService::NoDetails()); |
| 285 break; | 285 break; |
| 286 } | 286 } |
| 287 case JobEventDetails::USER_INIT_DONE: | 287 case JobEventDetails::USER_INIT_DONE: |
| 288 case JobEventDetails::DEFAULT_INIT_DONE: | 288 case JobEventDetails::DEFAULT_INIT_DONE: |
| 289 case JobEventDetails::USER_INIT_CANCELED: { | 289 case JobEventDetails::USER_INIT_CANCELED: { |
| 290 NOTREACHED(); | 290 NOTREACHED(); |
| 291 break; | 291 break; |
| 292 } | 292 } |
| 293 case JobEventDetails::ALL_PAGES_REQUESTED: { | 293 case JobEventDetails::ALL_PAGES_REQUESTED: { |
| 294 ShouldQuitFromInnerMessageLoop(); | 294 ShouldQuitFromInnerMessageLoop(); |
| 295 break; | 295 break; |
| 296 } | 296 } |
| 297 case JobEventDetails::NEW_DOC: | 297 case JobEventDetails::NEW_DOC: |
| 298 case JobEventDetails::NEW_PAGE: | 298 case JobEventDetails::NEW_PAGE: |
| 299 case JobEventDetails::PAGE_DONE: | 299 case JobEventDetails::PAGE_DONE: |
| 300 case JobEventDetails::DOC_DONE: { | 300 case JobEventDetails::DOC_DONE: { |
| 301 // Don't care about the actual printing process. | 301 // Don't care about the actual printing process. |
| 302 break; | 302 break; |
| 303 } | 303 } |
| 304 case JobEventDetails::JOB_DONE: { | 304 case JobEventDetails::JOB_DONE: { |
| 305 // Printing is done, we don't need it anymore. | 305 // Printing is done, we don't need it anymore. |
| 306 // print_job_->is_job_pending() may still be true, depending on the order | 306 // print_job_->is_job_pending() may still be true, depending on the order |
| 307 // of object registration. | 307 // of object registration. |
| 308 printing_succeeded_ = true; | 308 printing_succeeded_ = true; |
| 309 ReleasePrintJob(); | 309 ReleasePrintJob(); |
| 310 | 310 |
| 311 NotificationService::current()->Notify( | 311 content::NotificationService::current()->Notify( |
| 312 chrome::NOTIFICATION_PRINT_JOB_RELEASED, | 312 chrome::NOTIFICATION_PRINT_JOB_RELEASED, |
| 313 content::Source<TabContentsWrapper>(tab_), | 313 content::Source<TabContentsWrapper>(tab_), |
| 314 NotificationService::NoDetails()); | 314 content::NotificationService::NoDetails()); |
| 315 break; | 315 break; |
| 316 } | 316 } |
| 317 default: { | 317 default: { |
| 318 NOTREACHED(); | 318 NOTREACHED(); |
| 319 break; | 319 break; |
| 320 } | 320 } |
| 321 } | 321 } |
| 322 } | 322 } |
| 323 | 323 |
| 324 bool PrintViewManager::RenderAllMissingPagesNow() { | 324 bool PrintViewManager::RenderAllMissingPagesNow() { |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 } | 526 } |
| 527 | 527 |
| 528 bool PrintViewManager::PrintNowInternal(IPC::Message* message) { | 528 bool PrintViewManager::PrintNowInternal(IPC::Message* message) { |
| 529 // Don't print / print preview interstitials. | 529 // Don't print / print preview interstitials. |
| 530 if (tab_contents()->showing_interstitial_page()) | 530 if (tab_contents()->showing_interstitial_page()) |
| 531 return false; | 531 return false; |
| 532 return Send(message); | 532 return Send(message); |
| 533 } | 533 } |
| 534 | 534 |
| 535 } // namespace printing | 535 } // namespace printing |
| OLD | NEW |