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

Unified Diff: third_party/WebKit/Source/modules/device_light/DeviceLightDispatcher.cpp

Issue 2772843002: [DeviceLight] Ensure to round lux value to avoid fingerprinting risk. (Closed)
Patch Set: add expectations Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/ambient-light/rounded-lux-value-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1629d9bce07305ed2901eb4b4b8a0a80022ef78a..f7d241748d4c93acc5816da64936a95cc4b42108 100644
--- a/third_party/WebKit/Source/modules/device_light/DeviceLightDispatcher.cpp
+++ b/third_party/WebKit/Source/modules/device_light/DeviceLightDispatcher.cpp
@@ -4,9 +4,21 @@
#include "modules/device_light/DeviceLightDispatcher.h"
+#include <math.h>
+
#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.
+ return isinf(lux) ? lux : std::round(lux);
palmer 2017/03/23 19:00:19 Apologies in advance for the drive-by. :) A round
timvolodine 2017/04/20 01:34:30 Acknowledged.
+}
+} // namespace
+
namespace blink {
DeviceLightDispatcher& DeviceLightDispatcher::instance() {
@@ -33,8 +45,11 @@ void DeviceLightDispatcher::stopListening() {
}
void DeviceLightDispatcher::didChangeDeviceLight(double value) {
- m_lastDeviceLightData = value;
- notifyControllers();
+ double newValue = EnsureRoundedLuxValue(value);
+ if (m_lastDeviceLightData != newValue) {
+ m_lastDeviceLightData = newValue;
+ notifyControllers();
+ }
}
double DeviceLightDispatcher::latestDeviceLightData() const {
« no previous file with comments | « third_party/WebKit/LayoutTests/ambient-light/rounded-lux-value-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698