Chromium Code Reviews| 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 <string> | |
| 6 #include <vector> | |
| 7 | |
| 8 #include "base/base64.h" | |
| 9 #include "base/basictypes.h" | |
| 10 #include "base/callback.h" | |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "chrome/common/extensions/api/document_scan.h" | |
| 13 #include "extensions/browser/api/async_api_function.h" | |
| 14 | |
| 15 #ifndef CHROME_BROWSER_EXTENSIONS_API_DOCUMENT_SCAN_DOCUMENT_SCAN_API_H_ | |
| 16 #define CHROME_BROWSER_EXTENSIONS_API_DOCUMENT_SCAN_DOCUMENT_SCAN_API_H_ | |
| 17 | |
| 18 namespace base { | |
| 19 class ListValue; | |
| 20 } | |
| 21 | |
| 22 namespace extensions { | |
| 23 | |
| 24 namespace api { | |
| 25 | |
| 26 // Per-platform back-end implementation for each of the functions below. | |
| 27 class DocumentScanInterface { | |
|
mef
2014/10/13 15:59:54
suggest: put this class into document_scan_interfa
Paul Stewart
2014/10/14 19:28:31
Done.
| |
| 28 public: | |
| 29 struct ScannerDescription { | |
| 30 std::string name; | |
| 31 std::string manufacturer; | |
| 32 std::string model; | |
| 33 std::string scanner_type; | |
| 34 std::string image_mime_type; | |
| 35 }; | |
| 36 | |
| 37 enum ScanMode { | |
| 38 kScanModeColor, | |
| 39 kScanModeGray, | |
| 40 kScanModeLineart | |
| 41 }; | |
| 42 | |
| 43 typedef base::Callback<void( | |
| 44 const std::vector<ScannerDescription>& scanner_descriptions, | |
| 45 const std::string& error)> ListScannersResultsCallback; | |
| 46 | |
| 47 // Ownership of |results| is passed to the callback. | |
| 48 typedef base::Callback<void( | |
| 49 scoped_ptr<base::ListValue> results, | |
| 50 const std::string& error)> ScanResultsCallback; | |
| 51 | |
| 52 DocumentScanInterface() {} | |
| 53 virtual ~DocumentScanInterface() {} | |
| 54 | |
| 55 virtual void Scan(const std::string& scanner_name, | |
| 56 ScanMode mode, | |
| 57 int resolution_dpi, | |
| 58 const ScanResultsCallback& callback) = 0; | |
| 59 virtual void ListScanners(const ListScannersResultsCallback& callback) = 0; | |
| 60 }; | |
| 61 | |
| 62 class DocumentScanScanFunction : public AsyncApiFunction { | |
|
mef
2014/10/13 15:59:54
suggest: put this class into document_scan_[scan_]
Paul Stewart
2014/10/14 19:28:31
Because of how the API references are generated, I
| |
| 63 public: | |
| 64 DECLARE_EXTENSION_FUNCTION("documentScan.scan", | |
| 65 DOCUMENT_SCAN_SCAN) | |
| 66 DocumentScanScanFunction(); | |
|
mef
2014/10/13 15:59:54
Any particular reason to call it 'ScanScan'?
Paul Stewart
2014/10/14 19:28:31
It is a little unfortunate but "DocumentScan" refe
| |
| 67 | |
| 68 protected: | |
| 69 ~DocumentScanScanFunction(); | |
| 70 | |
| 71 // AsyncApiFunction: | |
| 72 virtual bool Prepare() OVERRIDE; | |
| 73 virtual void AsyncWorkStart() OVERRIDE; | |
| 74 virtual bool Respond() OVERRIDE; | |
| 75 | |
| 76 private: | |
| 77 void OnScannerListReceived( | |
| 78 const std::vector<DocumentScanInterface::ScannerDescription>& | |
| 79 scanner_descriptions, | |
| 80 const std::string& error); | |
| 81 void OnResultsReceived(scoped_ptr<base::ListValue> results, | |
| 82 const std::string &error); | |
| 83 | |
| 84 scoped_ptr<document_scan::Scan::Params> params_; | |
| 85 scoped_ptr<DocumentScanInterface> document_scan_interface_; | |
| 86 | |
| 87 DISALLOW_COPY_AND_ASSIGN(DocumentScanScanFunction); | |
| 88 }; | |
| 89 | |
| 90 } // namespace api | |
| 91 | |
| 92 } // namespace extensions | |
| 93 | |
| 94 #endif // CHROME_BROWSER_EXTENSIONS_API_DOCUMENT_SCAN_DOCUMENT_SCAN_API_H_ | |
| OLD | NEW |