diff options
author | bartfab@chromium.org <bartfab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-04 13:04:44 +0000 |
---|---|---|
committer | bartfab@chromium.org <bartfab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-04 13:04:44 +0000 |
commit | 439eb400f2b436ddea075b574da204f75ac04ee4 (patch) | |
tree | a8fe5c2c2891c8060ed5921cf45b36c93030e556 /content/public/browser | |
parent | 4b15160fbc0cdaea88842bb6ea36b40f8ef88c71 (diff) | |
download | chromium_src-439eb400f2b436ddea075b574da204f75ac04ee4.zip chromium_src-439eb400f2b436ddea075b574da204f75ac04ee4.tar.gz chromium_src-439eb400f2b436ddea075b574da204f75ac04ee4.tar.bz2 |
Add content API for requesting the current geolocation
This CL adds a RequestLocationUpdate() function through which the embedder can request a one-time callback when the next location update becomes available.
Unit tests and a method for easy location mocking are provided.
This CL depends on https://chromiumcodereview.appspot.com/10316007/
BUG=chromium-os:18710
TEST=unit_tests, content_unittests
Review URL: http://codereview.chromium.org/10344004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@135322 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/public/browser')
-rw-r--r-- | content/public/browser/geolocation.h | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/content/public/browser/geolocation.h b/content/public/browser/geolocation.h index 23868e9..673b275 100644 --- a/content/public/browser/geolocation.h +++ b/content/public/browser/geolocation.h @@ -13,16 +13,30 @@ namespace content { struct Geoposition; +typedef base::Callback<void(const Geoposition&)> GeolocationUpdateCallback; + // Overrides the current location for testing. This function may be called on // any thread. The completion callback will be invoked asynchronously on the // calling thread when the override operation is completed. -// This should be used instead of a mock location provider for a simpler way -// to provide fake location results when not testing the innards of the -// geolocation code. +// +// This function allows the current location to be faked without having to +// manually instantiate a GeolocationProvider backed by a MockLocationProvider +// that serves a fake location. +// +// Do not use this function in unit tests. The function instantiates the +// singleton geolocation stack in the background and manipulates it to report +// a fake location. Neither step can be undone, breaking unit test isolation +// (crbug.com/125931). void CONTENT_EXPORT OverrideLocationForTesting( const Geoposition& position, const base::Closure& completion_callback); +// Requests a one-time callback when the next location update becomes available. +// This function may be called on any thread. The callback will be invoked on +// the calling thread. +void CONTENT_EXPORT RequestLocationUpdate( + const GeolocationUpdateCallback& callback); + } // namespace content #endif // CONTENT_PUBLIC_BROWSER_GEOLOCATION_H_ |