forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbarcode_detection_provider_mac.mm
50 lines (39 loc) · 1.62 KB
/
barcode_detection_provider_mac.mm
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
// Copyright 2018 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 "services/shape_detection/barcode_detection_provider_mac.h"
#include <memory>
#include <utility>
#include "base/logging.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "services/shape_detection/barcode_detection_impl_mac.h"
namespace shape_detection {
BarcodeDetectionProviderMac::BarcodeDetectionProviderMac() = default;
BarcodeDetectionProviderMac::~BarcodeDetectionProviderMac() = default;
// static
void BarcodeDetectionProviderMac::Create(
mojom::BarcodeDetectionProviderRequest request) {
mojo::MakeStrongBinding(std::make_unique<BarcodeDetectionProviderMac>(),
std::move(request));
}
void BarcodeDetectionProviderMac::CreateBarcodeDetection(
mojom::BarcodeDetectionRequest request,
mojom::BarcodeDetectorOptionsPtr options) {
// Barcode detection needs at least MAC OS X 10.10.
if (@available(macOS 10.10, *)) {
mojo::MakeStrongBinding(std::make_unique<BarcodeDetectionImplMac>(),
std::move(request));
}
}
void BarcodeDetectionProviderMac::EnumerateSupportedFormats(
EnumerateSupportedFormatsCallback callback) {
// Barcode detection needs at least MAC OS X 10.10.
if (@available(macOS 10.10, *)) {
// Mac implementation supports only one BarcodeFormat.
std::move(callback).Run({mojom::BarcodeFormat::QR_CODE});
return;
}
DLOG(ERROR) << "Platform not supported for Barcode Detection.";
std::move(callback).Run({});
}
} // namespace shape_detection