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 840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
851 String path, long size, ValueCallback<String> callback) { | 851 String path, long size, ValueCallback<String> callback) { |
852 if (callback == null) return; | 852 if (callback == null) return; |
853 callback.onReceiveValue(size < 0 ? null : path); | 853 callback.onReceiveValue(size < 0 ? null : path); |
854 } | 854 } |
855 | 855 |
856 @CalledByNative | 856 @CalledByNative |
857 private void onReceivedHttpAuthRequest(AwHttpAuthHandler handler, String hos
t, String realm) { | 857 private void onReceivedHttpAuthRequest(AwHttpAuthHandler handler, String hos
t, String realm) { |
858 mContentsClient.onReceivedHttpAuthRequest(handler, host, realm); | 858 mContentsClient.onReceivedHttpAuthRequest(handler, host, realm); |
859 } | 859 } |
860 | 860 |
861 private static class ChromiumGeolocationCallback implements GeolocationPermi
ssions.Callback { | 861 private class AwGeolocationCallback implements GeolocationPermissions.Callba
ck { |
862 final int mRenderProcessId; | 862 private final AwGeolocationPermissions mGeolocationPermissions; |
863 final int mRenderViewId; | |
864 final int mBridgeId; | |
865 final String mRequestingFrame; | |
866 | 863 |
867 private ChromiumGeolocationCallback(int renderProcessId, int renderViewI
d, int bridgeId, | 864 private AwGeolocationCallback(AwGeolocationPermissions geolocationPermis
sions) { |
868 String requestingFrame) { | 865 mGeolocationPermissions = geolocationPermissions; |
869 mRenderProcessId = renderProcessId; | |
870 mRenderViewId = renderViewId; | |
871 mBridgeId = bridgeId; | |
872 mRequestingFrame = requestingFrame; | |
873 } | 866 } |
874 | 867 |
875 @Override | 868 @Override |
876 public void invoke(String origin, boolean allow, boolean retain) { | 869 public void invoke(final String origin, final boolean allow, final boole
an retain) { |
877 // TODO(kristianm): Implement callback handling | 870 ThreadUtils.runOnUiThread(new Runnable() { |
| 871 @Override |
| 872 public void run() { |
| 873 if (retain) { |
| 874 if (allow) { |
| 875 mGeolocationPermissions.allow(origin); |
| 876 } else { |
| 877 mGeolocationPermissions.deny(origin); |
| 878 } |
| 879 } |
| 880 nativeInvokeGeolocationCallback(mNativeAwContents, allow, or
igin); |
| 881 } |
| 882 }); |
878 } | 883 } |
879 } | 884 } |
880 | 885 |
881 @CalledByNative | 886 @CalledByNative |
882 private void onGeolocationPermissionsShowPrompt(int renderProcessId, int ren
derViewId, | 887 private void onGeolocationPermissionsShowPrompt(String origin) { |
883 int bridgeId, String requestingFrame) { | 888 AwGeolocationPermissions permissions = AwGeolocationPermissions.getInsta
nce(); |
884 // TODO(kristianm): Check with GeolocationPermissions if origin already
has a policy set | 889 // Reject if geoloaction is disabled, or the origin has a retained deny |
885 mContentsClient.onGeolocationPermissionsShowPrompt(GURLUtils.getOrigin(r
equestingFrame), | 890 if (!mSettings.getGeolocationEnabled()) { |
886 new ChromiumGeolocationCallback(renderProcessId, renderViewId, b
ridgeId, | 891 nativeInvokeGeolocationCallback(mNativeAwContents, false, origin); |
887 requestingFrame)); | 892 return; |
| 893 } |
| 894 // Allow if the origin has a retained allow |
| 895 if (permissions.hasOrigin(origin)) { |
| 896 nativeInvokeGeolocationCallback(mNativeAwContents, permissions.isOri
ginAllowed(origin), |
| 897 origin); |
| 898 return; |
| 899 } |
| 900 mContentsClient.onGeolocationPermissionsShowPrompt( |
| 901 origin, new AwGeolocationCallback(permissions)); |
888 } | 902 } |
889 | 903 |
890 @CalledByNative | 904 @CalledByNative |
| 905 private void onGeolocationPermissionsHidePrompt() { |
| 906 mContentsClient.onGeolocationPermissionsHidePrompt(); |
| 907 } |
| 908 |
| 909 @CalledByNative |
891 public void onFindResultReceived(int activeMatchOrdinal, int numberOfMatches
, | 910 public void onFindResultReceived(int activeMatchOrdinal, int numberOfMatches
, |
892 boolean isDoneCounting) { | 911 boolean isDoneCounting) { |
893 mContentsClient.onFindResultReceived(activeMatchOrdinal, numberOfMatches
, isDoneCounting); | 912 mContentsClient.onFindResultReceived(activeMatchOrdinal, numberOfMatches
, isDoneCounting); |
894 } | 913 } |
895 | 914 |
896 @CalledByNative | 915 @CalledByNative |
897 public void onNewPicture(Picture picture) { | 916 public void onNewPicture(Picture picture) { |
898 mContentsClient.onNewPicture(picture); | 917 mContentsClient.onNewPicture(picture); |
899 } | 918 } |
900 | 919 |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1073 // Returns false if restore state fails. | 1092 // Returns false if restore state fails. |
1074 private native boolean nativeRestoreFromOpaqueState(int nativeAwContents, by
te[] state); | 1093 private native boolean nativeRestoreFromOpaqueState(int nativeAwContents, by
te[] state); |
1075 | 1094 |
1076 private native int nativeReleasePopupWebContents(int nativeAwContents); | 1095 private native int nativeReleasePopupWebContents(int nativeAwContents); |
1077 private native void nativeSetWebContents(int nativeAwContents, int nativeNew
WebContents); | 1096 private native void nativeSetWebContents(int nativeAwContents, int nativeNew
WebContents); |
1078 private native void nativeFocusFirstNode(int nativeAwContents); | 1097 private native void nativeFocusFirstNode(int nativeAwContents); |
1079 | 1098 |
1080 private native Picture nativeCapturePicture(int nativeAwContents); | 1099 private native Picture nativeCapturePicture(int nativeAwContents); |
1081 private native void nativeEnableOnNewPicture(int nativeAwContents, boolean e
nabled, | 1100 private native void nativeEnableOnNewPicture(int nativeAwContents, boolean e
nabled, |
1082 boolean invalidationOnly); | 1101 boolean invalidationOnly); |
| 1102 |
| 1103 private native void nativeInvokeGeolocationCallback( |
| 1104 int nativeAwContents, boolean value, String requestingFrame); |
1083 } | 1105 } |
OLD | NEW |