| 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 EXTENSIONS_BROWSER_API_PRINTER_PROVIDER_PRINTER_PROVIDER_API_H_ | 5 #ifndef EXTENSIONS_BROWSER_API_PRINTER_PROVIDER_PRINTER_PROVIDER_API_H_ |
| 6 #define EXTENSIONS_BROWSER_API_PRINTER_PROVIDER_PRINTER_PROVIDER_API_H_ | 6 #define EXTENSIONS_BROWSER_API_PRINTER_PROVIDER_PRINTER_PROVIDER_API_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "components/keyed_service/core/keyed_service.h" | 11 #include "components/keyed_service/core/keyed_service.h" |
| 12 | 12 |
| 13 namespace base { | 13 namespace base { |
| 14 class DictionaryValue; | 14 class DictionaryValue; |
| 15 class ListValue; | 15 class ListValue; |
| 16 } | 16 } |
| 17 | 17 |
| 18 namespace content { | 18 namespace content { |
| 19 class BrowserContext; | 19 class BrowserContext; |
| 20 } | 20 } |
| 21 | 21 |
| 22 namespace device { |
| 23 class UsbDevice; |
| 24 } |
| 25 |
| 22 namespace extensions { | 26 namespace extensions { |
| 23 class Extension; | 27 class Extension; |
| 24 struct PrinterProviderPrintJob; | 28 struct PrinterProviderPrintJob; |
| 25 } | 29 } |
| 26 | 30 |
| 27 namespace extensions { | 31 namespace extensions { |
| 28 | 32 |
| 29 // Implements chrome.printerProvider API events. | 33 // Implements chrome.printerProvider API events. |
| 30 class PrinterProviderAPI : public KeyedService { | 34 class PrinterProviderAPI : public KeyedService { |
| 31 public: | 35 public: |
| 32 using GetPrintersCallback = | 36 using GetPrintersCallback = |
| 33 base::Callback<void(const base::ListValue& printers, bool done)>; | 37 base::Callback<void(const base::ListValue& printers, bool done)>; |
| 34 using GetCapabilityCallback = | 38 using GetCapabilityCallback = |
| 35 base::Callback<void(const base::DictionaryValue& capability)>; | 39 base::Callback<void(const base::DictionaryValue& capability)>; |
| 36 using PrintCallback = | 40 using PrintCallback = |
| 37 base::Callback<void(bool success, const std::string& error)>; | 41 base::Callback<void(bool success, const std::string& error)>; |
| 42 using UsbAccessGrantedCallback = |
| 43 base::Callback<void(const base::DictionaryValue& printer_info)>; |
| 38 | 44 |
| 39 static PrinterProviderAPI* Create(content::BrowserContext* context); | 45 static PrinterProviderAPI* Create(content::BrowserContext* context); |
| 40 | 46 |
| 41 // Returns generic error string for print request. | 47 // Returns generic error string for print request. |
| 42 static std::string GetDefaultPrintError(); | 48 static std::string GetDefaultPrintError(); |
| 43 | 49 |
| 44 ~PrinterProviderAPI() override {} | 50 ~PrinterProviderAPI() override {} |
| 45 | 51 |
| 46 // Requests list of supported printers from extensions implementing | 52 // Requests list of supported printers from extensions implementing |
| 47 // chrome.printerProvider API. It dispatches | 53 // chrome.printerProvider API. It dispatches |
| (...skipping 27 matching lines...) Expand all Loading... |
| 75 // |callback| is passed the print status returned by the extension, and it | 81 // |callback| is passed the print status returned by the extension, and it |
| 76 // must not be null. | 82 // must not be null. |
| 77 virtual void DispatchPrintRequested(const PrinterProviderPrintJob& job, | 83 virtual void DispatchPrintRequested(const PrinterProviderPrintJob& job, |
| 78 const PrintCallback& callback) = 0; | 84 const PrintCallback& callback) = 0; |
| 79 | 85 |
| 80 // Returns print job associated with the print request with id |request_id| | 86 // Returns print job associated with the print request with id |request_id| |
| 81 // for extension |extension|. | 87 // for extension |extension|. |
| 82 // It should return NULL if the job for the request does not exist. | 88 // It should return NULL if the job for the request does not exist. |
| 83 virtual const PrinterProviderPrintJob* GetPrintJob(const Extension* extension, | 89 virtual const PrinterProviderPrintJob* GetPrintJob(const Extension* extension, |
| 84 int request_id) const = 0; | 90 int request_id) const = 0; |
| 91 |
| 92 // Notifies the given extension that it has been granted access to the given |
| 93 virtual void DispatchGrantUsbPrinterAccess( |
| 94 const std::string& extension_id, |
| 95 int device_id, |
| 96 const PrinterProviderAPI::UsbAccessGrantedCallback& callback) = 0; |
| 85 }; | 97 }; |
| 86 | 98 |
| 87 } // namespace extensions | 99 } // namespace extensions |
| 88 | 100 |
| 89 #endif // EXTENSIONS_BROWSER_API_PRINTER_PROVIDER_PRINTER_PROVIDER_API_H_ | 101 #endif // EXTENSIONS_BROWSER_API_PRINTER_PROVIDER_PRINTER_PROVIDER_API_H_ |
| OLD | NEW |