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 6dc7ccb52dd169f73793cc15e6d11d35a6940f9f..d77cf9d1b27efcf77fd5c7860a3e8b906fd5e9cc 100644 |
--- a/android_webview/java/src/org/chromium/android_webview/AwContents.java |
+++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java |
@@ -858,33 +858,52 @@ 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 AwGeolocationCallback implements GeolocationPermissions.Callback { |
+ private final AwGeolocationPermissions mGeolocationPermissions; |
+ |
+ private AwGeolocationCallback(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()) { |
+ nativeInvokeGeolocationCallback(mNativeAwContents, false, origin); |
+ return; |
+ } |
+ // Allow if the origin has a retained allow |
+ if (permissions.hasOrigin(origin)) { |
+ nativeInvokeGeolocationCallback(mNativeAwContents, permissions.isOriginAllowed(origin), |
+ origin); |
+ return; |
+ } |
+ mContentsClient.onGeolocationPermissionsShowPrompt( |
+ origin, new AwGeolocationCallback(permissions)); |
+ } |
+ |
+ @CalledByNative |
+ private void onGeolocationPermissionsHidePrompt() { |
+ mContentsClient.onGeolocationPermissionsHidePrompt(); |
} |
@CalledByNative |
@@ -1080,4 +1099,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); |
} |