| 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" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 // Returns generic error string for print request. | 40 // Returns generic error string for print request. |
| 41 static std::string GetDefaultPrintError(); | 41 static std::string GetDefaultPrintError(); |
| 42 | 42 |
| 43 // The API currently cannot handle very large files, so the document size that | 43 // The API currently cannot handle very large files, so the document size that |
| 44 // may be sent to an extension is restricted. | 44 // may be sent to an extension is restricted. |
| 45 // TODO(tbarzic): Fix the API to support huge documents. | 45 // TODO(tbarzic): Fix the API to support huge documents. |
| 46 static const int kMaxDocumentSize = 50 * 1000 * 1000; | 46 static const int kMaxDocumentSize = 50 * 1000 * 1000; |
| 47 | 47 |
| 48 ~PrinterProviderAPI() override {} | 48 ~PrinterProviderAPI() override {} |
| 49 | 49 |
| 50 // Requests list of supported printers from extensions implementing |
| 51 // chrome.printerProvider API. It dispatches |
| 52 // chrome.printerProvider.onGetPrintersRequested event. The callback is |
| 53 // called once for every extension handling the event with a list of its |
| 54 // supported printers. The printer values reported by an extension are |
| 55 // added "extensionId" property that is set to the ID of the extension |
| 56 // returning the list and "extensionName" property set to the extension's |
| 57 // name. |
| 58 // Note that the "id" property of printer values reported by an extension are |
| 59 // rewriten as "<extension_id>:<id>" to ensure they are unique across |
| 60 // different extensions. |
| 50 virtual void DispatchGetPrintersRequested( | 61 virtual void DispatchGetPrintersRequested( |
| 51 const GetPrintersCallback& callback) = 0; | 62 const GetPrintersCallback& callback) = 0; |
| 52 | 63 |
| 53 // Requests printer capability for a printer with id |printer_id|. | 64 // Requests printer capability for a printer with id |printer_id|. |
| 54 // |printer_id| should be one of the printer ids reported by |GetPrinters| | 65 // |printer_id| should be one of the printer ids reported by |GetPrinters| |
| 55 // callback. | 66 // callback. |
| 56 // It dispatches chrome.printerProvider.onGetCapabilityRequested event | 67 // It dispatches chrome.printerProvider.onGetCapabilityRequested event |
| 57 // to the extension that manages the printer (which can be determined from | 68 // to the extension that manages the printer (which can be determined from |
| 58 // |printer_id| value). | 69 // |printer_id| value). |
| 59 // |callback| is passed a dictionary value containing printer capabilities as | 70 // |callback| is passed a dictionary value containing printer capabilities as |
| 60 // reported by the extension. | 71 // reported by the extension. |
| 61 virtual void DispatchGetCapabilityRequested( | 72 virtual void DispatchGetCapabilityRequested( |
| 62 const std::string& printer_id, | 73 const std::string& printer_id, |
| 63 const GetCapabilityCallback& callback) = 0; | 74 const GetCapabilityCallback& callback) = 0; |
| 64 | 75 |
| 65 // It dispatches chrome.printerProvider.onPrintRequested event with the | 76 // It dispatches chrome.printerProvider.onPrintRequested event with the |
| 66 // provided print job. The event is dispatched only to the extension that | 77 // provided print job. The event is dispatched only to the extension that |
| 67 // manages printer with id |job.printer_id|. | 78 // manages printer with id |job.printer_id|. |
| 68 // |callback| is passed the print status returned by the extension, and it | 79 // |callback| is passed the print status returned by the extension, and it |
| 69 // must not be null. | 80 // must not be null. |
| 70 virtual void DispatchPrintRequested(const PrinterProviderPrintJob& job, | 81 virtual void DispatchPrintRequested(const PrinterProviderPrintJob& job, |
| 71 const PrintCallback& callback) = 0; | 82 const PrintCallback& callback) = 0; |
| 72 }; | 83 }; |
| 73 | 84 |
| 74 } // namespace extensions | 85 } // namespace extensions |
| 75 | 86 |
| 76 #endif // EXTENSIONS_BROWSER_API_PRINTER_PROVIDER_PRINTER_PROVIDER_API_H_ | 87 #endif // EXTENSIONS_BROWSER_API_PRINTER_PROVIDER_PRINTER_PROVIDER_API_H_ |
| OLD | NEW |