Index: android_webview/java/src/org/chromium/android_webview/AwContents.java |
diff --git a/android_webview/java/src/org/chromium/android_webview/AwContents.java b/android_webview/java/src/org/chromium/android_webview/AwContents.java |
index 9d98d6e65d273c63b059a93195212f448e0e05d8..ec22c4aede90089f4f9e2291d4983eee7c838cf8 100644 |
--- a/android_webview/java/src/org/chromium/android_webview/AwContents.java |
+++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java |
@@ -862,33 +862,51 @@ public class AwContents { |
mContentsClient.onReceivedHttpAuthRequest(handler, host, realm); |
} |
- private static class ChromiumGeolocationCallback implements GeolocationPermissions.Callback { |
- final int mRenderProcessId; |
- final int mRenderViewId; |
- final int mBridgeId; |
- final String mRequestingFrame; |
- |
- private ChromiumGeolocationCallback(int renderProcessId, int renderViewId, int bridgeId, |
- String requestingFrame) { |
- mRenderProcessId = renderProcessId; |
- mRenderViewId = renderViewId; |
- mBridgeId = bridgeId; |
- mRequestingFrame = requestingFrame; |
+ private class ChromiumGeolocationCallback implements GeolocationPermissions.Callback { |
boliu
2013/02/06 20:29:54
Might be better to call this AwGeolocationCallback
Kristian Monsen
2013/02/08 00:07:44
Done.
|
+ private final AwGeolocationPermissions mGeolocationPermissions; |
+ |
+ private ChromiumGeolocationCallback(AwGeolocationPermissions geolocationPermissions) { |
+ mGeolocationPermissions = geolocationPermissions; |
} |
@Override |
- public void invoke(String origin, boolean allow, boolean retain) { |
- // TODO(kristianm): Implement callback handling |
+ public void invoke(final String origin, final boolean allow, final boolean retain) { |
+ ThreadUtils.runOnUiThread(new Runnable() { |
+ @Override |
+ public void run() { |
+ if (retain) { |
+ if (allow) { |
+ mGeolocationPermissions.allow(origin); |
+ } else { |
+ mGeolocationPermissions.deny(origin); |
+ } |
+ } |
+ nativeInvokeGeolocationCallback(mNativeAwContents, allow, origin); |
+ } |
+ }); |
} |
} |
@CalledByNative |
- private void onGeolocationPermissionsShowPrompt(int renderProcessId, int renderViewId, |
- int bridgeId, String requestingFrame) { |
- // TODO(kristianm): Check with GeolocationPermissions if origin already has a policy set |
- mContentsClient.onGeolocationPermissionsShowPrompt(GURLUtils.getOrigin(requestingFrame), |
- new ChromiumGeolocationCallback(renderProcessId, renderViewId, bridgeId, |
- requestingFrame)); |
+ private void onGeolocationPermissionsShowPrompt(String origin) { |
+ AwGeolocationPermissions permissions = AwGeolocationPermissions.getInstance(); |
+ // Reject if geoloaction is disabled, or the origin has a retained deny |
+ if (!mSettings.getGeolocationEnabled() || permissions.getDenied(origin)) { |
+ nativeInvokeGeolocationCallback(mNativeAwContents, false, origin); |
+ return; |
+ } |
+ // Allow if the origin has a retained allow |
+ if (permissions.getAllowed(origin)) { |
+ nativeInvokeGeolocationCallback(mNativeAwContents, true, origin); |
+ return; |
+ } |
+ mContentsClient.onGeolocationPermissionsShowPrompt( |
+ origin, new ChromiumGeolocationCallback(permissions)); |
boliu
2013/02/06 20:29:54
Not sure if this is a big concern, but can we just
Kristian Monsen
2013/02/08 00:07:44
There can be many outstanding at a time if they ge
|
+ } |
+ |
+ @CalledByNative |
+ private void onGeolocationPermissionsHidePrompt() { |
+ mContentsClient.onGeolocationPermissionsHidePrompt(); |
} |
@CalledByNative |
@@ -1084,4 +1102,7 @@ public class AwContents { |
private native Picture nativeCapturePicture(int nativeAwContents); |
private native void nativeEnableOnNewPicture(int nativeAwContents, boolean enabled, |
boolean invalidationOnly); |
+ |
+ private native void nativeInvokeGeolocationCallback( |
+ int nativeAwContents, boolean value, String requestingFrame); |
} |