summaryrefslogtreecommitdiffstats
path: root/core/java/android/webkit/MockGeolocation.java
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2012-05-22 06:15:07 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-05-22 06:15:07 -0700
commit7c22b1810cce5738f026eec801f4ec11a8df40f6 (patch)
tree82b359e2eeafa052a8ba785a625ba0ac0d35a057 /core/java/android/webkit/MockGeolocation.java
parent0c1e7d339c1ae707cae2acf42f2b5e83dfa9cf43 (diff)
parentf3f60d9328d8acfedf987a73631fc90c39bf5447 (diff)
downloadframeworks_base-7c22b1810cce5738f026eec801f4ec11a8df40f6.zip
frameworks_base-7c22b1810cce5738f026eec801f4ec11a8df40f6.tar.gz
frameworks_base-7c22b1810cce5738f026eec801f4ec11a8df40f6.tar.bz2
Merge "Switch Geolocation DRT methods to control client-based mock"
Diffstat (limited to 'core/java/android/webkit/MockGeolocation.java')
-rw-r--r--core/java/android/webkit/MockGeolocation.java44
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);
}