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.
5 #include "content/child/bluetooth/web_bluetooth_impl.h"
9 WebBluetoothImpl::WebBluetoothImpl()
10 : m_bluetoothMockDataSet(MockData::NOT_MOCKING),
11 m_bluetoothRequestDeviceRejectType(
12 blink::WebBluetoothError::NotFoundError) {
15 void WebBluetoothImpl::requestDevice(
16 blink::WebBluetoothRequestDeviceCallbacks* callbacks) {
17 // Mock implementation of blink::WebBluetooth until a more complete
18 // implementation is built out.
19 switch (m_bluetoothMockDataSet) {
20 case MockData::NOT_MOCKING: {
21 blink::WebBluetoothError* error = new blink::WebBluetoothError(
22 blink::WebBluetoothError::NotFoundError, "");
23 callbacks->onError(error);
26 case MockData::REJECT: {
27 blink::WebBluetoothError* error =
28 new blink::WebBluetoothError(m_bluetoothRequestDeviceRejectType, "");
29 callbacks->onError(error);
32 case MockData::RESOLVE: {
33 callbacks->onSuccess();
39 void WebBluetoothImpl::SetBluetoothMockDataSetForTesting(
40 const std::string& name) {
41 if (name == "RejectRequestDevice_NotFoundError") {
42 m_bluetoothMockDataSet = MockData::REJECT;
43 m_bluetoothRequestDeviceRejectType =
44 blink::WebBluetoothError::NotFoundError;
45 } else if (name == "RejectRequestDevice_SecurityError") {
46 m_bluetoothMockDataSet = MockData::REJECT;
47 m_bluetoothRequestDeviceRejectType =
48 blink::WebBluetoothError::SecurityError;
49 } else if (name == "ResolveRequestDevice_Empty") {
50 m_bluetoothMockDataSet = MockData::RESOLVE;
52 m_bluetoothMockDataSet = MockData::NOT_MOCKING;
56 } // namespace content