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" | |
10 | 9 |
11 namespace blink { | 10 namespace blink { |
12 | 11 |
13 const char* BluetoothSupplement::supplementName() | 12 const char* BluetoothSupplement::supplementName() |
14 { | 13 { |
15 return "BluetoothSupplement"; | 14 return "BluetoothSupplement"; |
16 } | 15 } |
17 | 16 |
18 BluetoothSupplement::BluetoothSupplement(WebBluetooth* bluetooth) | 17 BluetoothSupplement::BluetoothSupplement(WebBluetooth* bluetooth) |
19 : m_bluetooth(bluetooth) | 18 : m_bluetooth(bluetooth) |
20 { | 19 { |
21 } | 20 } |
22 | 21 |
23 void BluetoothSupplement::provideTo(LocalFrame& frame, WebBluetooth* bluetooth) | 22 void BluetoothSupplement::provideTo(LocalFrame& frame, WebBluetooth* bluetooth) |
24 { | 23 { |
25 OwnPtrWillBeRawPtr<BluetoothSupplement> bluetoothSupplement = adoptPtrWillBe Noop(new BluetoothSupplement(bluetooth)); | 24 OwnPtrWillBeRawPtr<BluetoothSupplement> bluetoothSupplement = adoptPtrWillBe Noop(new BluetoothSupplement(bluetooth)); |
26 WillBeHeapSupplement<LocalFrame>::provideTo(frame, supplementName(), bluetoo thSupplement.release()); | 25 WillBeHeapSupplement<LocalFrame>::provideTo(frame, supplementName(), bluetoo thSupplement.release()); |
27 }; | 26 }; |
28 | 27 |
29 WebBluetooth* BluetoothSupplement::from(ScriptState* scriptState) | 28 WebBluetooth* BluetoothSupplement::from(LocalFrame* frame) |
29 { | |
30 BluetoothSupplement* supplement = static_cast<BluetoothSupplement*>(WillBeHe apSupplement<LocalFrame>::from(frame, supplementName())); | |
31 if (supplement && supplement->m_bluetooth) | |
haraken
2015/10/10 14:09:57
If the supplement is 0, don't you need to create a
ortuno
2015/10/12 17:33:52
We provide the Supplement to the frame here:
http
| |
32 return supplement->m_bluetooth; | |
33 return nullptr; | |
34 } | |
35 | |
36 WebBluetooth* BluetoothSupplement::getFromScriptState(ScriptState* scriptState) | |
haraken
2015/10/10 14:09:57
getFromScriptState => fromScriptState (Blink doesn
ortuno
2015/10/12 17:33:52
Done.
| |
30 { | 37 { |
31 LocalDOMWindow* window = scriptState->domWindow(); | 38 LocalDOMWindow* window = scriptState->domWindow(); |
32 if (window && window->frame()) { | 39 if (window && window->frame()) { |
haraken
2015/10/10 14:09:57
It is unsafe to use window->frame() directly. You
ortuno
2015/10/12 17:33:52
As suggested in the other CL I changed it to get t
Jeffrey Yasskin
2015/10/12 21:57:24
Thanks Kentaro for catching my mistakes in writing
haraken
2015/10/12 23:29:25
Sorry for not having a comment about it. We had to
| |
33 BluetoothSupplement* supplement = static_cast<BluetoothSupplement*>(Will BeHeapSupplement<LocalFrame>::from(window->frame(), supplementName())); | 40 return BluetoothSupplement::from(window->frame()); |
34 if (supplement && supplement->m_bluetooth) | |
35 return supplement->m_bluetooth; | |
36 } | 41 } |
37 return Platform::current()->bluetooth(); | 42 return nullptr; |
38 } | 43 } |
39 | 44 |
40 DEFINE_TRACE(BluetoothSupplement) | 45 DEFINE_TRACE(BluetoothSupplement) |
41 { | 46 { |
42 WillBeHeapSupplement<LocalFrame>::trace(visitor); | 47 WillBeHeapSupplement<LocalFrame>::trace(visitor); |
43 } | 48 } |
44 | 49 |
45 }; // blink | 50 }; // blink |
OLD | NEW |