OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "modules/sensor/Sensor.h" | 5 #include "modules/sensor/Sensor.h" |
6 | 6 |
7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
8 #include "core/dom/ExceptionCode.h" | 8 #include "core/dom/ExceptionCode.h" |
9 #include "core/dom/TaskRunnerHelper.h" | 9 #include "core/dom/TaskRunnerHelper.h" |
10 #include "core/inspector/ConsoleMessage.h" | 10 #include "core/inspector/ConsoleMessage.h" |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 if (sensor_proxy_) | 154 if (sensor_proxy_) |
155 return; | 155 return; |
156 | 156 |
157 Document* document = ToDocument(GetExecutionContext()); | 157 Document* document = ToDocument(GetExecutionContext()); |
158 if (!document || !document->GetFrame()) | 158 if (!document || !document->GetFrame()) |
159 return; | 159 return; |
160 | 160 |
161 auto provider = SensorProviderProxy::From(document->GetFrame()); | 161 auto provider = SensorProviderProxy::From(document->GetFrame()); |
162 sensor_proxy_ = provider->GetSensorProxy(type_); | 162 sensor_proxy_ = provider->GetSensorProxy(type_); |
163 | 163 |
164 if (!sensor_proxy_) | 164 if (!sensor_proxy_) { |
165 sensor_proxy_ = provider->CreateSensorProxy(type_, document->GetPage()); | 165 RefPtr<SecurityOrigin> origin = GetExecutionContext()->GetSecurityOrigin(); |
| 166 DCHECK(origin); |
| 167 sensor_proxy_ = provider->CreateSensorProxy(type_, document->GetPage(), |
| 168 std::move(origin)); |
| 169 } |
166 } | 170 } |
167 | 171 |
168 void Sensor::ContextDestroyed(ExecutionContext*) { | 172 void Sensor::ContextDestroyed(ExecutionContext*) { |
169 if (state_ == Sensor::SensorState::kActivated || | 173 if (state_ == Sensor::SensorState::kActivated || |
170 state_ == Sensor::SensorState::kActivating) | 174 state_ == Sensor::SensorState::kActivating) |
171 StopListening(); | 175 StopListening(); |
172 } | 176 } |
173 | 177 |
174 void Sensor::OnSensorInitialized() { | 178 void Sensor::OnSensorInitialized() { |
175 if (state_ != Sensor::SensorState::kActivating) | 179 if (state_ != Sensor::SensorState::kActivating) |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 } | 299 } |
296 | 300 |
297 bool Sensor::CanReturnReadings() const { | 301 bool Sensor::CanReturnReadings() const { |
298 if (!IsActivated()) | 302 if (!IsActivated()) |
299 return false; | 303 return false; |
300 DCHECK(sensor_proxy_); | 304 DCHECK(sensor_proxy_); |
301 return sensor_proxy_->Reading().timestamp != 0.0; | 305 return sensor_proxy_->Reading().timestamp != 0.0; |
302 } | 306 } |
303 | 307 |
304 } // namespace blink | 308 } // namespace blink |
OLD | NEW |