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 "config.h" |
| 6 #include "modules/bluetooth/BluetoothSupplement.h" |
| 7 |
| 8 #include "core/frame/LocalDOMWindow.h" |
| 9 #include "public/platform/Platform.h" |
| 10 |
| 11 namespace blink { |
| 12 |
| 13 const char* BluetoothSupplement::supplementName() |
| 14 { |
| 15 return "BluetoothSupplement"; |
| 16 } |
| 17 |
| 18 BluetoothSupplement::BluetoothSupplement(WebBluetooth* bluetooth) |
| 19 : m_bluetooth(bluetooth) |
| 20 { |
| 21 } |
| 22 |
| 23 void BluetoothSupplement::provideTo(LocalFrame& frame, WebBluetooth* bluetooth) |
| 24 { |
| 25 OwnPtrWillBeRawPtr<BluetoothSupplement> bluetoothSupplement = adoptPtrWillBe
Noop(new BluetoothSupplement(bluetooth)); |
| 26 WillBeHeapSupplement<LocalFrame>::provideTo(frame, supplementName(), bluetoo
thSupplement.release()); |
| 27 }; |
| 28 |
| 29 WebBluetooth* BluetoothSupplement::from(ScriptState* scriptState) |
| 30 { |
| 31 LocalDOMWindow* window = scriptState->domWindow(); |
| 32 if (window && window->frame()) { |
| 33 BluetoothSupplement* supplement = static_cast<BluetoothSupplement*>(Will
BeHeapSupplement<LocalFrame>::from(window->frame(), supplementName())); |
| 34 if (supplement && supplement->m_bluetooth) |
| 35 return supplement->m_bluetooth; |
| 36 } |
| 37 return Platform::current()->bluetooth(); |
| 38 } |
| 39 |
| 40 DEFINE_TRACE(BluetoothSupplement) |
| 41 { |
| 42 WillBeHeapSupplement<LocalFrame>::trace(visitor); |
| 43 } |
| 44 |
| 45 }; // blink |
OLD | NEW |