| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/BluetoothSupplement.h" | 5 #include "modules/bluetooth/BluetoothSupplement.h" |
| 6 | 6 |
| 7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
| 8 | 8 |
| 9 namespace blink { | 9 namespace blink { |
| 10 | 10 |
| 11 const char* BluetoothSupplement::supplementName() | 11 const char* BluetoothSupplement::supplementName() |
| 12 { | 12 { |
| 13 return "BluetoothSupplement"; | 13 return "BluetoothSupplement"; |
| 14 } | 14 } |
| 15 | 15 |
| 16 BluetoothSupplement::BluetoothSupplement(WebBluetooth* bluetooth) | 16 BluetoothSupplement::BluetoothSupplement(WebBluetooth* bluetooth) |
| 17 : m_bluetooth(bluetooth) | 17 : m_bluetooth(bluetooth) |
| 18 { | 18 { |
| 19 } | 19 } |
| 20 | 20 |
| 21 void BluetoothSupplement::provideTo(LocalFrame& frame, WebBluetooth* bluetooth) | 21 void BluetoothSupplement::provideTo(LocalFrame& frame, WebBluetooth* bluetooth) |
| 22 { | 22 { |
| 23 RawPtr<BluetoothSupplement> bluetoothSupplement = new BluetoothSupplement(bl
uetooth); | 23 RawPtr<BluetoothSupplement> bluetoothSupplement = new BluetoothSupplement(bl
uetooth); |
| 24 HeapSupplement<LocalFrame>::provideTo(frame, supplementName(), bluetoothSupp
lement.release()); | 24 Supplement<LocalFrame>::provideTo(frame, supplementName(), bluetoothSuppleme
nt.release()); |
| 25 }; | 25 }; |
| 26 | 26 |
| 27 WebBluetooth* BluetoothSupplement::from(LocalFrame* frame) | 27 WebBluetooth* BluetoothSupplement::from(LocalFrame* frame) |
| 28 { | 28 { |
| 29 BluetoothSupplement* supplement = static_cast<BluetoothSupplement*>(HeapSupp
lement<LocalFrame>::from(frame, supplementName())); | 29 BluetoothSupplement* supplement = static_cast<BluetoothSupplement*>(Suppleme
nt<LocalFrame>::from(frame, supplementName())); |
| 30 | 30 |
| 31 ASSERT(supplement); | 31 ASSERT(supplement); |
| 32 ASSERT(supplement->m_bluetooth); | 32 ASSERT(supplement->m_bluetooth); |
| 33 | 33 |
| 34 return supplement->m_bluetooth; | 34 return supplement->m_bluetooth; |
| 35 } | 35 } |
| 36 | 36 |
| 37 WebBluetooth* BluetoothSupplement::fromScriptState(ScriptState* scriptState) | 37 WebBluetooth* BluetoothSupplement::fromScriptState(ScriptState* scriptState) |
| 38 { | 38 { |
| 39 return fromExecutionContext(scriptState->getExecutionContext()); | 39 return fromExecutionContext(scriptState->getExecutionContext()); |
| 40 } | 40 } |
| 41 | 41 |
| 42 WebBluetooth* BluetoothSupplement::fromExecutionContext(ExecutionContext* execut
ionContext) | 42 WebBluetooth* BluetoothSupplement::fromExecutionContext(ExecutionContext* execut
ionContext) |
| 43 { | 43 { |
| 44 if (!executionContext->isDocument()) { | 44 if (!executionContext->isDocument()) { |
| 45 return nullptr; | 45 return nullptr; |
| 46 } | 46 } |
| 47 return BluetoothSupplement::from(static_cast<Document*>(executionContext)->f
rame()); | 47 return BluetoothSupplement::from(static_cast<Document*>(executionContext)->f
rame()); |
| 48 } | 48 } |
| 49 | 49 |
| 50 DEFINE_TRACE(BluetoothSupplement) | 50 DEFINE_TRACE(BluetoothSupplement) |
| 51 { | 51 { |
| 52 HeapSupplement<LocalFrame>::trace(visitor); | 52 Supplement<LocalFrame>::trace(visitor); |
| 53 } | 53 } |
| 54 | 54 |
| 55 } // namespace blink | 55 } // namespace blink |
| OLD | NEW |