Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Side by Side Diff: chrome/browser/extensions/api/document_scan/document_scan_api.h

Issue 286933006: Implement a JavaScript API for document scanning (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: IDL indicates multiple images can be returned Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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.
4
5 #include "base/basictypes.h"
6 #include "base/callback.h"
7 #include "base/memory/scoped_ptr.h"
8 #include "chrome/common/extensions/api/document_scan.h"
9 #include "extensions/browser/api/async_api_function.h"
10
11 #ifndef CHROME_BROWSER_EXTENSIONS_API_DOCUMENT_SCAN_DOCUMENT_SCAN_API_H_
12 #define CHROME_BROWSER_EXTENSIONS_API_DOCUMENT_SCAN_DOCUMENT_SCAN_API_H_
13
14 namespace base {
15 class ListValue;
16 }
17
18 namespace extensions {
19
20 namespace api {
21
22 // Per-platform back-end implementation for each of the functions below.
23 class DocumentScanInterface {
24 public:
25 struct ScannerDescription {
26 std::string name;
27 std::string manufacturer;
28 std::string model;
29 std::string scanner_type;
30 std::string image_mime_type;
31 };
32
33 typedef base::Callback<void(
34 const std::vector<ScannerDescription>& scanner_descriptions,
35 const std::string& error)> ListScannersResultsCallback;
36
37 // Ownership of |results| is passed to the callback.
38 typedef base::Callback<void(
39 scoped_ptr<base::ListValue> results,
40 const std::string& error)> ScanResultsCallback;
41
42 DocumentScanInterface() {}
43 virtual ~DocumentScanInterface() {}
44
45 virtual void Scan(const document_scan::Scan::Params &params,
46 const ScanResultsCallback& callback) = 0;
47 virtual void ListScanners(const ListScannersResultsCallback& callback) = 0;
48 };
49
50 class DocumentScanScanFunction : public AsyncApiFunction {
51 public:
52 DECLARE_EXTENSION_FUNCTION("documentScan.scan",
53 DOCUMENT_SCAN_SCAN)
54 DocumentScanScanFunction();
55
56 protected:
57 ~DocumentScanScanFunction();
58
59 // AsyncApiFunction:
60 virtual bool Prepare() OVERRIDE;
61 virtual void AsyncWorkStart() OVERRIDE;
62 virtual bool Respond() OVERRIDE;
63
64 private:
65 void OnResultsReceived(scoped_ptr<base::ListValue> results,
66 const std::string &error);
67
68 scoped_ptr<document_scan::Scan::Params> params_;
69 scoped_ptr<DocumentScanInterface> document_scan_interface_;
70
71 DISALLOW_COPY_AND_ASSIGN(DocumentScanScanFunction);
72 };
73
74 } // namespace api
75
76 } // namespace extensions
77
78 #endif // CHROME_BROWSER_EXTENSIONS_API_DOCUMENT_SCAN_DOCUMENT_SCAN_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698