diff options
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 fbda492..d8dc724 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); } |