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

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

Issue 2332323002: [sensors] Ambient light sensor bindings implementation (Closed)
Patch Set: Add AmbientLightSensor to the list of expected global interfaces Created 4 years, 3 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/AmbientLightSensor.h"
6
7 #include "bindings/core/v8/ScriptPromise.h"
8 #include "bindings/core/v8/ScriptPromiseResolver.h"
9 #include "modules/sensor/AmbientLightSensorReading.h"
10
11 using device::mojom::blink::SensorType;
12
13 namespace blink {
14
15 // static
16 AmbientLightSensor* AmbientLightSensor::create(ExecutionContext* context, const SensorOptions& sensorOptions)
17 {
18 return new AmbientLightSensor(context, sensorOptions);
19 }
20
21 // static
22 AmbientLightSensor* AmbientLightSensor::create(ExecutionContext* context)
23 {
24 return create(context, SensorOptions());
25 }
26
27 AmbientLightSensor::AmbientLightSensor(ExecutionContext* executionContext, const SensorOptions& sensorOptions)
28 : Sensor(executionContext, sensorOptions, SensorType::AMBIENT_LIGHT)
29 {
30 }
31
32 AmbientLightSensorReading* AmbientLightSensor::reading() const
33 {
34 return static_cast<AmbientLightSensorReading*>(Sensor::reading());
35 }
36
37 SensorReading* AmbientLightSensor::createSensorReading(SensorProxy* proxy)
38 {
39 return AmbientLightSensorReading::create(proxy);
40 }
41
42 auto AmbientLightSensor::createSensorConfig(const SensorOptions& options, const SensorConfiguration& defaultConfig) -> SensorConfigurationPtr
43 {
44 auto result = device::mojom::blink::SensorConfiguration::New();
45 result->frequency = options.hasFrequency() ? options.frequency() : defaultCo nfig.frequency;
46 return result;
47 }
48
49 DEFINE_TRACE(AmbientLightSensor)
50 {
51 Sensor::trace(visitor);
52 }
53
54 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698