| Index: Source/modules/bluetooth/BluetoothSupplement.cpp
|
| diff --git a/Source/modules/bluetooth/BluetoothSupplement.cpp b/Source/modules/bluetooth/BluetoothSupplement.cpp
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..f1f466031675da2bd1f0432b235e6fb11da3b200
|
| --- /dev/null
|
| +++ b/Source/modules/bluetooth/BluetoothSupplement.cpp
|
| @@ -0,0 +1,50 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "config.h"
|
| +#include "modules/bluetooth/BluetoothSupplement.h"
|
| +
|
| +#include "core/frame/LocalDOMWindow.h"
|
| +#include "public/platform/Platform.h"
|
| +
|
| +namespace blink {
|
| +
|
| +const char* BluetoothSupplement::supplementName()
|
| +{
|
| + return "BluetoothSupplement";
|
| +}
|
| +
|
| +BluetoothSupplement::BluetoothSupplement(WebBluetooth* bluetooth)
|
| + : m_bluetooth(bluetooth)
|
| +{
|
| +}
|
| +
|
| +void BluetoothSupplement::provideTo(LocalFrame& frame, WebBluetooth* bluetooth)
|
| +{
|
| + OwnPtrWillBeRawPtr<BluetoothSupplement> bluetoothSupplement = adoptPtrWillBeNoop(new BluetoothSupplement(bluetooth));
|
| + WillBeHeapSupplement<LocalFrame>::provideTo(frame, supplementName(), bluetoothSupplement.release());
|
| +};
|
| +
|
| +WebBluetooth* BluetoothSupplement::from(LocalFrame* frame)
|
| +{
|
| + BluetoothSupplement* supplement = static_cast<BluetoothSupplement*>(WillBeHeapSupplement<LocalFrame>::from(frame, supplementName()));
|
| + return supplement ? supplement->m_bluetooth : nullptr;
|
| +}
|
| +
|
| +WebBluetooth* BluetoothSupplement::from(ScriptState* scriptState)
|
| +{
|
| + LocalDOMWindow* window = scriptState->domWindow();
|
| + if (window && window->frame()) {
|
| + if (WebBluetooth* bluetooth = from(window->frame()))
|
| + return bluetooth;
|
| + }
|
| + return Platform::current()->bluetooth();
|
| +}
|
| +
|
| +DEFINE_TRACE(BluetoothSupplement)
|
| +{
|
| + WillBeHeapSupplement<LocalFrame>::trace(visitor);
|
| +}
|
| +
|
| +}; // blink
|
|
|