Commit 56a6262f authored by Paul Miller's avatar Paul Miller Committed by Commit Bot

Enable StrictMode in WebView shell

BUG=655167

Change-Id: I2b18f52fae92993f1e37852924d8cbaf19872eaf
Reviewed-on: https://chromium-review.googlesource.com/1103395Reviewed-by: default avatarRichard Coles <torne@chromium.org>
Commit-Queue: Paul Miller <paulmiller@chromium.org>
Cr-Commit-Position: refs/heads/master@{#568115}
parent 696cec7b
......@@ -20,6 +20,7 @@ import android.graphics.Color;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.StrictMode;
import android.provider.Browser;
import android.util.SparseArray;
import android.view.Gravity;
......@@ -44,7 +45,9 @@ import android.widget.TextView;
import android.widget.Toast;
import org.chromium.base.Log;
import org.chromium.base.StrictModeContext;
import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
......@@ -188,6 +191,22 @@ public class WebViewBrowserActivity extends Activity implements PopupMenu.OnMenu
}
});
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
.detectAll()
.penaltyLog()
.penaltyDeath()
.build());
// Conspicuously omitted: detectCleartextNetwork() and detectFileUriExposure() to permit
// http:// and file:// origins.
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
.detectActivityLeaks()
.detectLeakedClosableObjects()
.detectLeakedRegistrationObjects()
.detectLeakedSqlLiteObjects()
.penaltyLog()
.penaltyDeath()
.build());
createAndInitializeWebView();
String url = getUrlFromIntent(getIntent());
......@@ -468,11 +487,18 @@ public class WebViewBrowserActivity extends Activity implements PopupMenu.OnMenu
// but we still use it because we support api level 19 and up.
@SuppressWarnings("deprecation")
private void initializeSettings(WebSettings settings) {
File appcache = null;
File geolocation = null;
try (StrictModeContext ctx = StrictModeContext.allowDiskWrites()) {
appcache = getDir("appcache", 0);
geolocation = getDir("geolocation", 0);
}
settings.setJavaScriptEnabled(true);
// configure local storage apis and their database paths.
settings.setAppCachePath(getDir("appcache", 0).getPath());
settings.setGeolocationDatabasePath(getDir("geolocation", 0).getPath());
settings.setAppCachePath(appcache.getPath());
settings.setGeolocationDatabasePath(geolocation.getPath());
settings.setAppCacheEnabled(true);
settings.setGeolocationEnabled(true);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment