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 AwGeolocationCallback implements GeolocationPermissions.Callba
ck { |
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 AwGeolocationCallback(AwGeolocationPermissions geolocationPermis
sions) { |
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()) { |
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.hasOrigin(origin)) { |
| 900 nativeInvokeGeolocationCallback(mNativeAwContents, permissions.isOri
ginAllowed(origin), |
| 901 origin); |
| 902 return; |
| 903 } |
| 904 mContentsClient.onGeolocationPermissionsShowPrompt( |
| 905 origin, new AwGeolocationCallback(permissions)); |
892 } | 906 } |
893 | 907 |
894 @CalledByNative | 908 @CalledByNative |
| 909 private void onGeolocationPermissionsHidePrompt() { |
| 910 mContentsClient.onGeolocationPermissionsHidePrompt(); |
| 911 } |
| 912 |
| 913 @CalledByNative |
895 public void onFindResultReceived(int activeMatchOrdinal, int numberOfMatches
, | 914 public void onFindResultReceived(int activeMatchOrdinal, int numberOfMatches
, |
896 boolean isDoneCounting) { | 915 boolean isDoneCounting) { |
897 mContentsClient.onFindResultReceived(activeMatchOrdinal, numberOfMatches
, isDoneCounting); | 916 mContentsClient.onFindResultReceived(activeMatchOrdinal, numberOfMatches
, isDoneCounting); |
898 } | 917 } |
899 | 918 |
900 @CalledByNative | 919 @CalledByNative |
901 public void onNewPicture(Picture picture) { | 920 public void onNewPicture(Picture picture) { |
902 mContentsClient.onNewPicture(picture); | 921 mContentsClient.onNewPicture(picture); |
903 } | 922 } |
904 | 923 |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1077 // Returns false if restore state fails. | 1096 // Returns false if restore state fails. |
1078 private native boolean nativeRestoreFromOpaqueState(int nativeAwContents, by
te[] state); | 1097 private native boolean nativeRestoreFromOpaqueState(int nativeAwContents, by
te[] state); |
1079 | 1098 |
1080 private native int nativeReleasePopupWebContents(int nativeAwContents); | 1099 private native int nativeReleasePopupWebContents(int nativeAwContents); |
1081 private native void nativeSetWebContents(int nativeAwContents, int nativeNew
WebContents); | 1100 private native void nativeSetWebContents(int nativeAwContents, int nativeNew
WebContents); |
1082 private native void nativeFocusFirstNode(int nativeAwContents); | 1101 private native void nativeFocusFirstNode(int nativeAwContents); |
1083 | 1102 |
1084 private native Picture nativeCapturePicture(int nativeAwContents); | 1103 private native Picture nativeCapturePicture(int nativeAwContents); |
1085 private native void nativeEnableOnNewPicture(int nativeAwContents, boolean e
nabled, | 1104 private native void nativeEnableOnNewPicture(int nativeAwContents, boolean e
nabled, |
1086 boolean invalidationOnly); | 1105 boolean invalidationOnly); |
| 1106 |
| 1107 private native void nativeInvokeGeolocationCallback( |
| 1108 int nativeAwContents, boolean value, String requestingFrame); |
1087 } | 1109 } |
OLD | NEW |