Chromium Code Reviews| Index: chrome/browser/ui/webui/print_preview/extension_printer_handler.h |
| diff --git a/chrome/browser/ui/webui/print_preview/extension_printer_handler.h b/chrome/browser/ui/webui/print_preview/extension_printer_handler.h |
| index 6ea9e0184a6c755290b00e047b99d033654b9ac8..4350f15941ffde562252e5bca82d76815a864d9a 100644 |
| --- a/chrome/browser/ui/webui/print_preview/extension_printer_handler.h |
| +++ b/chrome/browser/ui/webui/print_preview/extension_printer_handler.h |
| @@ -11,6 +11,7 @@ |
| #include "base/memory/scoped_ptr.h" |
| #include "base/memory/weak_ptr.h" |
| #include "chrome/browser/ui/webui/print_preview/printer_handler.h" |
| +#include "extensions/browser/api/printer_provider/printer_provider_api.h" |
| namespace base { |
| class DictionaryValue; |
| @@ -22,10 +23,27 @@ namespace content { |
| class BrowserContext; |
| } |
| +namespace cloud_devices { |
| +class CloudDeviceDescription; |
| +} |
| + |
| +namespace gfx { |
| +class Size; |
| +} |
| + |
| +#if defined(ENABLE_SERVICE_DISCOVERY) |
| +namespace local_discovery { |
| +class PWGRasterConverter; |
| +} |
| +#endif |
| + |
| // Implementation of PrinterHandler interface backed by printerProvider |
| // extension API. |
| class ExtensionPrinterHandler : public PrinterHandler { |
| public: |
| + using RefCountedMemoryCallback = |
| + base::Callback<void(const scoped_refptr<base::RefCountedMemory>&)>; |
| + |
| explicit ExtensionPrinterHandler(content::BrowserContext* browser_context); |
| ~ExtensionPrinterHandler() override; |
| @@ -41,10 +59,28 @@ class ExtensionPrinterHandler : public PrinterHandler { |
| void StartPrint(const std::string& destination_id, |
| const std::string& capability, |
| const std::string& ticket_json, |
| + const gfx::Size& size, |
| const scoped_refptr<base::RefCountedMemory>& print_data, |
| const PrinterHandler::PrintCallback& callback) override; |
| private: |
| + // Converts |data| to PWG raster format (from PDF) for a printer described |
| + // by |printer_description|. |
| + // |callback| is called with the converted data. |
| + void ConvertToPWGRaster( |
| + const scoped_refptr<base::RefCountedMemory>& data, |
| + const cloud_devices::CloudDeviceDescription& printer_description, |
| + const gfx::Size& size, |
| + const RefCountedMemoryCallback& callback); |
| + |
| + // Sets print job document data and dispatches it using printerProvider API. |
| + // TODO(tbarzic): Move PrinterProvider::PrintJob to it's own file so it can |
| + // be forward-declared. |
| + void DispatchPrintJob( |
| + const PrinterHandler::PrintCallback& callback, |
| + scoped_ptr<extensions::PrinterProviderAPI::PrintJob> print_job, |
| + const scoped_refptr<base::RefCountedMemory>& data); |
| + |
| // Methods used as wrappers to callbacks for extensions::PrinterProviderAPI |
| // methods, primarily so the callbacks can be bound to this class' weak ptr. |
| // They just propagate results to callbacks passed to them. |
| @@ -62,6 +98,12 @@ class ExtensionPrinterHandler : public PrinterHandler { |
| content::BrowserContext* browser_context_; |
| +#if defined(ENABLE_SERVICE_DISCOVERY) |
|
tbarzic
2015/02/13 03:08:13
actually, looking at chrome_browser_gypi, this is
Vitaly Buka (NO REVIEWS)
2015/02/17 19:43:54
ok
|
| + // TODO(tbarzic): See if local_discovery::PWGRasterConverter can be moved to a |
| + // place that can be used without ifdefs. |
| + scoped_ptr<local_discovery::PWGRasterConverter> pwg_raster_converter_; |
| +#endif |
| + |
| base::WeakPtrFactory<ExtensionPrinterHandler> weak_ptr_factory_; |
| DISALLOW_COPY_AND_ASSIGN(ExtensionPrinterHandler); |