| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "modules/bluetooth/BluetoothSupplement.h" | |
| 6 | |
| 7 #include "core/dom/Document.h" | |
| 8 | |
| 9 namespace blink { | |
| 10 | |
| 11 const char* BluetoothSupplement::supplementName() { | |
| 12 return "BluetoothSupplement"; | |
| 13 } | |
| 14 | |
| 15 BluetoothSupplement::BluetoothSupplement(WebBluetooth* bluetooth) | |
| 16 : m_bluetooth(bluetooth) {} | |
| 17 | |
| 18 void BluetoothSupplement::provideTo(LocalFrame& frame, | |
| 19 WebBluetooth* bluetooth) { | |
| 20 BluetoothSupplement* bluetoothSupplement = new BluetoothSupplement(bluetooth); | |
| 21 Supplement<LocalFrame>::provideTo(frame, supplementName(), | |
| 22 bluetoothSupplement); | |
| 23 }; | |
| 24 | |
| 25 WebBluetooth* BluetoothSupplement::from(LocalFrame* frame) { | |
| 26 BluetoothSupplement* supplement = static_cast<BluetoothSupplement*>( | |
| 27 Supplement<LocalFrame>::from(frame, supplementName())); | |
| 28 | |
| 29 ASSERT(supplement); | |
| 30 ASSERT(supplement->m_bluetooth); | |
| 31 | |
| 32 return supplement->m_bluetooth; | |
| 33 } | |
| 34 | |
| 35 WebBluetooth* BluetoothSupplement::fromScriptState(ScriptState* scriptState) { | |
| 36 return fromExecutionContext(scriptState->getExecutionContext()); | |
| 37 } | |
| 38 | |
| 39 WebBluetooth* BluetoothSupplement::fromExecutionContext( | |
| 40 ExecutionContext* executionContext) { | |
| 41 if (!executionContext->isDocument()) { | |
| 42 return nullptr; | |
| 43 } | |
| 44 return BluetoothSupplement::from( | |
| 45 static_cast<Document*>(executionContext)->frame()); | |
| 46 } | |
| 47 | |
| 48 DEFINE_TRACE(BluetoothSupplement) { | |
| 49 Supplement<LocalFrame>::trace(visitor); | |
| 50 } | |
| 51 | |
| 52 } // namespace blink | |
| OLD | NEW |