Index: content/browser/geolocation/geolocation_provider.cc |
diff --git a/content/browser/geolocation/geolocation_provider.cc b/content/browser/geolocation/geolocation_provider.cc |
index e090ac9b76c1175774a78908447ec86174098835..b491826177bfe12d08e5b14498fbcb16d47ae421 100644 |
--- a/content/browser/geolocation/geolocation_provider.cc |
+++ b/content/browser/geolocation/geolocation_provider.cc |
@@ -18,6 +18,7 @@ GeolocationProvider::GeolocationProvider() |
: base::Thread("Geolocation"), |
client_loop_(base::MessageLoopProxy::current()), |
is_permission_granted_(false), |
+ ignore_location_updates_(false), |
arbitrator_(NULL) { |
} |
@@ -127,12 +128,23 @@ void GeolocationProvider::CleanUp() { |
void GeolocationProvider::OnLocationUpdate(const Geoposition& position) { |
DCHECK(OnGeolocationThread()); |
+ // Will be true only in testing. |
+ if (ignore_location_updates_) |
+ return; |
client_loop_->PostTask( |
FROM_HERE, |
base::Bind(&GeolocationProvider::NotifyObservers, |
base::Unretained(this), position)); |
} |
+void GeolocationProvider::OverrideLocationForTesting( |
+ const Geoposition& position) { |
+ DCHECK(OnClientThread()); |
+ position_ = position; |
+ ignore_location_updates_ = true; |
+ NotifyObservers(position); |
+} |
+ |
bool GeolocationProvider::HasPermissionBeenGranted() const { |
DCHECK(OnClientThread()); |
return is_permission_granted_; |