Index: chrome/browser/extensions/api/document_scan/document_scan_api.h |
diff --git a/chrome/browser/extensions/api/document_scan/document_scan_api.h b/chrome/browser/extensions/api/document_scan/document_scan_api.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..a2ccb1cc7c483673569d9ab94890d54ce1f8d623 |
--- /dev/null |
+++ b/chrome/browser/extensions/api/document_scan/document_scan_api.h |
@@ -0,0 +1,89 @@ |
+// Copyright 2014 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. |
+ |
+#include "base/basictypes.h" |
+#include "base/callback.h" |
+#include "base/memory/scoped_ptr.h" |
+#include "chrome/common/extensions/api/document_scan.h" |
+#include "extensions/browser/api/async_api_function.h" |
+ |
+#ifndef CHROME_BROWSER_EXTENSIONS_API_DOCUMENT_SCAN_DOCUMENT_SCAN_API_H_ |
+#define CHROME_BROWSER_EXTENSIONS_API_DOCUMENT_SCAN_DOCUMENT_SCAN_API_H_ |
+ |
+namespace base { |
+class ListValue; |
+} |
+ |
+namespace extensions { |
+ |
+namespace api { |
+ |
+// Per-platform back-end implementation for each of the functions below. |
+class DocumentScanInterface { |
+ public: |
+ // Ownership of |results| is passed to the callback. |
+ typedef base::Callback<void( |
+ scoped_ptr<base::ListValue> results, |
+ const std::string& error)> ResultsCallback; |
+ |
+ DocumentScanInterface() {} |
+ virtual ~DocumentScanInterface() {} |
+ |
+ virtual void Scan(const document_scan::Scan::Params ¶ms, |
+ const ResultsCallback& callback) = 0; |
+ virtual void ListScanners(const ResultsCallback& callback) = 0; |
+}; |
+ |
+class DocumentScanListScannersFunction : public AsyncApiFunction { |
+ public: |
+ DECLARE_EXTENSION_FUNCTION("documentScan.listScanners", |
+ DOCUMENT_SCAN_LISTSCANNERS) |
+ DocumentScanListScannersFunction(); |
+ |
+ protected: |
+ ~DocumentScanListScannersFunction(); |
+ |
+ // AsyncApiFunction: |
+ virtual bool Prepare() OVERRIDE; |
+ virtual void AsyncWorkStart() OVERRIDE; |
+ virtual bool Respond() OVERRIDE; |
+ |
+ private: |
+ void OnResultsReceived(scoped_ptr<base::ListValue> results, |
+ const std::string &error); |
+ |
+ scoped_ptr<DocumentScanInterface> document_scan_interface_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(DocumentScanListScannersFunction); |
+}; |
+ |
+class DocumentScanScanFunction : public AsyncApiFunction { |
+ public: |
+ DECLARE_EXTENSION_FUNCTION("documentScan.scan", |
+ DOCUMENT_SCAN_SCAN) |
+ DocumentScanScanFunction(); |
+ |
+ protected: |
+ ~DocumentScanScanFunction(); |
+ |
+ // AsyncApiFunction: |
+ virtual bool Prepare() OVERRIDE; |
+ virtual void AsyncWorkStart() OVERRIDE; |
+ virtual bool Respond() OVERRIDE; |
+ |
+ private: |
+ void OnResultsReceived(scoped_ptr<base::ListValue> results, |
+ const std::string &error); |
+ |
+ scoped_ptr<document_scan::Scan::Params> params_; |
+ scoped_ptr<DocumentScanInterface> document_scan_interface_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(DocumentScanScanFunction); |
+}; |
+ |
+} // namespace api |
+ |
+} // namespace extensions |
+ |
+#endif // CHROME_BROWSER_EXTENSIONS_API_DOCUMENT_SCAN_DOCUMENT_SCAN_API_H_ |