Index: chromeos/printing/printer_detector.h |
diff --git a/chromeos/printing/printer_detector.h b/chromeos/printing/printer_detector.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..bb102f5db494623be7dab7affb7cb057b5bff566 |
--- /dev/null |
+++ b/chromeos/printing/printer_detector.h |
@@ -0,0 +1,51 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROMEOS_PRINTING_PRINTER_DETECTOR_H_ |
+#define CHROMEOS_PRINTING_PRINTER_DETECTOR_H_ |
+ |
+#include <memory> |
+#include <vector> |
+ |
+#include "chromeos/printing/printer_configuration.h" |
+ |
+namespace chromeos { |
+ |
+// Interface for printer discovery. Constructs Printer objects from USB and |
+// zeroconf (DNS-SD) printers. |
+class PrinterDetector { |
+ public: |
+ // Interface for objects interested in detected printers. |
+ class Observer { |
+ public: |
+ // Called after discovery has started. |
+ virtual void OnDiscoveryStarted() = 0; |
+ |
+ // Called when discovery is stopping. OnPrintersFound will not be |
+ // called after this occurs. |
+ virtual void OnDiscoverStopping() = 0; |
+ |
+ // Called with a collection of printers as they are discovered. |
+ virtual void OnPrintersFound(std::vector<Printer> printers) = 0; |
+ }; |
+ |
+ // Static factory. Caller is responsible for the created object. |
+ static std::unique_ptr<PrinterDetector> Create(); |
+ |
+ // Begin scanning for printers. Found printers will be reported to the |
+ // attachd observer. |
xdai1
2016/09/19 18:56:10
nit: attached
skau
2016/09/20 01:56:47
Done.
|
+ virtual bool StartDiscovery() = 0; |
+ |
+ // Stop scanning for printers. Returns true if scanning was stopped |
+ // successfully. No calls to the attached observer will be made after this |
+ // returns if it returned true. |
+ virtual bool StopDiscovery() = 0; |
+ |
+ // Set an observer that will be notified of discovered printers. |
+ virtual void SetObserver(PrinterDetector::Observer* observer) = 0; |
xdai1
2016/09/19 18:56:10
How about maintaining a list of observers and then
skau
2016/09/20 01:56:47
Done.
|
+}; |
+ |
+} // namespace chromeos |
+ |
+#endif // CHROMEOS_PRINTING_PRINTER_DETECTOR_H_ |