OLD | NEW |
(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 ¶ms, |
| 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_ |
OLD | NEW |