| Index: third_party/WebKit/Source/modules/device_light/DeviceLightDispatcher.cpp
|
| diff --git a/third_party/WebKit/Source/modules/device_light/DeviceLightDispatcher.cpp b/third_party/WebKit/Source/modules/device_light/DeviceLightDispatcher.cpp
|
| index 19d9bc54f8986d181a567cbaf2b12a05a2de28df..3d6a1ee76b542d75fee2637862742c10f34a5968 100644
|
| --- a/third_party/WebKit/Source/modules/device_light/DeviceLightDispatcher.cpp
|
| +++ b/third_party/WebKit/Source/modules/device_light/DeviceLightDispatcher.cpp
|
| @@ -4,9 +4,22 @@
|
|
|
| #include "modules/device_light/DeviceLightDispatcher.h"
|
|
|
| +#include <cmath>
|
| +
|
| #include "modules/device_light/DeviceLightController.h"
|
| #include "public/platform/Platform.h"
|
|
|
| +namespace {
|
| +double EnsureRoundedLuxValue(double lux) {
|
| + // Make sure to round the lux value to nearest integer, to
|
| + // avoid too precise values and hence reduce fingerprinting risk.
|
| + // The special case when the lux value is infinity (no data can be
|
| + // provided) is simply returned as is.
|
| + // TODO(timvolodine): consider reducing the lux value precision further.
|
| + return std::isinf(lux) ? lux : std::round(lux);
|
| +}
|
| +} // namespace
|
| +
|
| namespace blink {
|
|
|
| DeviceLightDispatcher& DeviceLightDispatcher::Instance() {
|
| @@ -33,8 +46,11 @@ void DeviceLightDispatcher::StopListening() {
|
| }
|
|
|
| void DeviceLightDispatcher::DidChangeDeviceLight(double value) {
|
| - last_device_light_data_ = value;
|
| - NotifyControllers();
|
| + double newValue = EnsureRoundedLuxValue(value);
|
| + if (last_device_light_data_ != newValue) {
|
| + last_device_light_data_ = newValue;
|
| + NotifyControllers();
|
| + }
|
| }
|
|
|
| double DeviceLightDispatcher::LatestDeviceLightData() const {
|
|
|