Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.android_webview; | 5 package org.chromium.android_webview; |
| 6 | 6 |
| 7 import android.content.res.Configuration; | 7 import android.content.res.Configuration; |
| 8 import android.graphics.Bitmap; | 8 import android.graphics.Bitmap; |
| 9 import android.graphics.Canvas; | 9 import android.graphics.Canvas; |
| 10 import android.graphics.Color; | 10 import android.graphics.Color; |
| (...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 855 String path, long size, ValueCallback<String> callback) { | 855 String path, long size, ValueCallback<String> callback) { |
| 856 if (callback == null) return; | 856 if (callback == null) return; |
| 857 callback.onReceiveValue(size < 0 ? null : path); | 857 callback.onReceiveValue(size < 0 ? null : path); |
| 858 } | 858 } |
| 859 | 859 |
| 860 @CalledByNative | 860 @CalledByNative |
| 861 private void onReceivedHttpAuthRequest(AwHttpAuthHandler handler, String hos t, String realm) { | 861 private void onReceivedHttpAuthRequest(AwHttpAuthHandler handler, String hos t, String realm) { |
| 862 mContentsClient.onReceivedHttpAuthRequest(handler, host, realm); | 862 mContentsClient.onReceivedHttpAuthRequest(handler, host, realm); |
| 863 } | 863 } |
| 864 | 864 |
| 865 private static class ChromiumGeolocationCallback implements GeolocationPermi ssions.Callback { | 865 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.
| |
| 866 final int mRenderProcessId; | 866 private final AwGeolocationPermissions mGeolocationPermissions; |
| 867 final int mRenderViewId; | |
| 868 final int mBridgeId; | |
| 869 final String mRequestingFrame; | |
| 870 | 867 |
| 871 private ChromiumGeolocationCallback(int renderProcessId, int renderViewI d, int bridgeId, | 868 private ChromiumGeolocationCallback(AwGeolocationPermissions geolocation Permissions) { |
| 872 String requestingFrame) { | 869 mGeolocationPermissions = geolocationPermissions; |
| 873 mRenderProcessId = renderProcessId; | |
| 874 mRenderViewId = renderViewId; | |
| 875 mBridgeId = bridgeId; | |
| 876 mRequestingFrame = requestingFrame; | |
| 877 } | 870 } |
| 878 | 871 |
| 879 @Override | 872 @Override |
| 880 public void invoke(String origin, boolean allow, boolean retain) { | 873 public void invoke(final String origin, final boolean allow, final boole an retain) { |
| 881 // TODO(kristianm): Implement callback handling | 874 ThreadUtils.runOnUiThread(new Runnable() { |
| 875 @Override | |
| 876 public void run() { | |
| 877 if (retain) { | |
| 878 if (allow) { | |
| 879 mGeolocationPermissions.allow(origin); | |
| 880 } else { | |
| 881 mGeolocationPermissions.deny(origin); | |
| 882 } | |
| 883 } | |
| 884 nativeInvokeGeolocationCallback(mNativeAwContents, allow, or igin); | |
| 885 } | |
| 886 }); | |
| 882 } | 887 } |
| 883 } | 888 } |
| 884 | 889 |
| 885 @CalledByNative | 890 @CalledByNative |
| 886 private void onGeolocationPermissionsShowPrompt(int renderProcessId, int ren derViewId, | 891 private void onGeolocationPermissionsShowPrompt(String origin) { |
| 887 int bridgeId, String requestingFrame) { | 892 AwGeolocationPermissions permissions = AwGeolocationPermissions.getInsta nce(); |
| 888 // TODO(kristianm): Check with GeolocationPermissions if origin already has a policy set | 893 // Reject if geoloaction is disabled, or the origin has a retained deny |
| 889 mContentsClient.onGeolocationPermissionsShowPrompt(GURLUtils.getOrigin(r equestingFrame), | 894 if (!mSettings.getGeolocationEnabled() || permissions.getDenied(origin)) { |
| 890 new ChromiumGeolocationCallback(renderProcessId, renderViewId, b ridgeId, | 895 nativeInvokeGeolocationCallback(mNativeAwContents, false, origin); |
| 891 requestingFrame)); | 896 return; |
| 897 } | |
| 898 // Allow if the origin has a retained allow | |
| 899 if (permissions.getAllowed(origin)) { | |
| 900 nativeInvokeGeolocationCallback(mNativeAwContents, true, origin); | |
| 901 return; | |
| 902 } | |
| 903 mContentsClient.onGeolocationPermissionsShowPrompt( | |
| 904 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
| |
| 892 } | 905 } |
| 893 | 906 |
| 894 @CalledByNative | 907 @CalledByNative |
| 908 private void onGeolocationPermissionsHidePrompt() { | |
| 909 mContentsClient.onGeolocationPermissionsHidePrompt(); | |
| 910 } | |
| 911 | |
| 912 @CalledByNative | |
| 895 public void onFindResultReceived(int activeMatchOrdinal, int numberOfMatches , | 913 public void onFindResultReceived(int activeMatchOrdinal, int numberOfMatches , |
| 896 boolean isDoneCounting) { | 914 boolean isDoneCounting) { |
| 897 mContentsClient.onFindResultReceived(activeMatchOrdinal, numberOfMatches , isDoneCounting); | 915 mContentsClient.onFindResultReceived(activeMatchOrdinal, numberOfMatches , isDoneCounting); |
| 898 } | 916 } |
| 899 | 917 |
| 900 @CalledByNative | 918 @CalledByNative |
| 901 public void onNewPicture(Picture picture) { | 919 public void onNewPicture(Picture picture) { |
| 902 mContentsClient.onNewPicture(picture); | 920 mContentsClient.onNewPicture(picture); |
| 903 } | 921 } |
| 904 | 922 |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1077 // Returns false if restore state fails. | 1095 // Returns false if restore state fails. |
| 1078 private native boolean nativeRestoreFromOpaqueState(int nativeAwContents, by te[] state); | 1096 private native boolean nativeRestoreFromOpaqueState(int nativeAwContents, by te[] state); |
| 1079 | 1097 |
| 1080 private native int nativeReleasePopupWebContents(int nativeAwContents); | 1098 private native int nativeReleasePopupWebContents(int nativeAwContents); |
| 1081 private native void nativeSetWebContents(int nativeAwContents, int nativeNew WebContents); | 1099 private native void nativeSetWebContents(int nativeAwContents, int nativeNew WebContents); |
| 1082 private native void nativeFocusFirstNode(int nativeAwContents); | 1100 private native void nativeFocusFirstNode(int nativeAwContents); |
| 1083 | 1101 |
| 1084 private native Picture nativeCapturePicture(int nativeAwContents); | 1102 private native Picture nativeCapturePicture(int nativeAwContents); |
| 1085 private native void nativeEnableOnNewPicture(int nativeAwContents, boolean e nabled, | 1103 private native void nativeEnableOnNewPicture(int nativeAwContents, boolean e nabled, |
| 1086 boolean invalidationOnly); | 1104 boolean invalidationOnly); |
| 1105 | |
| 1106 private native void nativeInvokeGeolocationCallback( | |
| 1107 int nativeAwContents, boolean value, String requestingFrame); | |
| 1087 } | 1108 } |
| OLD | NEW |