diff options
author | sverrir@google.com <sverrir@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-19 15:58:01 +0000 |
---|---|---|
committer | sverrir@google.com <sverrir@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-19 15:58:01 +0000 |
commit | 8227045e458705c27ca116a02fd7b9b9a75237ae (patch) | |
tree | 2e694fc454663eedc62b27e99aeef67d476a09ab /chrome/browser/printing/print_view_manager.cc | |
parent | b0fd9c1c6b3ccf0b436d38d181ab26100b3135a6 (diff) | |
download | chromium_src-8227045e458705c27ca116a02fd7b9b9a75237ae.zip chromium_src-8227045e458705c27ca116a02fd7b9b9a75237ae.tar.gz chromium_src-8227045e458705c27ca116a02fd7b9b9a75237ae.tar.bz2 |
Add Print Selection support to Chrome. This change is fairly involved since this means that the printing is done async instead of the fully synchronous mode the normal full page printing is.
This means we create an in memory copy of the selected text for printing.
This is the next step to move to fully async printing with print frame support.
This change also removes the print on demand functionality that was no longer used.
BUG=http://crbug.com/1682
TEST=The print dialog on Windows now contains an option to print selection only. Test that with various pages and various selections.
Review URL: http://codereview.chromium.org/125082
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18815 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/printing/print_view_manager.cc')
-rw-r--r-- | chrome/browser/printing/print_view_manager.cc | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/chrome/browser/printing/print_view_manager.cc b/chrome/browser/printing/print_view_manager.cc index 5976bf3..d775ff5 100644 --- a/chrome/browser/printing/print_view_manager.cc +++ b/chrome/browser/printing/print_view_manager.cc @@ -25,6 +25,7 @@ namespace printing { PrintViewManager::PrintViewManager(TabContents& owner) : owner_(owner), waiting_to_print_(false), + printing_succeeded_(false), inside_inner_message_loop_(false) { } @@ -46,7 +47,7 @@ bool PrintViewManager::OnRenderViewGone(RenderViewHost* render_view_host) { scoped_refptr<PrintedDocument> document(print_job_->document()); if (document) { - // If IsComplete() returns false, the document isn't completely renderered. + // If IsComplete() returns false, the document isn't completely rendered. // Since our renderer is gone, there's nothing to do, cancel it. Otherwise, // the print job may finish without problem. TerminatePrintJob(!document->IsComplete()); @@ -148,7 +149,6 @@ void PrintViewManager::OnNotifyPrintJobEvent( const JobEventDetails& event_details) { switch (event_details.type()) { case JobEventDetails::FAILED: { - // TODO(maruel): bug 1123882 Show some kind of notification. TerminatePrintJob(true); break; } @@ -176,6 +176,7 @@ void PrintViewManager::OnNotifyPrintJobEvent( // Printing is done, we don't need it anymore. // print_job_->is_job_pending() may still be true, depending on the order // of object registration. + printing_succeeded_ = true; ReleasePrintJob(); break; } @@ -202,6 +203,7 @@ bool PrintViewManager::RenderAllMissingPagesNow() { // Is the document already complete? if (print_job_->document() && print_job_->document()->IsComplete()) { waiting_to_print_ = false; + printing_succeeded_ = true; return true; } @@ -266,6 +268,7 @@ bool PrintViewManager::CreateNewPrintJob(PrintJobWorkerOwner* job) { print_job_->Initialize(job, this); registrar_.Add(this, NotificationType::PRINT_JOB_EVENT, Source<PrintJob>(print_job_.get())); + printing_succeeded_ = false; return true; } @@ -287,6 +290,12 @@ void PrintViewManager::DisconnectFromCurrentPrintJob() { } } +void PrintViewManager::PrintingDone(bool success) { + if (print_job_.get()) { + owner_.PrintingDone(print_job_->cookie(), success); + } +} + void PrintViewManager::TerminatePrintJob(bool cancel) { if (!print_job_.get()) return; @@ -314,6 +323,8 @@ void PrintViewManager::ReleasePrintJob() { if (!print_job_.get()) return; + PrintingDone(printing_succeeded_); + registrar_.Remove(this, NotificationType::PRINT_JOB_EVENT, Source<PrintJob>(print_job_.get())); print_job_->DisconnectSource(); |