OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "modules/bluetooth/BluetoothDevice.h" | 5 #include "modules/bluetooth/BluetoothDevice.h" |
6 | 6 |
7 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 7 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
8 #include "bindings/core/v8/ScriptPromise.h" | 8 #include "bindings/core/v8/ScriptPromise.h" |
9 #include "bindings/core/v8/ScriptPromiseResolver.h" | 9 #include "bindings/core/v8/ScriptPromiseResolver.h" |
10 #include "core/dom/DOMException.h" | 10 #include "core/dom/DOMException.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 isNull = false; | 62 isNull = false; |
63 return m_webDevice->productID; | 63 return m_webDevice->productID; |
64 } | 64 } |
65 | 65 |
66 unsigned BluetoothDevice::productVersion(bool& isNull) | 66 unsigned BluetoothDevice::productVersion(bool& isNull) |
67 { | 67 { |
68 isNull = false; | 68 isNull = false; |
69 return m_webDevice->productVersion; | 69 return m_webDevice->productVersion; |
70 } | 70 } |
71 | 71 |
72 bool BluetoothDevice::paired() | |
73 { | |
74 return m_webDevice->paired; | |
75 } | |
76 | |
77 Vector<String> BluetoothDevice::uuids() | 72 Vector<String> BluetoothDevice::uuids() |
78 { | 73 { |
79 Vector<String> uuids(m_webDevice->uuids.size()); | 74 Vector<String> uuids(m_webDevice->uuids.size()); |
80 for (size_t i = 0; i < m_webDevice->uuids.size(); ++i) | 75 for (size_t i = 0; i < m_webDevice->uuids.size(); ++i) |
81 uuids[i] = m_webDevice->uuids[i]; | 76 uuids[i] = m_webDevice->uuids[i]; |
82 return uuids; | 77 return uuids; |
83 } | 78 } |
84 | 79 |
85 ScriptPromise BluetoothDevice::connectGATT(ScriptState* scriptState) | 80 ScriptPromise BluetoothDevice::connectGATT(ScriptState* scriptState) |
86 { | 81 { |
87 WebBluetooth* webbluetooth = BluetoothSupplement::fromScriptState(scriptStat
e); | 82 WebBluetooth* webbluetooth = BluetoothSupplement::fromScriptState(scriptStat
e); |
88 if (!webbluetooth) | 83 if (!webbluetooth) |
89 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(NotSupportedError)); | 84 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(NotSupportedError)); |
90 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; | 85 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
91 ScriptPromise promise = resolver->promise(); | 86 ScriptPromise promise = resolver->promise(); |
92 webbluetooth->connectGATT(id(), new CallbackPromiseAdapter<BluetoothGATTRemo
teServer, BluetoothError>(resolver)); | 87 webbluetooth->connectGATT(id(), new CallbackPromiseAdapter<BluetoothGATTRemo
teServer, BluetoothError>(resolver)); |
93 return promise; | 88 return promise; |
94 } | 89 } |
95 | 90 |
96 } // namespace blink | 91 } // namespace blink |
OLD | NEW |