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

Side by Side Diff: third_party/WebKit/Source/modules/sensor/NavigatorAmbientLightSensor.cpp

Issue 1892083002: Generic Sensor API : Ambient Light Sensor API. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
OLDNEW
(Empty)
1 // Copyright 2016 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 "modules/sensor/NavigatorAmbientLightSensor.h"
6
7 #include "bindings/core/v8/ExceptionState.h"
8 #include "core/dom/ExecutionContext.h"
9 #include "core/frame/Navigator.h"
10
11 namespace blink {
12
13 NavigatorAmbientLightSensor::NavigatorAmbientLightSensor()
14 {
15 }
16
17 // static
18 NavigatorAmbientLightSensor& NavigatorAmbientLightSensor::from(Navigator& naviga tor)
19 {
20 NavigatorAmbientLightSensor* supplement = static_cast<NavigatorAmbientLightS ensor*>(Supplement<Navigator>::from(navigator, supplementName()));
21 if (!supplement) {
22 supplement = new NavigatorAmbientLightSensor();
23 provideTo(navigator, supplementName(), supplement);
24 }
25 return *supplement;
26 }
27
28 // static
29 AmbientLightSensor* NavigatorAmbientLightSensor::lightSensor(ExecutionContext* c ontext, Navigator& navigator, ExceptionState& exceptionState)
30 {
31 NavigatorAmbientLightSensor& self = NavigatorAmbientLightSensor::from(naviga tor);
32 if (!self.m_lightSensors)
33 self.m_lightSensors = AmbientLightSensor::create(context, exceptionState );
34
35 if (exceptionState.hadException())
36 return nullptr;
37
38 return self.m_lightSensors.get();
39 }
40
41 // static
42 const char* NavigatorAmbientLightSensor::supplementName()
43 {
44 return "NavigatorAmbientLightSensor";
45 }
46
47 NavigatorAmbientLightSensor::~NavigatorAmbientLightSensor()
48 {
49 }
50
51 DEFINE_TRACE(NavigatorAmbientLightSensor)
52 {
53 visitor->trace(m_lightSensors);
54 Supplement<Navigator>::trace(visitor);
55 }
56
57 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698