diff options
| author | Steve Block <steveblock@google.com> | 2012-05-16 12:41:18 +0100 |
|---|---|---|
| committer | Steve Block <steveblock@google.com> | 2012-05-22 12:07:55 +0100 |
| commit | f3f60d9328d8acfedf987a73631fc90c39bf5447 (patch) | |
| tree | 1df1425cd3c08ef1e29dee80877406332eafa873 /core/java/android/webkit/MockGeolocation.java | |
| parent | 32a85291efb1b5ef0c3dbd7b581df27f1d03305a (diff) | |
Switch Geolocation DRT methods to control client-based mock
Note that we plumb DRT Geolocation mock calls via WebView. This is required
because the WebCore client-based mock is not a static but is tied to the Page.
See WebKit change Ib74a3c05991593e75c3138415d4ac0bf0c9aefa9.
Bug: 6511338
Change-Id: I6d88d5dce5c2148812b191a5b452718bf0854aeb
Diffstat (limited to 'core/java/android/webkit/MockGeolocation.java')
| -rw-r--r-- | core/java/android/webkit/MockGeolocation.java | 44 |
1 files changed, 27 insertions, 17 deletions
diff --git a/core/java/android/webkit/MockGeolocation.java b/core/java/android/webkit/MockGeolocation.java index fbda4924da0e..d8dc7240db0b 100644 --- a/core/java/android/webkit/MockGeolocation.java +++ b/core/java/android/webkit/MockGeolocation.java @@ -17,21 +17,29 @@ package android.webkit; /** - * This class is simply a container for the methods used to configure WebKit's - * mock Geolocation service for use in LayoutTests. + * Used to configure the mock Geolocation client for the LayoutTests. * @hide */ public final class MockGeolocation { + private WebViewCore mWebViewCore; - // Global instance of a MockGeolocation - private static MockGeolocation sMockGeolocation; + public MockGeolocation(WebViewCore webViewCore) { + mWebViewCore = webViewCore; + } + + /** + * Sets use of the mock Geolocation client. Also resets that client. + */ + public void setUseMock() { + nativeSetUseMock(mWebViewCore); + } /** * Set the position for the mock Geolocation service. */ public void setPosition(double latitude, double longitude, double accuracy) { // This should only ever be called on the WebKit thread. - nativeSetPosition(latitude, longitude, accuracy); + nativeSetPosition(mWebViewCore, latitude, longitude, accuracy); } /** @@ -39,21 +47,23 @@ public final class MockGeolocation { */ public void setError(int code, String message) { // This should only ever be called on the WebKit thread. - nativeSetError(code, message); + nativeSetError(mWebViewCore, code, message); } - /** - * Get the global instance of MockGeolocation. - * @return The global MockGeolocation instance. - */ - public static MockGeolocation getInstance() { - if (sMockGeolocation == null) { - sMockGeolocation = new MockGeolocation(); - } - return sMockGeolocation; + public void setPermission(boolean allow) { + // This should only ever be called on the WebKit thread. + nativeSetPermission(mWebViewCore, allow); } // Native functions - private static native void nativeSetPosition(double latitude, double longitude, double accuracy); - private static native void nativeSetError(int code, String message); + private static native void nativeSetUseMock(WebViewCore webViewCore); + private static native void nativeSetPosition(WebViewCore webViewCore, + double latitude, + double longitude, + double accuracy); + private static native void nativeSetError(WebViewCore webViewCore, + int code, + String message); + private static native void nativeSetPermission(WebViewCore webViewCore, + boolean allow); } |
