summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/modules/sensor/sensor_proxy.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/blink/renderer/modules/sensor/sensor_proxy.cc')
-rw-r--r--chromium/third_party/blink/renderer/modules/sensor/sensor_proxy.cc31
1 files changed, 22 insertions, 9 deletions
diff --git a/chromium/third_party/blink/renderer/modules/sensor/sensor_proxy.cc b/chromium/third_party/blink/renderer/modules/sensor/sensor_proxy.cc
index 12f25645b02..584ecf60106 100644
--- a/chromium/third_party/blink/renderer/modules/sensor/sensor_proxy.cc
+++ b/chromium/third_party/blink/renderer/modules/sensor/sensor_proxy.cc
@@ -56,7 +56,7 @@ void SensorProxy::Detach() {
}
}
-void SensorProxy::ReportError(ExceptionCode code, const String& message) {
+void SensorProxy::ReportError(DOMExceptionCode code, const String& message) {
auto copy = observers_;
for (Observer* observer : copy) {
observer->OnSensorError(code, message, String());
@@ -103,17 +103,30 @@ void SensorProxy::UpdateSuspendedStatus() {
if (!IsInitialized())
return;
- bool page_visible =
- GetPage()->VisibilityState() == mojom::PageVisibilityState::kVisible;
+ if (ShouldSuspendUpdates())
+ Suspend();
+ else
+ Resume();
+}
+
+bool SensorProxy::ShouldSuspendUpdates() const {
+ if (GetPage()->VisibilityState() != mojom::PageVisibilityState::kVisible)
+ return true;
LocalFrame* focused_frame = GetPage()->GetFocusController().FocusedFrame();
- bool main_frame_focused =
- focused_frame && !focused_frame->IsCrossOriginSubframe();
+ if (!focused_frame)
+ return true;
- if (page_visible && main_frame_focused)
- Resume();
- else
- Suspend();
+ LocalFrame* this_frame = provider_->GetSupplementable();
+ if (focused_frame == this_frame)
+ return false;
+
+ const SecurityOrigin* focused_frame_origin =
+ focused_frame->GetSecurityContext()->GetSecurityOrigin();
+ const SecurityOrigin* this_origin =
+ this_frame->GetSecurityContext()->GetSecurityOrigin();
+
+ return !focused_frame_origin->CanAccess(this_origin);
}
SensorProvider* SensorProxy::sensor_provider() const {