Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions framework/src/org/apache/cordova/engine/SystemWebChromeClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ Licensed to the Apache Software Foundation (ASF) under one
import android.webkit.JsResult;
import android.webkit.ValueCallback;
import android.webkit.WebChromeClient;
import android.webkit.WebStorage;
import android.webkit.WebView;
import android.webkit.PermissionRequest;
import android.widget.LinearLayout;
Expand Down Expand Up @@ -150,19 +149,6 @@ public boolean onJsPrompt(WebView view, String origin, String message, String de
return true;
}

/**
* Handle database quota exceeded notification.
*/
@Override
@SuppressWarnings("deprecation")
public void onExceededDatabaseQuota(String url, String databaseIdentifier, long currentQuota, long estimatedSize,
long totalUsedQuota, WebStorage.QuotaUpdater quotaUpdater)
{
LOG.d(LOG_TAG, "onExceededDatabaseQuota estimatedSize: %d currentQuota: %d totalUsedQuota: %d", estimatedSize, currentQuota, totalUsedQuota);
long MAX_QUOTA = 100 * 1024 * 1024;
quotaUpdater.updateQuota(MAX_QUOTA);
}

/**
* Instructs the client to show a prompt to ask the user to set the Geolocation permission state for the specified origin.
*
Expand Down
77 changes: 13 additions & 64 deletions framework/src/org/apache/cordova/engine/SystemWebViewClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ Licensed to the Apache Software Foundation (ASF) under one
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.AssetManager;
import android.graphics.Bitmap;
import android.net.Uri;
import android.net.http.SslError;
import android.webkit.ClientCertRequest;
import android.webkit.HttpAuthHandler;
Expand All @@ -32,6 +31,7 @@ Licensed to the Apache Software Foundation (ASF) under one
import android.webkit.ServiceWorkerClient;
import android.webkit.ServiceWorkerController;
import android.webkit.SslErrorHandler;
import android.webkit.WebResourceError;
import android.webkit.WebResourceRequest;
import android.webkit.WebResourceResponse;
import android.webkit.WebView;
Expand All @@ -41,12 +41,9 @@ Licensed to the Apache Software Foundation (ASF) under one
import org.apache.cordova.CordovaClientCertRequest;
import org.apache.cordova.CordovaHttpAuthHandler;
import org.apache.cordova.CordovaPluginPathHandler;
import org.apache.cordova.CordovaResourceApi;
import org.apache.cordova.LOG;
import org.apache.cordova.PluginManager;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Hashtable;

Expand Down Expand Up @@ -137,13 +134,12 @@ public WebResourceResponse shouldInterceptRequest(WebResourceRequest request) {
* is about to be loaded in the current WebView.
*
* @param view The WebView that is initiating the callback.
* @param url The url to be loaded.
* @param request The request to be loaded.
* @return true to override, false for default behavior
*/
@Override
@SuppressWarnings("deprecation")
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return parentEngine.client.onNavigationAttempt(url);
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
return parentEngine.client.onNavigationAttempt(request.getUrl().toString());
}

/**
Expand Down Expand Up @@ -247,13 +243,16 @@ public void onPageFinished(WebView view, String url) {
* The errorCode parameter corresponds to one of the ERROR_* constants.
*
* @param view The WebView that is initiating the callback.
* @param errorCode The error code corresponding to an ERROR_* value.
* @param description A String describing the error.
* @param failingUrl The url that failed to load.
* @param request The request that caused the error.
* @param error The error object.
*/
@Override
@SuppressWarnings("deprecation")
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
public void onReceivedError(WebView view,
WebResourceRequest request,
WebResourceError error) {
int errorCode = error.getErrorCode();
String description = error.getDescription().toString();
String failingUrl = request.getUrl().toString();
// Ignore error due to stopLoading().
if (!isCurrentlyLoading) {
return;
Expand All @@ -270,7 +269,7 @@ public void onReceivedError(WebView view, int errorCode, String description, Str
view.goBack();
return;
} else {
super.onReceivedError(view, errorCode, description, failingUrl);
super.onReceivedError(view, request, error);
}
}
parentEngine.client.onReceivedError(errorCode, description, failingUrl);
Expand Down Expand Up @@ -382,56 +381,6 @@ public void clearAuthenticationTokens() {
this.authenticationTokens.clear();
}

@Override
@SuppressWarnings("deprecation")
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
try {
// Check the against the allow list and lock out access to the WebView directory
// Changing this will cause problems for your application
if (!parentEngine.pluginManager.shouldAllowRequest(url)) {
LOG.w(TAG, "URL blocked by allow list: " + url);
// Results in a 404.
return new WebResourceResponse("text/plain", "UTF-8", null);
}

CordovaResourceApi resourceApi = parentEngine.resourceApi;
Uri origUri = Uri.parse(url);
// Allow plugins to intercept WebView requests.
Uri remappedUri = resourceApi.remapUri(origUri);

if (!origUri.equals(remappedUri) || needsSpecialsInAssetUrlFix(origUri) || needsContentUrlFix(origUri)) {
CordovaResourceApi.OpenForReadResult result = resourceApi.openForRead(remappedUri, true);
return new WebResourceResponse(result.mimeType, "UTF-8", result.inputStream);
}
// If we don't need to special-case the request, let the browser load it.
return null;
} catch (IOException e) {
if (!(e instanceof FileNotFoundException)) {
LOG.e(TAG, "Error occurred while loading a file (returning a 404).", e);
}
// Results in a 404.
return new WebResourceResponse("text/plain", "UTF-8", null);
}
}

private static boolean needsContentUrlFix(Uri uri) {
return "content".equals(uri.getScheme());
}

private static boolean needsSpecialsInAssetUrlFix(Uri uri) {
if (CordovaResourceApi.getUriType(uri) != CordovaResourceApi.URI_TYPE_ASSET) {
return false;
}
if (uri.getQuery() != null || uri.getFragment() != null) {
return true;
}

if (!uri.toString().contains("%")) {
return false;
}

return false;
}

@Override
public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@ Licensed to the Apache Software Foundation (ASF) under one
package org.apache.cordova.engine;

import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ApplicationInfo;
import android.os.Build;
import android.view.View;
import android.webkit.ValueCallback;
import android.webkit.WebSettings;
Expand All @@ -44,9 +42,6 @@ Licensed to the Apache Software Foundation (ASF) under one
import org.apache.cordova.NativeToJsMessageQueue;
import org.apache.cordova.PluginManager;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;


/**
* Glue class between CordovaWebView (main Cordova logic) and SystemWebView (the actual View).
Expand Down Expand Up @@ -142,7 +137,6 @@ public View getView() {
}

@SuppressLint({"NewApi", "SetJavaScriptEnabled"})
@SuppressWarnings("deprecation")
private void initWebViewSettings() {
webView.setInitialScale(0);
webView.setVerticalScrollBarEnabled(false);
Expand Down Expand Up @@ -192,9 +186,6 @@ else if ("true".equals(inspectableWebview)) {
enableRemoteDebugging();
}

// @todo remove when Cordova drop API level 24 support
settings.setGeolocationDatabasePath(databasePath);

// Enable DOM storage
settings.setDomStorageEnabled(true);

Expand Down
Loading