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

Unified Diff: third_party/WebKit/Source/modules/sensor/SensorProxy.h

Issue 2458453002: [sensors] Add Permission guard to the generic sensor apis.
Patch Set: rebase + blink reformat Created 3 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/sensor/SensorProxy.h
diff --git a/third_party/WebKit/Source/modules/sensor/SensorProxy.h b/third_party/WebKit/Source/modules/sensor/SensorProxy.h
index 84bc7a4e4315591fb5aeb9bb2de3e237d0e671ac..585184fedb87fd974e83df4133da294ad09bcd7a 100644
--- a/third_party/WebKit/Source/modules/sensor/SensorProxy.h
+++ b/third_party/WebKit/Source/modules/sensor/SensorProxy.h
@@ -13,6 +13,8 @@
#include "mojo/public/cpp/bindings/binding.h"
#include "platform/Supplementable.h"
#include "platform/heap/Handle.h"
+#include "public/platform/modules/permissions/permission.mojom-blink.h"
+#include "public/platform/modules/permissions/permission_status.mojom-blink.h"
#include "wtf/Vector.h"
namespace blink {
@@ -20,11 +22,13 @@ namespace blink {
class SensorProviderProxy;
class SensorReading;
class SensorReadingUpdater;
+class SecurityOrigin;
// This class wraps 'Sensor' mojo interface and used by multiple
// JS sensor instances of the same type (within a single frame).
class SensorProxy final : public GarbageCollectedFinalized<SensorProxy>,
public device::mojom::blink::SensorClient,
+ public mojom::blink::PermissionObserver,
public PageVisibilityObserver {
USING_GARBAGE_COLLECTED_MIXIN(SensorProxy);
USING_PRE_FINALIZER(SensorProxy, Dispose);
@@ -103,7 +107,10 @@ class SensorProxy final : public GarbageCollectedFinalized<SensorProxy>,
friend class SensorProviderProxy;
friend class SensorReadingUpdaterContinuous;
friend class SensorReadingUpdaterOnChange;
- SensorProxy(device::mojom::blink::SensorType, SensorProviderProxy*, Page*);
+ SensorProxy(device::mojom::blink::SensorType,
+ RefPtr<SecurityOrigin>,
+ SensorProviderProxy*,
+ Page*);
// Updates sensor reading from shared buffer.
void UpdateSensorReading();
@@ -131,9 +138,13 @@ class SensorProxy final : public GarbageCollectedFinalized<SensorProxy>,
bool TryReadFromBuffer(device::SensorReading& result);
void OnAnimationFrame(double timestamp);
+ // PermissionObserver override.
+ void OnPermissionStatusChange(mojom::blink::PermissionStatus);
+
device::mojom::blink::SensorType type_;
device::mojom::blink::ReportingMode mode_;
Member<SensorProviderProxy> provider_;
+
using ObserversSet = HeapHashSet<WeakMember<Observer>>;
ObserversSet observers_;
@@ -158,6 +169,10 @@ class SensorProxy final : public GarbageCollectedFinalized<SensorProxy>,
sizeof(ReadingBuffer) ==
device::mojom::blink::SensorInitParams::kReadBufferSizeForTests,
"Check reading buffer size for tests");
+
+ RefPtr<SecurityOrigin> security_origin_;
+ mojo::Binding<mojom::blink::PermissionObserver> binding_;
+ bool permission_subscribed_;
};
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698