Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chromeos / dbus / lorgnette_manager_client.h
blobd36cd388dd178277b0f8c9437843e9b41ffaab84
1 // Copyright 2014 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 CHROMEOS_DBUS_LORGNETTE_MANAGER_CLIENT_H_
6 #define CHROMEOS_DBUS_LORGNETTE_MANAGER_CLIENT_H_
8 #include <map>
10 #include "base/callback.h"
11 #include "base/files/file.h"
12 #include "base/memory/ref_counted_memory.h"
13 #include "chromeos/chromeos_export.h"
14 #include "chromeos/dbus/dbus_client.h"
16 namespace chromeos {
18 // LorgnetteManagerClient is used to communicate with the lorgnette
19 // document scanning daemon.
20 class CHROMEOS_EXPORT LorgnetteManagerClient : public DBusClient {
21 public:
22 // The property information for each scanner retured by ListScanners.
23 typedef std::map<std::string, std::string> ScannerTableEntry;
24 typedef std::map<std::string, ScannerTableEntry> ScannerTable;
26 // Callback type for ListScanners(). Returns a map which contains
27 // a ScannerTableEntry for each available scanner.
28 typedef base::Callback<void(
29 bool succeeded, const ScannerTable&)> ListScannersCallback;
31 // Called once ScanImageToFile() is complete. Takes one parameter:
32 // - succeeded: was the scan completed successfully.
33 typedef base::Callback<void(bool succeeded)> ScanImageToFileCallback;
35 // Called once ScanImageToString() is complete. Takes two parameters:
36 // - succeeded: was the scan completed successfully.
37 // - image_data: the contents of the image.
38 typedef base::Callback<void(
39 bool succeeded,
40 const std::string& image_data)> ScanImageToStringCallback;
42 // Attributes provided to a scan request.
43 struct ScanProperties {
44 ScanProperties() : resolution_dpi(0) {}
45 std::string mode; // Can be "Color", "Gray", or "Lineart".
46 int resolution_dpi;
49 ~LorgnetteManagerClient() override;
51 // Gets a list of scanners from the lorgnette manager.
52 virtual void ListScanners(const ListScannersCallback& callback) = 0;
54 // Request a scanned image to be scanned to |file| and calls |callback|
55 // when completed. Image data will be stored in the .png format.
56 virtual void ScanImageToFile(std::string device_name,
57 const ScanProperties& properties,
58 const ScanImageToFileCallback& callback,
59 base::File* file) = 0;
61 // Request a scanned image and calls |callback| when completed with a string
62 // pointing at the scanned image data. Image data will be stored in the .png
63 // format.
64 virtual void ScanImageToString(std::string device_name,
65 const ScanProperties& properties,
66 const ScanImageToStringCallback& callback) = 0;
68 // Factory function, creates a new instance and returns ownership.
69 // For normal usage, access the singleton via DBusThreadManager::Get().
70 static LorgnetteManagerClient* Create();
72 protected:
73 // Create() should be used instead.
74 LorgnetteManagerClient();
76 private:
77 DISALLOW_COPY_AND_ASSIGN(LorgnetteManagerClient);
80 } // namespace chromeos
82 #endif // CHROMEOS_DBUS_LORGNETTE_MANAGER_CLIENT_H_