Update printing code to latest

This commit is contained in:
Cheng Zhao 2017-01-31 17:38:05 +09:00 committed by Kevin Sawicki
parent 75627ba6ad
commit ab783413a2
16 changed files with 374 additions and 463 deletions

View file

@ -6,15 +6,15 @@
#define CHROME_BROWSER_PRINTING_PRINT_JOB_H_
#include <memory>
#include <vector>
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/message_loop/message_loop.h"
#include "build/build_config.h"
#include "chrome/browser/printing/print_job_worker_owner.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
class Thread;
namespace base {
class RefCountedMemory;
}
@ -49,16 +49,17 @@ class PrintJob : public PrintJobWorkerOwner,
int page_count);
// content::NotificationObserver implementation.
virtual void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) override;
void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) override;
// PrintJobWorkerOwner implementation.
virtual void GetSettingsDone(const PrintSettings& new_settings,
PrintingContext::Result result) override;
virtual PrintJobWorker* DetachWorker(PrintJobWorkerOwner* new_owner) override;
virtual const PrintSettings& settings() const override;
virtual int cookie() const override;
void GetSettingsDone(const PrintSettings& new_settings,
PrintingContext::Result result) override;
std::unique_ptr<PrintJobWorker> DetachWorker(
PrintJobWorkerOwner* new_owner) override;
const PrintSettings& settings() const override;
int cookie() const override;
// Starts the actual printing. Signals the worker that it should begin to
// spool as soon as data is available.
@ -91,23 +92,21 @@ class PrintJob : public PrintJobWorkerOwner,
PrintedDocument* document() const;
#if defined(OS_WIN)
// Let the PrintJob know the 0-based |page_number| of a given printed page.
void AppendPrintedPage(int page_number);
void StartPdfToEmfConversion(
const scoped_refptr<base::RefCountedMemory>& bytes,
const gfx::Size& page_size,
const gfx::Rect& content_area);
void OnPdfToEmfStarted(int page_count);
void OnPdfToEmfPageConverted(int page_number,
float scale_factor,
std::unique_ptr<MetafilePlayer> emf);
#endif // OS_WIN
const gfx::Rect& content_area,
bool print_text_with_gdi);
#endif // defined(OS_WIN)
protected:
virtual ~PrintJob();
~PrintJob() override;
private:
// Updates document_ to a new instance.
// Updates |document_| to a new instance.
void UpdatePrintedDocument(PrintedDocument* new_document);
// Processes a NOTIFY_PRINT_JOB_EVENT notification.
@ -126,6 +125,13 @@ class PrintJob : public PrintJobWorkerOwner,
void HoldUntilStopIsCalled();
#if defined(OS_WIN)
void OnPdfToEmfStarted(int page_count);
void OnPdfToEmfPageConverted(int page_number,
float scale_factor,
std::unique_ptr<MetafilePlayer> emf);
#endif // defined(OS_WIN)
content::NotificationRegistrar registrar_;
// Source that generates the PrintedPage's (i.e. a WebContents). It will be
@ -152,8 +158,9 @@ class PrintJob : public PrintJobWorkerOwner,
#if defined(OS_WIN)
class PdfToEmfState;
std::unique_ptr<PdfToEmfState> ptd_to_emf_state_;
#endif // OS_WIN
std::unique_ptr<PdfToEmfState> pdf_to_emf_state_;
std::vector<int> pdf_page_mapping_;
#endif // defined(OS_WIN)
// Used at shutdown so that we can quit a nested message loop.
base::WeakPtrFactory<PrintJob> quit_factory_;