| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_EXTENSION_PRINTER_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_EXTENSION_PRINTER_HANDLER_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_EXTENSION_PRINTER_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_EXTENSION_PRINTER_HANDLER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 } | 33 } |
| 34 | 34 |
| 35 namespace local_discovery { | 35 namespace local_discovery { |
| 36 class PWGRasterConverter; | 36 class PWGRasterConverter; |
| 37 } | 37 } |
| 38 | 38 |
| 39 // Implementation of PrinterHandler interface backed by printerProvider | 39 // Implementation of PrinterHandler interface backed by printerProvider |
| 40 // extension API. | 40 // extension API. |
| 41 class ExtensionPrinterHandler : public PrinterHandler { | 41 class ExtensionPrinterHandler : public PrinterHandler { |
| 42 public: | 42 public: |
| 43 using RefCountedMemoryCallback = | 43 using PrintJobCallback = |
| 44 base::Callback<void(const scoped_refptr<base::RefCountedMemory>&)>; | 44 base::Callback<void(scoped_ptr<extensions::PrinterProviderPrintJob>)>; |
| 45 | 45 |
| 46 ExtensionPrinterHandler( | 46 ExtensionPrinterHandler( |
| 47 content::BrowserContext* browser_context, | 47 content::BrowserContext* browser_context, |
| 48 const scoped_refptr<base::TaskRunner>& slow_task_runner); | 48 const scoped_refptr<base::TaskRunner>& slow_task_runner); |
| 49 | 49 |
| 50 ~ExtensionPrinterHandler() override; | 50 ~ExtensionPrinterHandler() override; |
| 51 | 51 |
| 52 // PrinterHandler implementation: | 52 // PrinterHandler implementation: |
| 53 void Reset() override; | 53 void Reset() override; |
| 54 void StartGetPrinters( | 54 void StartGetPrinters( |
| (...skipping 16 matching lines...) Expand all Loading... |
| 71 scoped_ptr<local_discovery::PWGRasterConverter> pwg_raster_converter); | 71 scoped_ptr<local_discovery::PWGRasterConverter> pwg_raster_converter); |
| 72 | 72 |
| 73 // Converts |data| to PWG raster format (from PDF) for a printer described | 73 // Converts |data| to PWG raster format (from PDF) for a printer described |
| 74 // by |printer_description|. | 74 // by |printer_description|. |
| 75 // |callback| is called with the converted data. | 75 // |callback| is called with the converted data. |
| 76 void ConvertToPWGRaster( | 76 void ConvertToPWGRaster( |
| 77 const scoped_refptr<base::RefCountedMemory>& data, | 77 const scoped_refptr<base::RefCountedMemory>& data, |
| 78 const cloud_devices::CloudDeviceDescription& printer_description, | 78 const cloud_devices::CloudDeviceDescription& printer_description, |
| 79 const cloud_devices::CloudDeviceDescription& ticket, | 79 const cloud_devices::CloudDeviceDescription& ticket, |
| 80 const gfx::Size& page_size, | 80 const gfx::Size& page_size, |
| 81 const RefCountedMemoryCallback& callback); | 81 scoped_ptr<extensions::PrinterProviderPrintJob> job, |
| 82 const PrintJobCallback& callback); |
| 82 | 83 |
| 83 // Sets print job document data and dispatches it using printerProvider API. | 84 // Sets print job document data and dispatches it using printerProvider API. |
| 84 void DispatchPrintJob( | 85 void DispatchPrintJob( |
| 85 const PrinterHandler::PrintCallback& callback, | 86 const PrinterHandler::PrintCallback& callback, |
| 86 scoped_ptr<extensions::PrinterProviderPrintJob> print_job, | 87 scoped_ptr<extensions::PrinterProviderPrintJob> print_job); |
| 87 const scoped_refptr<base::RefCountedMemory>& data); | |
| 88 | 88 |
| 89 // Methods used as wrappers to callbacks for extensions::PrinterProviderAPI | 89 // Methods used as wrappers to callbacks for extensions::PrinterProviderAPI |
| 90 // methods, primarily so the callbacks can be bound to this class' weak ptr. | 90 // methods, primarily so the callbacks can be bound to this class' weak ptr. |
| 91 // They just propagate results to callbacks passed to them. | 91 // They just propagate results to callbacks passed to them. |
| 92 void WrapGetPrintersCallback( | 92 void WrapGetPrintersCallback( |
| 93 const PrinterHandler::GetPrintersCallback& callback, | 93 const PrinterHandler::GetPrintersCallback& callback, |
| 94 const base::ListValue& pritners, | 94 const base::ListValue& pritners, |
| 95 bool done); | 95 bool done); |
| 96 void WrapGetCapabilityCallback( | 96 void WrapGetCapabilityCallback( |
| 97 const PrinterHandler::GetCapabilityCallback& callback, | 97 const PrinterHandler::GetCapabilityCallback& callback, |
| 98 const std::string& destination_id, | 98 const std::string& destination_id, |
| 99 const base::DictionaryValue& capability); | 99 const base::DictionaryValue& capability); |
| 100 void WrapPrintCallback(const PrinterHandler::PrintCallback& callback, | 100 void WrapPrintCallback(const PrinterHandler::PrintCallback& callback, |
| 101 bool success, | 101 bool success, |
| 102 const std::string& status); | 102 const std::string& status); |
| 103 | 103 |
| 104 content::BrowserContext* browser_context_; | 104 content::BrowserContext* browser_context_; |
| 105 | 105 |
| 106 scoped_ptr<local_discovery::PWGRasterConverter> pwg_raster_converter_; | 106 scoped_ptr<local_discovery::PWGRasterConverter> pwg_raster_converter_; |
| 107 | 107 |
| 108 scoped_refptr<base::TaskRunner> slow_task_runner_; | 108 scoped_refptr<base::TaskRunner> slow_task_runner_; |
| 109 | 109 |
| 110 base::WeakPtrFactory<ExtensionPrinterHandler> weak_ptr_factory_; | 110 base::WeakPtrFactory<ExtensionPrinterHandler> weak_ptr_factory_; |
| 111 | 111 |
| 112 DISALLOW_COPY_AND_ASSIGN(ExtensionPrinterHandler); | 112 DISALLOW_COPY_AND_ASSIGN(ExtensionPrinterHandler); |
| 113 }; | 113 }; |
| 114 | 114 |
| 115 #endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_EXTENSION_PRINTER_HANDLER_H_ | 115 #endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_EXTENSION_PRINTER_HANDLER_H_ |
| OLD | NEW |