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

Unified Diff: Source/modules/geolocation/GeolocationController.cpp

Issue 27368003: Add page visibility observer for Geolocation (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix nit Created 7 years, 2 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/modules/geolocation/GeolocationController.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/geolocation/GeolocationController.cpp
diff --git a/Source/modules/geolocation/GeolocationController.cpp b/Source/modules/geolocation/GeolocationController.cpp
index dd9f80e24ffe4ff027448296d12bf6a34d421d42..1956eec6345fe9529451a4a5ae5c6e66895f6776 100644
--- a/Source/modules/geolocation/GeolocationController.cpp
+++ b/Source/modules/geolocation/GeolocationController.cpp
@@ -34,8 +34,8 @@
namespace WebCore {
GeolocationController::GeolocationController(Page* page, GeolocationClient* client)
- : m_client(client)
- , m_page(page)
+ : PageLifecycleObserver(page)
+ , m_client(client)
{
}
@@ -64,7 +64,7 @@ void GeolocationController::addObserver(Geolocation* observer, bool enableHighAc
if (m_client) {
if (enableHighAccuracy)
m_client->setEnableHighAccuracy(true);
- if (wasEmpty)
+ if (wasEmpty && page()->visibilityState() == PageVisibilityStateVisible)
m_client->startUpdating();
}
}
@@ -99,7 +99,7 @@ void GeolocationController::cancelPermissionRequest(Geolocation* geolocation)
void GeolocationController::positionChanged(GeolocationPosition* position)
{
- position = InspectorInstrumentation::overrideGeolocationPosition(m_page, position);
+ position = InspectorInstrumentation::overrideGeolocationPosition(page(), position);
if (!position) {
errorOccurred(GeolocationError::create(GeolocationError::PositionUnavailable, "PositionUnavailable").get());
return;
@@ -130,6 +130,17 @@ GeolocationPosition* GeolocationController::lastPosition()
return m_client->lastPosition();
}
+void GeolocationController::pageVisibilityChanged()
+{
+ if (m_observers.isEmpty() || !m_client)
+ return;
+
+ if (page()->visibilityState() == PageVisibilityStateVisible)
+ m_client->startUpdating();
+ else
+ m_client->stopUpdating();
+}
+
const char* GeolocationController::supplementName()
{
return "GeolocationController";
« no previous file with comments | « Source/modules/geolocation/GeolocationController.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698