| | |
| | | |
| | | public class WriteHandlingWebViewClient extends WebViewClient { |
| | | |
| | | private static final String TAG = "WriteHandlingWebViewClient"; |
| | | private final String MARKER = "AJAXINTERCEPT"; |
| | | |
| | | /** |
| | |
| | | OkHttpClient client = new OkHttpClient(); |
| | | try { |
| | | String url = request.getUrl().toString(); |
| | | Log.i(TAG,"url:"+url); |
| | | // if (!Pattern.matches(regex, url)) { |
| | | // return super.shouldInterceptRequest(view, request); |
| | | // } |
| | |
| | | String mime = response.getMimeType(); |
| | | |
| | | // WebResourceResponse的mime必须为"text/html",不能是"text/html; charset=utf-8" |
| | | if (mime.contains("text/html")) { |
| | | if (mime != null && mime.contains("text/html")) { |
| | | mime = "text/html"; |
| | | } |
| | | |
| | |
| | | private InputStream injectInterceptToStream(Context context, InputStream is, String mime, String charset) { |
| | | try { |
| | | byte[] pageContents = Utils.consumeInputStream(is); |
| | | if (mime.contains("text/html")) { |
| | | if (mime != null && mime.contains("text/html")) { |
| | | pageContents = AjaxInterceptJavascriptInterface |
| | | .enableIntercept(context, pageContents) |
| | | .getBytes(charset); |