| 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 23 matching lines...) Expand all Loading... |
| 34 } | 34 } |
| 35 | 35 |
| 36 namespace local_discovery { | 36 namespace local_discovery { |
| 37 class PWGRasterConverter; | 37 class PWGRasterConverter; |
| 38 } | 38 } |
| 39 | 39 |
| 40 // Implementation of PrinterHandler interface backed by printerProvider | 40 // Implementation of PrinterHandler interface backed by printerProvider |
| 41 // extension API. | 41 // extension API. |
| 42 class ExtensionPrinterHandler : public PrinterHandler { | 42 class ExtensionPrinterHandler : public PrinterHandler { |
| 43 public: | 43 public: |
| 44 using GrantUsbPrinterAccessCallback = |
| 45 base::Callback<void(const base::DictionaryValue& printer_info)>; |
| 44 using PrintJobCallback = | 46 using PrintJobCallback = |
| 45 base::Callback<void(scoped_ptr<extensions::PrinterProviderPrintJob>)>; | 47 base::Callback<void(scoped_ptr<extensions::PrinterProviderPrintJob>)>; |
| 46 | 48 |
| 47 ExtensionPrinterHandler( | 49 ExtensionPrinterHandler( |
| 48 content::BrowserContext* browser_context, | 50 content::BrowserContext* browser_context, |
| 49 const scoped_refptr<base::TaskRunner>& slow_task_runner); | 51 const scoped_refptr<base::TaskRunner>& slow_task_runner); |
| 50 | 52 |
| 51 ~ExtensionPrinterHandler() override; | 53 ~ExtensionPrinterHandler() override; |
| 52 | 54 |
| 53 // PrinterHandler implementation: | 55 // PrinterHandler implementation: |
| 54 void Reset() override; | 56 void Reset() override; |
| 55 void StartGetPrinters( | 57 void StartGetPrinters( |
| 56 const PrinterHandler::GetPrintersCallback& callback) override; | 58 const PrinterHandler::GetPrintersCallback& callback) override; |
| 57 void StartGetCapability( | 59 void StartGetCapability( |
| 58 const std::string& destination_id, | 60 const std::string& destination_id, |
| 59 const PrinterHandler::GetCapabilityCallback& calback) override; | 61 const PrinterHandler::GetCapabilityCallback& calback) override; |
| 60 // TODO(tbarzic): It might make sense to have the strings in a single struct. | 62 // TODO(tbarzic): It might make sense to have the strings in a single struct. |
| 61 void StartPrint(const std::string& destination_id, | 63 void StartPrint(const std::string& destination_id, |
| 62 const std::string& capability, | 64 const std::string& capability, |
| 63 const base::string16& job_title, | 65 const base::string16& job_title, |
| 64 const std::string& ticket_json, | 66 const std::string& ticket_json, |
| 65 const gfx::Size& page_size, | 67 const gfx::Size& page_size, |
| 66 const scoped_refptr<base::RefCountedMemory>& print_data, | 68 const scoped_refptr<base::RefCountedMemory>& print_data, |
| 67 const PrinterHandler::PrintCallback& callback) override; | 69 const PrinterHandler::PrintCallback& callback) override; |
| 68 | 70 |
| 71 void StartGrantUsbPrinterAccess( |
| 72 const std::string& extension_id, |
| 73 int device_id, |
| 74 const GrantUsbPrinterAccessCallback& callback); |
| 75 |
| 69 private: | 76 private: |
| 70 friend class ExtensionPrinterHandlerTest; | 77 friend class ExtensionPrinterHandlerTest; |
| 71 | 78 |
| 72 void SetPwgRasterConverterForTesting( | 79 void SetPwgRasterConverterForTesting( |
| 73 scoped_ptr<local_discovery::PWGRasterConverter> pwg_raster_converter); | 80 scoped_ptr<local_discovery::PWGRasterConverter> pwg_raster_converter); |
| 74 | 81 |
| 75 // Converts |data| to PWG raster format (from PDF) for a printer described | 82 // Converts |data| to PWG raster format (from PDF) for a printer described |
| 76 // by |printer_description|. | 83 // by |printer_description|. |
| 77 // |callback| is called with the converted data. | 84 // |callback| is called with the converted data. |
| 78 void ConvertToPWGRaster( | 85 void ConvertToPWGRaster( |
| (...skipping 16 matching lines...) Expand all Loading... |
| 95 const PrinterHandler::GetPrintersCallback& callback, | 102 const PrinterHandler::GetPrintersCallback& callback, |
| 96 const base::ListValue& pritners, | 103 const base::ListValue& pritners, |
| 97 bool done); | 104 bool done); |
| 98 void WrapGetCapabilityCallback( | 105 void WrapGetCapabilityCallback( |
| 99 const PrinterHandler::GetCapabilityCallback& callback, | 106 const PrinterHandler::GetCapabilityCallback& callback, |
| 100 const std::string& destination_id, | 107 const std::string& destination_id, |
| 101 const base::DictionaryValue& capability); | 108 const base::DictionaryValue& capability); |
| 102 void WrapPrintCallback(const PrinterHandler::PrintCallback& callback, | 109 void WrapPrintCallback(const PrinterHandler::PrintCallback& callback, |
| 103 bool success, | 110 bool success, |
| 104 const std::string& status); | 111 const std::string& status); |
| 112 void WrapGrantUsbPrinterAccessCallback( |
| 113 const GrantUsbPrinterAccessCallback& callback, |
| 114 const base::DictionaryValue& printer_info); |
| 105 | 115 |
| 106 content::BrowserContext* browser_context_; | 116 content::BrowserContext* browser_context_; |
| 107 | 117 |
| 108 scoped_ptr<local_discovery::PWGRasterConverter> pwg_raster_converter_; | 118 scoped_ptr<local_discovery::PWGRasterConverter> pwg_raster_converter_; |
| 109 | 119 |
| 110 scoped_refptr<base::TaskRunner> slow_task_runner_; | 120 scoped_refptr<base::TaskRunner> slow_task_runner_; |
| 111 | 121 |
| 112 base::WeakPtrFactory<ExtensionPrinterHandler> weak_ptr_factory_; | 122 base::WeakPtrFactory<ExtensionPrinterHandler> weak_ptr_factory_; |
| 113 | 123 |
| 114 DISALLOW_COPY_AND_ASSIGN(ExtensionPrinterHandler); | 124 DISALLOW_COPY_AND_ASSIGN(ExtensionPrinterHandler); |
| 115 }; | 125 }; |
| 116 | 126 |
| 117 #endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_EXTENSION_PRINTER_HANDLER_H_ | 127 #endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_EXTENSION_PRINTER_HANDLER_H_ |
| OLD | NEW |