Upstream version 11.40.271.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / modules / bluetooth / NavigatorBluetooth.cpp
1 // Copyright 2014 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/NavigatorBluetooth.h"
7
8 #include "core/frame/Navigator.h"
9 #include "modules/bluetooth/Bluetooth.h"
10
11 namespace blink {
12
13 NavigatorBluetooth& NavigatorBluetooth::from(Navigator& navigator)
14 {
15     NavigatorBluetooth* supplement = static_cast<NavigatorBluetooth*>(WillBeHeapSupplement<Navigator>::from(navigator, supplementName()));
16     if (!supplement) {
17         supplement = new NavigatorBluetooth();
18         provideTo(navigator, supplementName(), adoptPtrWillBeNoop(supplement));
19     }
20     return *supplement;
21 }
22
23 Bluetooth* NavigatorBluetooth::bluetooth(Navigator& navigator)
24 {
25     return NavigatorBluetooth::from(navigator).bluetooth();
26 }
27
28 Bluetooth* NavigatorBluetooth::bluetooth()
29 {
30     if (!m_bluetooth)
31         m_bluetooth = Bluetooth::create();
32     return m_bluetooth.get();
33 }
34
35 void NavigatorBluetooth::trace(Visitor* visitor)
36 {
37     visitor->trace(m_bluetooth);
38     WillBeHeapSupplement<Navigator>::trace(visitor);
39 }
40
41 NavigatorBluetooth::NavigatorBluetooth()
42 {
43 }
44
45 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(NavigatorBluetooth);
46
47 const char* NavigatorBluetooth::supplementName()
48 {
49     return "NavigatorBluetooth";
50 }
51
52 } // namespace blink