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