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

Side by Side Diff: third_party/WebKit/Source/modules/sensor/Sensor.cpp

Issue 2458453002: [sensors] Add Permission guard to the generic sensor apis.
Patch Set: Mikhail+alex comments Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 return; 160 return;
161 161
162 Document* document = toDocument(getExecutionContext()); 162 Document* document = toDocument(getExecutionContext());
163 if (!document || !document->frame()) 163 if (!document || !document->frame())
164 return; 164 return;
165 165
166 auto provider = SensorProviderProxy::from(document->frame()); 166 auto provider = SensorProviderProxy::from(document->frame());
167 m_sensorProxy = provider->getSensor(m_type); 167 m_sensorProxy = provider->getSensor(m_type);
168 168
169 if (!m_sensorProxy) { 169 if (!m_sensorProxy) {
170 m_sensorProxy = 170 m_sensorProxy = provider->createSensor(m_type, getExecutionContext(),
171 provider->createSensor(m_type, createSensorReadingFactory()); 171 createSensorReadingFactory());
172 // check if proxy was created correctly.
173 if (!m_sensorProxy)
shalamov 2016/11/18 13:17:45 This is sync operation that is initiated from Sens
riju_ 2016/11/21 11:23:28 Done.
174 reportError(NotAllowedError, "Could not create sensor proxy.");
172 } 175 }
173 } 176 }
174 177
175 void Sensor::contextDestroyed() { 178 void Sensor::contextDestroyed() {
176 if (m_state == Sensor::SensorState::Active || 179 if (m_state == Sensor::SensorState::Active ||
177 m_state == Sensor::SensorState::Activating) 180 m_state == Sensor::SensorState::Activating)
178 stopListening(); 181 stopListening();
179 } 182 }
180 183
181 void Sensor::onSensorInitialized() { 184 void Sensor::onSensorInitialized() {
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 void Sensor::notifyOnActivate() { 353 void Sensor::notifyOnActivate() {
351 dispatchEvent(Event::create(EventTypeNames::activate)); 354 dispatchEvent(Event::create(EventTypeNames::activate));
352 } 355 }
353 356
354 void Sensor::notifyError(DOMException* error) { 357 void Sensor::notifyError(DOMException* error) {
355 dispatchEvent( 358 dispatchEvent(
356 SensorErrorEvent::create(EventTypeNames::error, std::move(error))); 359 SensorErrorEvent::create(EventTypeNames::error, std::move(error)));
357 } 360 }
358 361
359 } // namespace blink 362 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698