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

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: Pass only origin to provider 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 RefPtr<SecurityOrigin> origin = getExecutionContext()->getSecurityOrigin();
171 DCHECK(origin);
170 m_sensorProxy = 172 m_sensorProxy =
171 provider->createSensor(m_type, createSensorReadingFactory()); 173 provider->createSensor(m_type, origin, createSensorReadingFactory());
Mikhail 2016/11/21 14:29:41 nit: std::move(origin)
riju_ 2016/11/23 09:02:28 Acknowledged.
172 } 174 }
173 } 175 }
174 176
175 void Sensor::contextDestroyed() { 177 void Sensor::contextDestroyed() {
176 if (m_state == Sensor::SensorState::Active || 178 if (m_state == Sensor::SensorState::Active ||
177 m_state == Sensor::SensorState::Activating) 179 m_state == Sensor::SensorState::Activating)
178 stopListening(); 180 stopListening();
179 } 181 }
180 182
181 void Sensor::onSensorInitialized() { 183 void Sensor::onSensorInitialized() {
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 void Sensor::notifyOnActivate() { 352 void Sensor::notifyOnActivate() {
351 dispatchEvent(Event::create(EventTypeNames::activate)); 353 dispatchEvent(Event::create(EventTypeNames::activate));
352 } 354 }
353 355
354 void Sensor::notifyError(DOMException* error) { 356 void Sensor::notifyError(DOMException* error) {
355 dispatchEvent( 357 dispatchEvent(
356 SensorErrorEvent::create(EventTypeNames::error, std::move(error))); 358 SensorErrorEvent::create(EventTypeNames::error, std::move(error)));
357 } 359 }
358 360
359 } // namespace blink 361 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698