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

Unified 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: API fully up to data (and functional) with respect to API submission, minus image selection API whi… Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
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..c92b608d64107d172f9ea0b029ecd669bfffe463
--- /dev/null
+++ b/chrome/browser/extensions/api/document_scan/document_scan_api.h
@@ -0,0 +1,94 @@
+// 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 <string>
+#include <vector>
+
+#include "base/base64.h"
+#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 {
mef 2014/10/13 15:59:54 suggest: put this class into document_scan_interfa
Paul Stewart 2014/10/14 19:28:31 Done.
+ public:
+ struct ScannerDescription {
+ std::string name;
+ std::string manufacturer;
+ std::string model;
+ std::string scanner_type;
+ std::string image_mime_type;
+ };
+
+ enum ScanMode {
+ kScanModeColor,
+ kScanModeGray,
+ kScanModeLineart
+ };
+
+ typedef base::Callback<void(
+ const std::vector<ScannerDescription>& scanner_descriptions,
+ const std::string& error)> ListScannersResultsCallback;
+
+ // Ownership of |results| is passed to the callback.
+ typedef base::Callback<void(
+ scoped_ptr<base::ListValue> results,
+ const std::string& error)> ScanResultsCallback;
+
+ DocumentScanInterface() {}
+ virtual ~DocumentScanInterface() {}
+
+ virtual void Scan(const std::string& scanner_name,
+ ScanMode mode,
+ int resolution_dpi,
+ const ScanResultsCallback& callback) = 0;
+ virtual void ListScanners(const ListScannersResultsCallback& callback) = 0;
+};
+
+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
+ public:
+ DECLARE_EXTENSION_FUNCTION("documentScan.scan",
+ DOCUMENT_SCAN_SCAN)
+ 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
+
+ protected:
+ ~DocumentScanScanFunction();
+
+ // AsyncApiFunction:
+ virtual bool Prepare() OVERRIDE;
+ virtual void AsyncWorkStart() OVERRIDE;
+ virtual bool Respond() OVERRIDE;
+
+ private:
+ void OnScannerListReceived(
+ const std::vector<DocumentScanInterface::ScannerDescription>&
+ scanner_descriptions,
+ const std::string& error);
+ 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_

Powered by Google App Engine
This is Rietveld 408576698