diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-04 08:58:19 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-04 08:58:19 +0000 |
commit | 7d5c3acd124fae8816416374f629752138ec08e1 (patch) | |
tree | e7c0eb48729c056ed4bbafbd3816fafd269a8f15 /chrome/browser/printing | |
parent | 13a9e86809ec0b88304afe5d2126d24b6750a327 (diff) | |
download | chromium_src-7d5c3acd124fae8816416374f629752138ec08e1.zip chromium_src-7d5c3acd124fae8816416374f629752138ec08e1.tar.gz chromium_src-7d5c3acd124fae8816416374f629752138ec08e1.tar.bz2 |
Revert my change to get the tree green. Not sure why the tests became flaky. I'll try to check them in again but in smaller chunks tomorrow.
TBR=mpcomplete
Review URL: http://codereview.chromium.org/21039
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9132 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/printing')
-rw-r--r-- | chrome/browser/printing/print_view_manager.cc | 21 | ||||
-rw-r--r-- | chrome/browser/printing/print_view_manager.h | 6 |
2 files changed, 25 insertions, 2 deletions
diff --git a/chrome/browser/printing/print_view_manager.cc b/chrome/browser/printing/print_view_manager.cc index 4e017e8..bdc9da3 100644 --- a/chrome/browser/printing/print_view_manager.cc +++ b/chrome/browser/printing/print_view_manager.cc @@ -27,6 +27,7 @@ PrintViewManager::PrintViewManager(WebContents& owner) waiting_to_print_(false), inside_inner_message_loop_(false), waiting_to_show_print_dialog_(false) { + memset(&print_params_, 0, sizeof(print_params_)); } PrintViewManager::~PrintViewManager() { @@ -239,6 +240,25 @@ void PrintViewManager::OnNotifyPrintJobEvent( void PrintViewManager::OnNotifyPrintJobInitEvent( const JobEventDetails& event_details) { + ViewMsg_Print_Params old_print_params(print_params_); + + // Backup the print settings relevant to the renderer. + DCHECK_EQ(print_job_->document(), event_details.document()); + event_details.document()->settings().RenderParams(&print_params_); + print_params_.document_cookie = event_details.document()->cookie(); + DCHECK_GT(print_params_.document_cookie, 0); + + // If settings changed + DCHECK(owner_.render_view_host()); + // Equals() doesn't compare the cookie value. + if (owner_.render_view_host() && + owner_.render_view_host()->IsRenderViewLive() && + (!old_print_params.Equals(print_params_) || + !event_details.document()->page_count())) { + // TODO(maruel): Will never happen, this code is about to be deleted. + NOTREACHED(); + } + // Continue even if owner_.render_view_host() is dead because we may already // have buffered all the necessary pages. switch (event_details.type()) { @@ -440,6 +460,7 @@ void PrintViewManager::ReleasePrintJob() { print_job_->DisconnectSource(); // Don't close the worker thread. print_job_ = NULL; + memset(&print_params_, 0, sizeof(print_params_)); } void PrintViewManager::PrintNowInternal() { diff --git a/chrome/browser/printing/print_view_manager.h b/chrome/browser/printing/print_view_manager.h index 3cd0272..405b180 100644 --- a/chrome/browser/printing/print_view_manager.h +++ b/chrome/browser/printing/print_view_manager.h @@ -5,13 +5,12 @@ #ifndef CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_ #define CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_ -#include "base/ref_counted.h" #include "chrome/browser/printing/printed_pages_source.h" #include "chrome/common/notification_observer.h" +#include "chrome/common/render_messages.h" class RenderViewHost; class WebContents; -struct ViewHostMsg_DidPrintPage_Params; namespace printing { @@ -119,6 +118,9 @@ class PrintViewManager : public NotificationObserver, // print_job_ is initialized. bool OpportunisticallyCreatePrintJob(int cookie); + // Cache the last print settings requested to the renderer. + ViewMsg_Print_Params print_params_; + // Manages the low-level talk to the printer. scoped_refptr<PrintJob> print_job_; |