Reland the ULONG -> SIZE_T change from 317177
[chromium-blink-merge.git] / extensions / browser / api / printer_provider_internal / printer_provider_internal_api.h
blob703ffb56625987b13ab4789c1baa66201f70f2f6
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
3 // found in the LICENSE file.
5 #ifndef EXTENSIONS_BROWSER_API_PRINTER_PROVIDER_INTERNAL_PRINTER_PROVIDER_INTERNAL_API_H_
6 #define EXTENSIONS_BROWSER_API_PRINTER_PROVIDER_INTERNAL_PRINTER_PROVIDER_INTERNAL_API_H_
8 #include "base/macros.h"
9 #include "base/observer_list.h"
10 #include "extensions/browser/api/printer_provider_internal/printer_provider_internal_api_observer.h"
11 #include "extensions/browser/browser_context_keyed_api_factory.h"
12 #include "extensions/browser/extension_function.h"
13 #include "extensions/common/api/printer_provider_internal.h"
15 namespace base {
16 class DictionaryValue;
17 class ListValue;
20 namespace content {
21 class BrowserContext;
24 namespace extensions {
25 class Extension;
28 namespace extensions {
30 // Internal API instance. Primarily used to enable observers to watch for when
31 // printerProviderInternal API functions are called.
32 class PrinterProviderInternalAPI : public BrowserContextKeyedAPI {
33 public:
34 static BrowserContextKeyedAPIFactory<PrinterProviderInternalAPI>*
35 GetFactoryInstance();
37 explicit PrinterProviderInternalAPI(content::BrowserContext* browser_context);
38 ~PrinterProviderInternalAPI() override;
40 void AddObserver(PrinterProviderInternalAPIObserver* observer);
41 void RemoveObserver(PrinterProviderInternalAPIObserver* observer);
43 private:
44 friend class BrowserContextKeyedAPIFactory<PrinterProviderInternalAPI>;
45 friend class PrinterProviderInternalReportPrintersFunction;
46 friend class PrinterProviderInternalReportPrinterCapabilityFunction;
47 friend class PrinterProviderInternalReportPrintResultFunction;
49 // BrowserContextKeyedAPI implementation.
50 static const bool kServiceRedirectedInIncognito = true;
51 static const char* service_name() { return "PrinterProviderInternal"; }
53 // Notifies observers that a printerProvider.onGetPrintersRequested callback
54 // has been called. Called from
55 // |PrinterProviderInternalReportPrintersFunction|.
56 void NotifyGetPrintersResult(
57 const Extension* extension,
58 int request_id,
59 const PrinterProviderInternalAPIObserver::PrinterInfoVector& printers);
61 // Notifies observers that a printerProvider.onGetCapabilityRequested callback
62 // has been called. Called from
63 // |PrinterProviderInternalReportPrinterCapabilityFunction|.
64 void NotifyGetCapabilityResult(const Extension* extension,
65 int request_id,
66 const base::DictionaryValue& capability);
68 // Notifies observers that a printerProvider.onPrintRequested callback has
69 // been called. Called from
70 // |PrinterProviderInternalReportPrintResultFunction|.
71 void NotifyPrintResult(const Extension* extension,
72 int request_id,
73 core_api::printer_provider_internal::PrintError error);
75 ObserverList<PrinterProviderInternalAPIObserver> observers_;
77 DISALLOW_COPY_AND_ASSIGN(PrinterProviderInternalAPI);
80 class PrinterProviderInternalReportPrintResultFunction
81 : public UIThreadExtensionFunction {
82 public:
83 PrinterProviderInternalReportPrintResultFunction();
85 protected:
86 ~PrinterProviderInternalReportPrintResultFunction() override;
88 ExtensionFunction::ResponseAction Run() override;
90 private:
91 DECLARE_EXTENSION_FUNCTION("printerProviderInternal.reportPrintResult",
92 PRINTERPROVIDERINTERNAL_REPORTPRINTRESULT)
94 DISALLOW_COPY_AND_ASSIGN(PrinterProviderInternalReportPrintResultFunction);
97 class PrinterProviderInternalReportPrinterCapabilityFunction
98 : public UIThreadExtensionFunction {
99 public:
100 PrinterProviderInternalReportPrinterCapabilityFunction();
102 protected:
103 ~PrinterProviderInternalReportPrinterCapabilityFunction() override;
105 ExtensionFunction::ResponseAction Run() override;
107 private:
108 DECLARE_EXTENSION_FUNCTION("printerProviderInternal.reportPrinterCapability",
109 PRINTERPROVIDERINTERNAL_REPORTPRINTERCAPABILITY)
111 DISALLOW_COPY_AND_ASSIGN(
112 PrinterProviderInternalReportPrinterCapabilityFunction);
115 class PrinterProviderInternalReportPrintersFunction
116 : public UIThreadExtensionFunction {
117 public:
118 PrinterProviderInternalReportPrintersFunction();
120 protected:
121 ~PrinterProviderInternalReportPrintersFunction() override;
122 ExtensionFunction::ResponseAction Run() override;
124 private:
125 DECLARE_EXTENSION_FUNCTION("printerProviderInternal.reportPrinters",
126 PRINTERPROVIDERINTERNAL_REPORTPRINTERS)
128 DISALLOW_COPY_AND_ASSIGN(PrinterProviderInternalReportPrintersFunction);
131 } // namespace extensions
133 #endif // EXTENSIONS_BROWSER_API_PRINTER_PROVIDER_INTERNAL_PRINTER_PROVIDER_INTERNAL_API_H_