Index: Source/modules/geolocation/GeolocationController.cpp |
diff --git a/Source/modules/geolocation/GeolocationController.cpp b/Source/modules/geolocation/GeolocationController.cpp |
index dd9f80e24ffe4ff027448296d12bf6a34d421d42..d7aec39a0cebd7f36488d241abef6eaa985b7cf6 100644 |
--- a/Source/modules/geolocation/GeolocationController.cpp |
+++ b/Source/modules/geolocation/GeolocationController.cpp |
@@ -34,7 +34,8 @@ |
namespace WebCore { |
GeolocationController::GeolocationController(Page* page, GeolocationClient* client) |
- : m_client(client) |
+ : PageLifecycleObserver(page) |
+ , m_client(client) |
, m_page(page) |
abarth-chromium
2013/10/15 20:57:50
Can we delete m_page and just use the one in PageL
Inactive
2013/10/15 21:32:09
Done.
|
{ |
} |
@@ -64,7 +65,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(); |
} |
} |
@@ -130,6 +131,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"; |