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

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: Drop vestigial file-related code; kOnstify strings Created 6 years, 7 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 // Ownership of |results| is passed to the callback.
26 typedef base::Callback<void(
27 scoped_ptr<base::ListValue> results,
28 const std::string& error)> ResultsCallback;
29
30 DocumentScanInterface() {}
31 virtual ~DocumentScanInterface() {}
32
33 virtual void Scan(const document_scan::Scan::Params &params,
34 const ResultsCallback& callback) = 0;
35 virtual void ListScanners(const ResultsCallback& callback) = 0;
36 };
37
38 class DocumentScanListScannersFunction : public AsyncApiFunction {
39 public:
40 DECLARE_EXTENSION_FUNCTION("documentScan.listScanners",
41 DOCUMENT_SCAN_LISTSCANNERS)
42 DocumentScanListScannersFunction();
43
44 protected:
45 ~DocumentScanListScannersFunction();
46
47 // AsyncApiFunction:
48 virtual bool Prepare() OVERRIDE;
49 virtual void AsyncWorkStart() OVERRIDE;
50 virtual bool Respond() OVERRIDE;
51
52 private:
53 void OnResultsReceived(scoped_ptr<base::ListValue> results,
54 const std::string &error);
55
56 scoped_ptr<DocumentScanInterface> document_scan_interface_;
57
58 DISALLOW_COPY_AND_ASSIGN(DocumentScanListScannersFunction);
59 };
60
61 class DocumentScanScanFunction : public AsyncApiFunction {
62 public:
63 DECLARE_EXTENSION_FUNCTION("documentScan.scan",
64 DOCUMENT_SCAN_SCAN)
65 DocumentScanScanFunction();
66
67 protected:
68 ~DocumentScanScanFunction();
69
70 // AsyncApiFunction:
71 virtual bool Prepare() OVERRIDE;
72 virtual void AsyncWorkStart() OVERRIDE;
73 virtual bool Respond() OVERRIDE;
74
75 private:
76 void OnResultsReceived(scoped_ptr<base::ListValue> results,
77 const std::string &error);
78
79 scoped_ptr<document_scan::Scan::Params> params_;
80 scoped_ptr<DocumentScanInterface> document_scan_interface_;
81
82 DISALLOW_COPY_AND_ASSIGN(DocumentScanScanFunction);
83 };
84
85 } // namespace api
86
87 } // namespace extensions
88
89 #endif // CHROME_BROWSER_EXTENSIONS_API_DOCUMENT_SCAN_DOCUMENT_SCAN_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698