Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(186)

Side by Side Diff: Source/modules/bluetooth/BluetoothSupplement.cpp

Issue 1228283003: Attach a WebBluetooth to the LocalFrame and use it if it's available. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@error-enum-cleanup
Patch Set: Always use BluetoothSupplement to get the WebBluetooth instance. Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/modules/bluetooth/BluetoothSupplement.h ('k') | Source/modules/modules.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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
OLDNEW
« no previous file with comments | « Source/modules/bluetooth/BluetoothSupplement.h ('k') | Source/modules/modules.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698