| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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.annotation.SuppressLint; | 7 import android.annotation.SuppressLint; |
| 8 import android.app.Activity; | 8 import android.app.Activity; |
| 9 import android.content.ComponentCallbacks2; | 9 import android.content.ComponentCallbacks2; |
| 10 import android.content.Context; | 10 import android.content.Context; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 import android.view.KeyEvent; | 30 import android.view.KeyEvent; |
| 31 import android.view.MotionEvent; | 31 import android.view.MotionEvent; |
| 32 import android.view.View; | 32 import android.view.View; |
| 33 import android.view.ViewGroup; | 33 import android.view.ViewGroup; |
| 34 import android.view.accessibility.AccessibilityEvent; | 34 import android.view.accessibility.AccessibilityEvent; |
| 35 import android.view.accessibility.AccessibilityNodeInfo; | 35 import android.view.accessibility.AccessibilityNodeInfo; |
| 36 import android.view.accessibility.AccessibilityNodeProvider; | 36 import android.view.accessibility.AccessibilityNodeProvider; |
| 37 import android.view.animation.AnimationUtils; | 37 import android.view.animation.AnimationUtils; |
| 38 import android.view.inputmethod.EditorInfo; | 38 import android.view.inputmethod.EditorInfo; |
| 39 import android.view.inputmethod.InputConnection; | 39 import android.view.inputmethod.InputConnection; |
| 40 import android.webkit.GeolocationPermissions; | |
| 41 import android.webkit.JavascriptInterface; | 40 import android.webkit.JavascriptInterface; |
| 42 import android.webkit.ValueCallback; | 41 import android.webkit.ValueCallback; |
| 43 import android.widget.OverScroller; | 42 import android.widget.OverScroller; |
| 44 | 43 |
| 44 import org.chromium.android_webview.permission.AwGeolocationCallback; |
| 45 import org.chromium.android_webview.permission.AwPermissionRequest; | 45 import org.chromium.android_webview.permission.AwPermissionRequest; |
| 46 import org.chromium.base.CalledByNative; | 46 import org.chromium.base.CalledByNative; |
| 47 import org.chromium.base.JNINamespace; | 47 import org.chromium.base.JNINamespace; |
| 48 import org.chromium.base.ThreadUtils; | 48 import org.chromium.base.ThreadUtils; |
| 49 import org.chromium.base.TraceEvent; | 49 import org.chromium.base.TraceEvent; |
| 50 import org.chromium.base.VisibleForTesting; | 50 import org.chromium.base.VisibleForTesting; |
| 51 import org.chromium.base.annotations.SuppressFBWarnings; | 51 import org.chromium.base.annotations.SuppressFBWarnings; |
| 52 import org.chromium.components.navigation_interception.InterceptNavigationDelega
te; | 52 import org.chromium.components.navigation_interception.InterceptNavigationDelega
te; |
| 53 import org.chromium.components.navigation_interception.NavigationParams; | 53 import org.chromium.components.navigation_interception.NavigationParams; |
| 54 import org.chromium.content.browser.ContentViewClient; | 54 import org.chromium.content.browser.ContentViewClient; |
| (...skipping 2348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2403 String path, long size, ValueCallback<String> callback) { | 2403 String path, long size, ValueCallback<String> callback) { |
| 2404 if (callback == null) return; | 2404 if (callback == null) return; |
| 2405 callback.onReceiveValue(size < 0 ? null : path); | 2405 callback.onReceiveValue(size < 0 ? null : path); |
| 2406 } | 2406 } |
| 2407 | 2407 |
| 2408 @CalledByNative | 2408 @CalledByNative |
| 2409 private void onReceivedHttpAuthRequest(AwHttpAuthHandler handler, String hos
t, String realm) { | 2409 private void onReceivedHttpAuthRequest(AwHttpAuthHandler handler, String hos
t, String realm) { |
| 2410 mContentsClient.onReceivedHttpAuthRequest(handler, host, realm); | 2410 mContentsClient.onReceivedHttpAuthRequest(handler, host, realm); |
| 2411 } | 2411 } |
| 2412 | 2412 |
| 2413 private class AwGeolocationCallback implements GeolocationPermissions.Callba
ck { | 2413 public AwGeolocationPermissions getGeolocationPermissions() { |
| 2414 return mBrowserContext.getGeolocationPermissions(); |
| 2415 } |
| 2414 | 2416 |
| 2415 @Override | 2417 public void invokeGeolocationCallback(boolean value, String requestingFrame)
{ |
| 2416 public void invoke(final String origin, final boolean allow, final boole
an retain) { | 2418 if (isDestroyed()) return; |
| 2417 ThreadUtils.runOnUiThread(new Runnable() { | 2419 nativeInvokeGeolocationCallback(mNativeAwContents, value, requestingFram
e); |
| 2418 @Override | |
| 2419 public void run() { | |
| 2420 if (retain) { | |
| 2421 if (allow) { | |
| 2422 mBrowserContext.getGeolocationPermissions().allow(or
igin); | |
| 2423 } else { | |
| 2424 mBrowserContext.getGeolocationPermissions().deny(ori
gin); | |
| 2425 } | |
| 2426 } | |
| 2427 if (isDestroyed()) return; | |
| 2428 nativeInvokeGeolocationCallback(mNativeAwContents, allow, or
igin); | |
| 2429 } | |
| 2430 }); | |
| 2431 } | |
| 2432 } | 2420 } |
| 2433 | 2421 |
| 2434 @CalledByNative | 2422 @CalledByNative |
| 2435 private void onGeolocationPermissionsShowPrompt(String origin) { | 2423 private void onGeolocationPermissionsShowPrompt(String origin) { |
| 2436 if (isDestroyed()) return; | 2424 if (isDestroyed()) return; |
| 2437 AwGeolocationPermissions permissions = mBrowserContext.getGeolocationPer
missions(); | 2425 AwGeolocationPermissions permissions = mBrowserContext.getGeolocationPer
missions(); |
| 2438 // Reject if geoloaction is disabled, or the origin has a retained deny | 2426 // Reject if geoloaction is disabled, or the origin has a retained deny |
| 2439 if (!mSettings.getGeolocationEnabled()) { | 2427 if (!mSettings.getGeolocationEnabled()) { |
| 2440 nativeInvokeGeolocationCallback(mNativeAwContents, false, origin); | 2428 nativeInvokeGeolocationCallback(mNativeAwContents, false, origin); |
| 2441 return; | 2429 return; |
| 2442 } | 2430 } |
| 2443 // Allow if the origin has a retained allow | 2431 // Allow if the origin has a retained allow |
| 2444 if (permissions.hasOrigin(origin)) { | 2432 if (permissions.hasOrigin(origin)) { |
| 2445 nativeInvokeGeolocationCallback(mNativeAwContents, permissions.isOri
ginAllowed(origin), | 2433 nativeInvokeGeolocationCallback(mNativeAwContents, permissions.isOri
ginAllowed(origin), |
| 2446 origin); | 2434 origin); |
| 2447 return; | 2435 return; |
| 2448 } | 2436 } |
| 2449 mContentsClient.onGeolocationPermissionsShowPrompt( | 2437 mContentsClient.onGeolocationPermissionsShowPrompt( |
| 2450 origin, new AwGeolocationCallback()); | 2438 origin, new AwGeolocationCallback(origin, this)); |
| 2451 } | 2439 } |
| 2452 | 2440 |
| 2453 @CalledByNative | 2441 @CalledByNative |
| 2454 private void onGeolocationPermissionsHidePrompt() { | 2442 private void onGeolocationPermissionsHidePrompt() { |
| 2455 mContentsClient.onGeolocationPermissionsHidePrompt(); | 2443 mContentsClient.onGeolocationPermissionsHidePrompt(); |
| 2456 } | 2444 } |
| 2457 | 2445 |
| 2458 @CalledByNative | 2446 @CalledByNative |
| 2459 private void onPermissionRequest(AwPermissionRequest awPermissionRequest) { | 2447 private void onPermissionRequest(AwPermissionRequest awPermissionRequest) { |
| 2460 mContentsClient.onPermissionRequest(awPermissionRequest); | 2448 mContentsClient.onPermissionRequest(awPermissionRequest); |
| (...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3104 private native void nativeCreatePdfExporter(long nativeAwContents, AwPdfExpo
rter awPdfExporter); | 3092 private native void nativeCreatePdfExporter(long nativeAwContents, AwPdfExpo
rter awPdfExporter); |
| 3105 | 3093 |
| 3106 private native void nativePreauthorizePermission(long nativeAwContents, Stri
ng origin, | 3094 private native void nativePreauthorizePermission(long nativeAwContents, Stri
ng origin, |
| 3107 long resources); | 3095 long resources); |
| 3108 | 3096 |
| 3109 private native void nativePostMessageToFrame(long nativeAwContents, String f
rameId, | 3097 private native void nativePostMessageToFrame(long nativeAwContents, String f
rameId, |
| 3110 String message, String targetOrigin, int[] msgPorts); | 3098 String message, String targetOrigin, int[] msgPorts); |
| 3111 | 3099 |
| 3112 private native void nativeCreateMessageChannel(long nativeAwContents, AwMess
agePort[] ports); | 3100 private native void nativeCreateMessageChannel(long nativeAwContents, AwMess
agePort[] ports); |
| 3113 } | 3101 } |
| OLD | NEW |