Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / extensions / browser / api / printer_provider_internal / printer_provider_internal_api.h
blob611e3118ef8b9aada128d5adbc5a43f40e46feed
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 <string>
10 #include "base/macros.h"
11 #include "base/observer_list.h"
12 #include "extensions/browser/api/printer_provider_internal/printer_provider_internal_api_observer.h"
13 #include "extensions/browser/browser_context_keyed_api_factory.h"
14 #include "extensions/browser/extension_function.h"
15 #include "extensions/common/api/printer_provider_internal.h"
17 namespace base {
18 class DictionaryValue;
19 class ListValue;
22 namespace content {
23 class BlobHandle;
24 class BrowserContext;
27 namespace extensions {
28 class Extension;
31 namespace extensions {
33 // Internal API instance. Primarily used to enable observers to watch for when
34 // printerProviderInternal API functions are called.
35 class PrinterProviderInternalAPI : public BrowserContextKeyedAPI {
36 public:
37 static BrowserContextKeyedAPIFactory<PrinterProviderInternalAPI>*
38 GetFactoryInstance();
40 explicit PrinterProviderInternalAPI(content::BrowserContext* browser_context);
41 ~PrinterProviderInternalAPI() override;
43 void AddObserver(PrinterProviderInternalAPIObserver* observer);
44 void RemoveObserver(PrinterProviderInternalAPIObserver* observer);
46 private:
47 friend class BrowserContextKeyedAPIFactory<PrinterProviderInternalAPI>;
48 friend class PrinterProviderInternalReportPrintersFunction;
49 friend class PrinterProviderInternalReportPrinterCapabilityFunction;
50 friend class PrinterProviderInternalReportPrintResultFunction;
52 // BrowserContextKeyedAPI implementation.
53 static const bool kServiceRedirectedInIncognito = true;
54 static const char* service_name() { return "PrinterProviderInternal"; }
56 // Notifies observers that a printerProvider.onGetPrintersRequested callback
57 // has been called. Called from
58 // |PrinterProviderInternalReportPrintersFunction|.
59 void NotifyGetPrintersResult(
60 const Extension* extension,
61 int request_id,
62 const PrinterProviderInternalAPIObserver::PrinterInfoVector& printers);
64 // Notifies observers that a printerProvider.onGetCapabilityRequested callback
65 // has been called. Called from
66 // |PrinterProviderInternalReportPrinterCapabilityFunction|.
67 void NotifyGetCapabilityResult(const Extension* extension,
68 int request_id,
69 const base::DictionaryValue& capability);
71 // Notifies observers that a printerProvider.onPrintRequested callback has
72 // been called. Called from
73 // |PrinterProviderInternalReportPrintResultFunction|.
74 void NotifyPrintResult(const Extension* extension,
75 int request_id,
76 core_api::printer_provider_internal::PrintError error);
78 ObserverList<PrinterProviderInternalAPIObserver> observers_;
80 DISALLOW_COPY_AND_ASSIGN(PrinterProviderInternalAPI);
83 class PrinterProviderInternalReportPrintResultFunction
84 : public UIThreadExtensionFunction {
85 public:
86 PrinterProviderInternalReportPrintResultFunction();
88 protected:
89 ~PrinterProviderInternalReportPrintResultFunction() override;
91 ExtensionFunction::ResponseAction Run() override;
93 private:
94 DECLARE_EXTENSION_FUNCTION("printerProviderInternal.reportPrintResult",
95 PRINTERPROVIDERINTERNAL_REPORTPRINTRESULT)
97 DISALLOW_COPY_AND_ASSIGN(PrinterProviderInternalReportPrintResultFunction);
100 class PrinterProviderInternalReportPrinterCapabilityFunction
101 : public UIThreadExtensionFunction {
102 public:
103 PrinterProviderInternalReportPrinterCapabilityFunction();
105 protected:
106 ~PrinterProviderInternalReportPrinterCapabilityFunction() override;
108 ExtensionFunction::ResponseAction Run() override;
110 private:
111 DECLARE_EXTENSION_FUNCTION("printerProviderInternal.reportPrinterCapability",
112 PRINTERPROVIDERINTERNAL_REPORTPRINTERCAPABILITY)
114 DISALLOW_COPY_AND_ASSIGN(
115 PrinterProviderInternalReportPrinterCapabilityFunction);
118 class PrinterProviderInternalReportPrintersFunction
119 : public UIThreadExtensionFunction {
120 public:
121 PrinterProviderInternalReportPrintersFunction();
123 protected:
124 ~PrinterProviderInternalReportPrintersFunction() override;
125 ExtensionFunction::ResponseAction Run() override;
127 private:
128 DECLARE_EXTENSION_FUNCTION("printerProviderInternal.reportPrinters",
129 PRINTERPROVIDERINTERNAL_REPORTPRINTERS)
131 DISALLOW_COPY_AND_ASSIGN(PrinterProviderInternalReportPrintersFunction);
134 class PrinterProviderInternalGetPrintDataFunction
135 : public UIThreadExtensionFunction {
136 public:
137 PrinterProviderInternalGetPrintDataFunction();
139 protected:
140 ~PrinterProviderInternalGetPrintDataFunction() override;
141 ExtensionFunction::ResponseAction Run() override;
143 private:
144 void OnBlob(const std::string& type,
145 int size,
146 const scoped_refptr<base::RefCountedMemory>& data,
147 scoped_ptr<content::BlobHandle> blob);
148 DECLARE_EXTENSION_FUNCTION("printerProviderInternal.getPrintData",
149 PRINTERPROVIDERINTERNAL_GETPRINTDATA)
151 DISALLOW_COPY_AND_ASSIGN(PrinterProviderInternalGetPrintDataFunction);
154 } // namespace extensions
156 #endif // EXTENSIONS_BROWSER_API_PRINTER_PROVIDER_INTERNAL_PRINTER_PROVIDER_INTERNAL_API_H_