Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1740)

Unified Diff: android_webview/java/src/org/chromium/android_webview/AwContents.java

Issue 12211047: Implementing geolocation for the Android Webview (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Minor style updates Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);
}

Powered by Google App Engine
This is Rietveld 408576698