| 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/ExecutionContextTask.h" | 9 #include "core/dom/ExecutionContextTask.h" |
| 10 #include "core/inspector/ConsoleMessage.h" | 10 #include "core/inspector/ConsoleMessage.h" |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 return; | 157 return; |
| 158 | 158 |
| 159 Document* document = toDocument(getExecutionContext()); | 159 Document* document = toDocument(getExecutionContext()); |
| 160 if (!document || !document->frame()) | 160 if (!document || !document->frame()) |
| 161 return; | 161 return; |
| 162 | 162 |
| 163 auto provider = SensorProviderProxy::from(document->frame()); | 163 auto provider = SensorProviderProxy::from(document->frame()); |
| 164 m_sensorProxy = provider->getSensorProxy(m_type); | 164 m_sensorProxy = provider->getSensorProxy(m_type); |
| 165 | 165 |
| 166 if (!m_sensorProxy) { | 166 if (!m_sensorProxy) { |
| 167 m_sensorProxy = provider->createSensorProxy(m_type, document->page(), | 167 RefPtr<SecurityOrigin> origin = getExecutionContext()->getSecurityOrigin(); |
| 168 createSensorReadingFactory()); | 168 DCHECK(origin); |
| 169 m_sensorProxy = |
| 170 provider->createSensorProxy(m_type, document->page(), std::move(origin), |
| 171 createSensorReadingFactory()); |
| 169 } | 172 } |
| 170 } | 173 } |
| 171 | 174 |
| 172 void Sensor::contextDestroyed() { | 175 void Sensor::contextDestroyed() { |
| 173 if (m_state == Sensor::SensorState::Active || | 176 if (m_state == Sensor::SensorState::Active || |
| 174 m_state == Sensor::SensorState::Activating) | 177 m_state == Sensor::SensorState::Activating) |
| 175 stopListening(); | 178 stopListening(); |
| 176 } | 179 } |
| 177 | 180 |
| 178 void Sensor::onSensorInitialized() { | 181 void Sensor::onSensorInitialized() { |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 void Sensor::notifyOnActivate() { | 317 void Sensor::notifyOnActivate() { |
| 315 dispatchEvent(Event::create(EventTypeNames::activate)); | 318 dispatchEvent(Event::create(EventTypeNames::activate)); |
| 316 } | 319 } |
| 317 | 320 |
| 318 void Sensor::notifyError(DOMException* error) { | 321 void Sensor::notifyError(DOMException* error) { |
| 319 dispatchEvent( | 322 dispatchEvent( |
| 320 SensorErrorEvent::create(EventTypeNames::error, std::move(error))); | 323 SensorErrorEvent::create(EventTypeNames::error, std::move(error))); |
| 321 } | 324 } |
| 322 | 325 |
| 323 } // namespace blink | 326 } // namespace blink |
| OLD | NEW |