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

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: 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..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";
« 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