summaryrefslogtreecommitdiffstats
path: root/extensions/browser/api/document_scan/document_scan_api.h
blob: 806d7688d670684034d2d1eb8d96d9ee5f48b377 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// 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.

#ifndef EXTENSIONS_BROWSER_API_DOCUMENT_SCAN_DOCUMENT_SCAN_API_H_
#define EXTENSIONS_BROWSER_API_DOCUMENT_SCAN_DOCUMENT_SCAN_API_H_

#include <string>
#include <vector>

#include "base/memory/scoped_ptr.h"
#include "extensions/browser/api/async_api_function.h"
#include "extensions/browser/api/document_scan/document_scan_interface.h"
#include "extensions/common/api/document_scan.h"

namespace extensions {

namespace core_api {

class DocumentScanScanFunction : public AsyncApiFunction {
 public:
  DECLARE_EXTENSION_FUNCTION("documentScan.scan", DOCUMENT_SCAN_SCAN)
  DocumentScanScanFunction();

 protected:
  ~DocumentScanScanFunction() override;

  // AsyncApiFunction:
  bool Prepare() override;
  void AsyncWorkStart() override;
  bool Respond() override;

 private:
  friend class DocumentScanScanFunctionTest;

  void OnScannerListReceived(
      const std::vector<DocumentScanInterface::ScannerDescription>&
          scanner_descriptions,
      const std::string& error);
  void OnResultsReceived(const std::string& scanned_image,
                         const std::string& mime_type,
                         const std::string& error);

  scoped_ptr<document_scan::Scan::Params> params_;
  scoped_ptr<DocumentScanInterface> document_scan_interface_;

  DISALLOW_COPY_AND_ASSIGN(DocumentScanScanFunction);
};

}  // namespace core_api

}  // namespace extensions

#endif  // EXTENSIONS_BROWSER_API_DOCUMENT_SCAN_DOCUMENT_SCAN_API_H_