Chromium Code Reviews| 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 "config.h" | 5 #include "config.h" |
| 6 #include "modules/bluetooth/BluetoothSupplement.h" | 6 #include "modules/bluetooth/BluetoothSupplement.h" |
| 7 | 7 |
| 8 #include "core/frame/LocalDOMWindow.h" | 8 #include "core/frame/LocalDOMWindow.h" |
| 9 #include "public/platform/Platform.h" | 9 #include "public/platform/Platform.h" |
| 10 | 10 |
| 11 namespace blink { | 11 namespace blink { |
| 12 | 12 |
| 13 const char* BluetoothSupplement::supplementName() | 13 const char* BluetoothSupplement::supplementName() |
| 14 { | 14 { |
| 15 return "BluetoothSupplement"; | 15 return "BluetoothSupplement"; |
| 16 } | 16 } |
| 17 | 17 |
| 18 BluetoothSupplement::BluetoothSupplement(WebBluetooth* bluetooth) | 18 BluetoothSupplement::BluetoothSupplement(WebBluetooth* bluetooth) |
| 19 : m_bluetooth(bluetooth) | 19 : m_bluetooth(bluetooth) |
| 20 { | 20 { |
| 21 } | 21 } |
| 22 | 22 |
| 23 void BluetoothSupplement::provideTo(LocalFrame& frame, WebBluetooth* bluetooth) | 23 void BluetoothSupplement::provideTo(LocalFrame& frame, WebBluetooth* bluetooth) |
| 24 { | 24 { |
| 25 OwnPtrWillBeRawPtr<BluetoothSupplement> bluetoothSupplement = adoptPtrWillBe Noop(new BluetoothSupplement(bluetooth)); | 25 OwnPtrWillBeRawPtr<BluetoothSupplement> bluetoothSupplement = adoptPtrWillBe Noop(new BluetoothSupplement(bluetooth)); |
| 26 WillBeHeapSupplement<LocalFrame>::provideTo(frame, supplementName(), bluetoo thSupplement.release()); | 26 WillBeHeapSupplement<LocalFrame>::provideTo(frame, supplementName(), bluetoo thSupplement.release()); |
| 27 }; | 27 }; |
| 28 | 28 |
| 29 WebBluetooth* BluetoothSupplement::from(ScriptState* scriptState) | 29 WebBluetooth* BluetoothSupplement::from(LocalDOMWindow* window) |
| 30 { | 30 { |
| 31 LocalDOMWindow* window = scriptState->domWindow(); | |
| 32 if (window && window->frame()) { | 31 if (window && window->frame()) { |
| 33 BluetoothSupplement* supplement = static_cast<BluetoothSupplement*>(Will BeHeapSupplement<LocalFrame>::from(window->frame(), supplementName())); | 32 BluetoothSupplement* supplement = static_cast<BluetoothSupplement*>(Will BeHeapSupplement<LocalFrame>::from(window->frame(), supplementName())); |
| 34 if (supplement && supplement->m_bluetooth) | 33 if (supplement && supplement->m_bluetooth) |
| 35 return supplement->m_bluetooth; | 34 return supplement->m_bluetooth; |
| 36 } | 35 } |
| 37 return Platform::current()->bluetooth(); | 36 return Platform::current()->bluetooth(); |
| 38 } | 37 } |
| 39 | 38 |
| 39 WebBluetooth* BluetoothSupplement::from(ScriptState* scriptState) | |
|
scheib
2015/10/01 22:05:23
Ordering, here or in .h should adjust: http://goog
ortuno
2015/10/03 04:03:04
Done.
| |
| 40 { | |
| 41 return BluetoothSupplement::from(scriptState->domWindow()); | |
| 42 } | |
| 43 | |
| 44 WebBluetooth* BluetoothSupplement::from(ExecutionContext* executionContext) | |
| 45 { | |
| 46 return BluetoothSupplement::from(executionContext->executingWindow()); | |
| 47 } | |
| 48 | |
| 40 DEFINE_TRACE(BluetoothSupplement) | 49 DEFINE_TRACE(BluetoothSupplement) |
| 41 { | 50 { |
| 42 WillBeHeapSupplement<LocalFrame>::trace(visitor); | 51 WillBeHeapSupplement<LocalFrame>::trace(visitor); |
| 43 } | 52 } |
| 44 | 53 |
| 45 }; // blink | 54 }; // blink |
| OLD | NEW |