Java 类org.apache.cordova.CordovaResourceApi.OpenForReadResult 实例源码

项目:krakn    文件:ChromeI18n.java   
@Override
public Uri remapChromeUri(Uri uri) {
    Uri ret = Uri.parse(replacePatternsInLine(uri.toString()));
    if (ret.getPath().endsWith(".css") || uri.getPath().equals("manifest.json")) {
        Uri fileUri = Uri.parse("file:///android_asset/www" + uri.getPath());
        fileUri = webView.getResourceApi().remapUri(fileUri);
        try {
            OpenForReadResult readResult = webView.getResourceApi().openForRead(fileUri, true);
            try {
                byte[] newData = replaceI18nPlaceholders(readResult.inputStream);
                return Uri.parse("data:text/css;charset=utf-8;base64," + Base64.encode(newData));
            } finally {
                if (readResult != null) {
                    readResult.inputStream.close();
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    return ret;
}
项目:krakn    文件:ChromeStorage.java   
private JSONObject getStorage(String namespace) throws IOException, JSONException {
    JSONObject oldMap = new JSONObject();
    CordovaResourceApi resourceApi = webView.getResourceApi();
    try {
        OpenForReadResult readResult = resourceApi.openForRead(getStorageFile(namespace));
        ByteArrayOutputStream readBytes = new ByteArrayOutputStream((int)readResult.length);
        resourceApi.copyResource(readResult, readBytes);
        byte[] bytes = readBytes.toByteArray();
        String content = (new String(bytes)).trim();
        if (content.length() > 0) {
            oldMap = new JSONObject(content);
        }
    } catch (FileNotFoundException e) {
        //Suppress the file not found exception
    }
    return oldMap;
}
项目:krakn    文件:ChromeI18n.java   
@Override
public Uri remapChromeUri(Uri uri) {
    Uri ret = Uri.parse(replacePatternsInLine(uri.toString()));
    if (ret.getPath().endsWith(".css") || uri.getPath().equals("manifest.json")) {
        Uri fileUri = Uri.parse("file:///android_asset/www" + uri.getPath());
        fileUri = webView.getResourceApi().remapUri(fileUri);
        try {
            OpenForReadResult readResult = webView.getResourceApi().openForRead(fileUri, true);
            try {
                byte[] newData = replaceI18nPlaceholders(readResult.inputStream);
                return Uri.parse("data:text/css;charset=utf-8;base64," + Base64.encode(newData));
            } finally {
                if (readResult != null) {
                    readResult.inputStream.close();
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    return ret;
}
项目:krakn    文件:ChromeStorage.java   
private JSONObject getStorage(String namespace) throws IOException, JSONException {
    JSONObject oldMap = new JSONObject();
    CordovaResourceApi resourceApi = webView.getResourceApi();
    try {
        OpenForReadResult readResult = resourceApi.openForRead(getStorageFile(namespace));
        ByteArrayOutputStream readBytes = new ByteArrayOutputStream((int)readResult.length);
        resourceApi.copyResource(readResult, readBytes);
        byte[] bytes = readBytes.toByteArray();
        String content = (new String(bytes)).trim();
        if (content.length() > 0) {
            oldMap = new JSONObject(content);
        }
    } catch (FileNotFoundException e) {
        //Suppress the file not found exception
    }
    return oldMap;
}
项目:krakn    文件:ChromeI18n.java   
@Override
public Uri remapChromeUri(Uri uri) {
    Uri ret = Uri.parse(replacePatternsInLine(uri.toString()));
    if (ret.getPath().endsWith(".css") || uri.getPath().equals("manifest.json")) {
        Uri fileUri = Uri.parse("file:///android_asset/www" + uri.getPath());
        fileUri = webView.getResourceApi().remapUri(fileUri);
        try {
            OpenForReadResult readResult = webView.getResourceApi().openForRead(fileUri, true);
            try {
                byte[] newData = replaceI18nPlaceholders(readResult.inputStream);
                return Uri.parse("data:text/css;charset=utf-8;base64," + Base64.encode(newData));
            } finally {
                if (readResult != null) {
                    readResult.inputStream.close();
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    return ret;
}
项目:krakn    文件:ChromeStorage.java   
private JSONObject getStorage(String namespace) throws IOException, JSONException {
    JSONObject oldMap = new JSONObject();
    CordovaResourceApi resourceApi = webView.getResourceApi();
    try {
        OpenForReadResult readResult = resourceApi.openForRead(getStorageFile(namespace));
        ByteArrayOutputStream readBytes = new ByteArrayOutputStream((int)readResult.length);
        resourceApi.copyResource(readResult, readBytes);
        byte[] bytes = readBytes.toByteArray();
        String content = (new String(bytes)).trim();
        if (content.length() > 0) {
            oldMap = new JSONObject(content);
        }
    } catch (FileNotFoundException e) {
        //Suppress the file not found exception
    }
    return oldMap;
}
项目:krakn    文件:ChromeI18n.java   
@Override
public Uri remapChromeUri(Uri uri) {
    Uri ret = Uri.parse(replacePatternsInLine(uri.toString()));
    if (ret.getPath().endsWith(".css") || uri.getPath().equals("manifest.json")) {
        Uri fileUri = Uri.parse("file:///android_asset/www" + uri.getPath());
        fileUri = webView.getResourceApi().remapUri(fileUri);
        try {
            OpenForReadResult readResult = webView.getResourceApi().openForRead(fileUri, true);
            try {
                byte[] newData = replaceI18nPlaceholders(readResult.inputStream);
                return Uri.parse("data:text/css;charset=utf-8;base64," + Base64.encode(newData));
            } finally {
                if (readResult != null) {
                    readResult.inputStream.close();
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    return ret;
}
项目:krakn    文件:ChromeStorage.java   
private JSONObject getStorage(String namespace) throws IOException, JSONException {
    JSONObject oldMap = new JSONObject();
    CordovaResourceApi resourceApi = webView.getResourceApi();
    try {
        OpenForReadResult readResult = resourceApi.openForRead(getStorageFile(namespace));
        ByteArrayOutputStream readBytes = new ByteArrayOutputStream((int)readResult.length);
        resourceApi.copyResource(readResult, readBytes);
        byte[] bytes = readBytes.toByteArray();
        String content = (new String(bytes)).trim();
        if (content.length() > 0) {
            oldMap = new JSONObject(content);
        }
    } catch (FileNotFoundException e) {
        //Suppress the file not found exception
    }
    return oldMap;
}
项目:MarkTimeJS    文件:ChromeStorage.java   
private JSONObject getStorage(String namespace) throws IOException, JSONException {
    JSONObject oldMap = new JSONObject();
    CordovaResourceApi resourceApi = webView.getResourceApi();
    try {
        OpenForReadResult readResult = resourceApi.openForRead(getStorageFile(namespace));
        ByteArrayOutputStream readBytes = new ByteArrayOutputStream((int)readResult.length);
        resourceApi.copyResource(readResult, readBytes);
        byte[] bytes = readBytes.toByteArray();
        String content = (new String(bytes)).trim();
        if (content.length() > 0) {
            oldMap = new JSONObject(content);
        }
    } catch (FileNotFoundException e) {
        //Suppress the file not found exception
    }
    return oldMap;
}
项目:MarkTimeJS    文件:ChromeStorage.java   
private JSONObject getStorage(String namespace) throws IOException, JSONException {
    JSONObject oldMap = new JSONObject();
    CordovaResourceApi resourceApi = webView.getResourceApi();
    try {
        OpenForReadResult readResult = resourceApi.openForRead(getStorageFile(namespace));
        ByteArrayOutputStream readBytes = new ByteArrayOutputStream((int)readResult.length);
        resourceApi.copyResource(readResult, readBytes);
        byte[] bytes = readBytes.toByteArray();
        String content = (new String(bytes)).trim();
        if (content.length() > 0) {
            oldMap = new JSONObject(content);
        }
    } catch (FileNotFoundException e) {
        //Suppress the file not found exception
    }
    return oldMap;
}
项目:LoRaWAN-Smart-Parking    文件:IceCreamCordovaWebViewClient.java   
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
    try {
        // Check the against the whitelist and lock out access to the WebView directory
        // Changing this will cause problems for your application
        if (isUrlHarmful(url)) {
            LOG.w(TAG, "URL blocked by whitelist: " + url);
            // Results in a 404.
            return new WebResourceResponse("text/plain", "UTF-8", null);
        }

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

        if (!origUri.equals(remappedUri) || needsSpecialsInAssetUrlFix(origUri) || needsKitKatContentUrlFix(origUri)) {
            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("IceCreamCordovaWebViewClient", "Error occurred while loading a file (returning a 404).", e);
        }
        // Results in a 404.
        return new WebResourceResponse("text/plain", "UTF-8", null);
    }
}
项目:LoRaWAN-Smart-Parking    文件:IceCreamCordovaWebViewClient.java   
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
    try {
        // Check the against the whitelist and lock out access to the WebView directory
        // Changing this will cause problems for your application
        if (isUrlHarmful(url)) {
            LOG.w(TAG, "URL blocked by whitelist: " + url);
            // Results in a 404.
            return new WebResourceResponse("text/plain", "UTF-8", null);
        }

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

        if (!origUri.equals(remappedUri) || needsSpecialsInAssetUrlFix(origUri) || needsKitKatContentUrlFix(origUri)) {
            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("IceCreamCordovaWebViewClient", "Error occurred while loading a file (returning a 404).", e);
        }
        // Results in a 404.
        return new WebResourceResponse("text/plain", "UTF-8", null);
    }
}
项目:cordova-plugin-crosswalk-webview    文件:XWalkCordovaResourceClient.java   
@Override
public WebResourceResponse shouldInterceptLoadRequest(XWalkView view, String url) {
    try {
        // Check the against the white-list.
        if (!parentEngine.pluginManager.shouldAllowRequest(url)) {
            LOG.w(TAG, "URL blocked by whitelist: " + 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)) {
            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);
    }
}
项目:cordova-photosphere-example    文件:XWalkCordovaResourceClient.java   
@Override
public WebResourceResponse shouldInterceptLoadRequest(XWalkView view, String url) {
    try {
        // Check the against the white-list.
        if (!parentEngine.pluginManager.shouldAllowRequest(url)) {
            LOG.w(TAG, "URL blocked by whitelist: " + 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)) {
            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);
    }
}
项目:cordova-photosphere-example    文件:XWalkCordovaResourceClient.java   
@Override
public WebResourceResponse shouldInterceptLoadRequest(XWalkView view, String url) {
    try {
        // Check the against the white-list.
        if (!parentEngine.pluginManager.shouldAllowRequest(url)) {
            LOG.w(TAG, "URL blocked by whitelist: " + 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)) {
            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);
    }
}
项目:ShaPaoZi-Mobile    文件:XWalkCordovaResourceClient.java   
@Override
public WebResourceResponse shouldInterceptLoadRequest(XWalkView view, String url) {
    try {
        // Check the against the white-list.
        if (!parentEngine.pluginManager.shouldAllowRequest(url)) {
            LOG.w(TAG, "URL blocked by whitelist: " + 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)) {
            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);
    }
}
项目:ShaPaoZi-Mobile    文件:XWalkCordovaResourceClient.java   
@Override
public WebResourceResponse shouldInterceptLoadRequest(XWalkView view, String url) {
    try {
        // Check the against the white-list.
        if (!parentEngine.pluginManager.shouldAllowRequest(url)) {
            LOG.w(TAG, "URL blocked by whitelist: " + 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)) {
            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);
    }
}
项目:smart-mirror-app    文件:IceCreamCordovaWebViewClient.java   
@Override
public AmazonWebResourceResponse shouldInterceptRequest(AmazonWebView view, String url) {
    try {
        // Check the against the whitelist and lock out access to the WebView directory
        // Changing this will cause problems for your application
        if (isUrlHarmful(url)) {
            LOG.w(TAG, "URL blocked by whitelist: " + url);
            // Results in a 404.
            return new AmazonWebResourceResponse("text/plain", "UTF-8", null);
        }

        CordovaResourceApi resourceApi = appView.getResourceApi();
        Uri origUri = Uri.parse(url);
        // Allow plugins to intercept AmazonWebView requests.
        Uri remappedUri = resourceApi.remapUri(origUri);

        if (!origUri.equals(remappedUri) || needsSpecialsInAssetUrlFix(origUri) || needsKitKatContentUrlFix(origUri)) {
            OpenForReadResult result = resourceApi.openForRead(remappedUri, true);
            return new AmazonWebResourceResponse(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("IceCreamCordovaWebViewClient", "Error occurred while loading a file (returning a 404).", e);
        }
        // Results in a 404.
        return new AmazonWebResourceResponse("text/plain", "UTF-8", null);
    }
}
项目:cordova-plugin-background-mode    文件:IceCreamCordovaWebViewClient.java   
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
    try {
        // Check the against the whitelist and lock out access to the WebView directory
        // Changing this will cause problems for your application
        if (isUrlHarmful(url)) {
            LOG.w(TAG, "URL blocked by whitelist: " + url);
            // Results in a 404.
            return new WebResourceResponse("text/plain", "UTF-8", null);
        }

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

        if (!origUri.equals(remappedUri) || needsSpecialsInAssetUrlFix(origUri) || needsKitKatContentUrlFix(origUri)) {
            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("IceCreamCordovaWebViewClient", "Error occurred while loading a file (returning a 404).", e);
        }
        // Results in a 404.
        return new WebResourceResponse("text/plain", "UTF-8", null);
    }
}
项目:multirotorstuff-vtx-calc    文件:IceCreamCordovaWebViewClient.java   
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
    try {
        // Check the against the whitelist and lock out access to the WebView directory
        // Changing this will cause problems for your application
        if (isUrlHarmful(url)) {
            LOG.w(TAG, "URL blocked by whitelist: " + url);
            // Results in a 404.
            return new WebResourceResponse("text/plain", "UTF-8", null);
        }

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

        if (!origUri.equals(remappedUri) || needsSpecialsInAssetUrlFix(origUri) || needsKitKatContentUrlFix(origUri)) {
            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("IceCreamCordovaWebViewClient", "Error occurred while loading a file (returning a 404).", e);
        }
        // Results in a 404.
        return new WebResourceResponse("text/plain", "UTF-8", null);
    }
}
项目:L.TileLayer.Cordova    文件:IceCreamCordovaWebViewClient.java   
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
    try {
        // Check the against the whitelist and lock out access to the WebView directory
        // Changing this will cause problems for your application
        if (isUrlHarmful(url)) {
            LOG.w(TAG, "URL blocked by whitelist: " + url);
            // Results in a 404.
            return new WebResourceResponse("text/plain", "UTF-8", null);
        }

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

        if (!origUri.equals(remappedUri) || needsSpecialsInAssetUrlFix(origUri) || needsKitKatContentUrlFix(origUri)) {
            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("IceCreamCordovaWebViewClient", "Error occurred while loading a file (returning a 404).", e);
        }
        // Results in a 404.
        return new WebResourceResponse("text/plain", "UTF-8", null);
    }
}
项目:cordova-android-tv    文件:IceCreamCordovaWebViewClient.java   
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
    try {
        // Check the against the whitelist and lock out access to the WebView directory
        // Changing this will cause problems for your application
        if (isUrlHarmful(url)) {
            LOG.w(TAG, "URL blocked by whitelist: " + url);
            // Results in a 404.
            return new WebResourceResponse("text/plain", "UTF-8", null);
        }

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

        if (!origUri.equals(remappedUri) || needsSpecialsInAssetUrlFix(origUri) || needsKitKatContentUrlFix(origUri)) {
            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("IceCreamCordovaWebViewClient", "Error occurred while loading a file (returning a 404).", e);
        }
        // Results in a 404.
        return new WebResourceResponse("text/plain", "UTF-8", null);
    }
}
项目:Cordova-Locale-Plugin    文件:IceCreamCordovaWebViewClient.java   
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
    try {
        // Check the against the whitelist and lock out access to the WebView directory
        // Changing this will cause problems for your application
        if (isUrlHarmful(url)) {
            LOG.w(TAG, "URL blocked by whitelist: " + url);
            // Results in a 404.
            return new WebResourceResponse("text/plain", "UTF-8", null);
        }

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

        if (!origUri.equals(remappedUri) || needsSpecialsInAssetUrlFix(origUri) || needsKitKatContentUrlFix(origUri)) {
            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("IceCreamCordovaWebViewClient", "Error occurred while loading a file (returning a 404).", e);
        }
        // Results in a 404.
        return new WebResourceResponse("text/plain", "UTF-8", null);
    }
}
项目:pubnub-rpi-smart-parking    文件:IceCreamCordovaWebViewClient.java   
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
    try {
        // Check the against the whitelist and lock out access to the WebView directory
        // Changing this will cause problems for your application
        if (isUrlHarmful(url)) {
            LOG.w(TAG, "URL blocked by whitelist: " + url);
            // Results in a 404.
            return new WebResourceResponse("text/plain", "UTF-8", null);
        }

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

        if (!origUri.equals(remappedUri) || needsSpecialsInAssetUrlFix(origUri) || needsKitKatContentUrlFix(origUri)) {
            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("IceCreamCordovaWebViewClient", "Error occurred while loading a file (returning a 404).", e);
        }
        // Results in a 404.
        return new WebResourceResponse("text/plain", "UTF-8", null);
    }
}
项目:IoTgo_Android_App    文件:IceCreamCordovaWebViewClient.java   
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
    try {
        // Check the against the whitelist and lock out access to the WebView directory
        // Changing this will cause problems for your application
        if (isUrlHarmful(url)) {
            LOG.w(TAG, "URL blocked by whitelist: " + url);
            // Results in a 404.
            return new WebResourceResponse("text/plain", "UTF-8", null);
        }

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

        if (!origUri.equals(remappedUri) || needsSpecialsInAssetUrlFix(origUri) || needsKitKatContentUrlFix(origUri)) {
            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("IceCreamCordovaWebViewClient", "Error occurred while loading a file (returning a 404).", e);
        }
        // Results in a 404.
        return new WebResourceResponse("text/plain", "UTF-8", null);
    }
}
项目:CanDoVS2015    文件:IceCreamCordovaWebViewClient.java   
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
    try {
        // Check the against the whitelist and lock out access to the WebView directory
        // Changing this will cause problems for your application
        if (isUrlHarmful(url)) {
            LOG.w(TAG, "URL blocked by whitelist: " + url);
            // Results in a 404.
            return new WebResourceResponse("text/plain", "UTF-8", null);
        }

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

        if (!origUri.equals(remappedUri) || needsSpecialsInAssetUrlFix(origUri) || needsKitKatContentUrlFix(origUri)) {
            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("IceCreamCordovaWebViewClient", "Error occurred while loading a file (returning a 404).", e);
        }
        // Results in a 404.
        return new WebResourceResponse("text/plain", "UTF-8", null);
    }
}
项目:krakn    文件:XWalkCordovaResourceClient.java   
@Override
public WebResourceResponse shouldInterceptLoadRequest(XWalkView view, String url) {
    try {
        // Check the against the white-list.
        if ((url.startsWith("http:") || url.startsWith("https:")) && !appView.getWhitelist().isUrlWhiteListed(url)) {
            LOG.w(TAG, "URL blocked by whitelist: " + url);
            // Results in a 404.
            return new WebResourceResponse("text/plain", "UTF-8", null);
        }

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

        if (!origUri.equals(remappedUri) || needsSpecialsInAssetUrlFix(origUri) || needsKitKatContentUrlFix(origUri)) {
            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("IceCreamCordovaWebViewClient", "Error occurred while loading a file (returning a 404).", e);
        }
        // Results in a 404.
        return new WebResourceResponse("text/plain", "UTF-8", null);
    }
}
项目:krakn    文件:IceCreamCordovaWebViewClient.java   
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
    try {
        // Check the against the whitelist and lock out access to the WebView directory
        // Changing this will cause problems for your application
        if (isUrlHarmful(url)) {
            LOG.w(TAG, "URL blocked by whitelist: " + url);
            // Results in a 404.
            return new WebResourceResponse("text/plain", "UTF-8", null);
        }

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

        if (!origUri.equals(remappedUri) || needsSpecialsInAssetUrlFix(origUri) || needsKitKatContentUrlFix(origUri)) {
            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("IceCreamCordovaWebViewClient", "Error occurred while loading a file (returning a 404).", e);
        }
        // Results in a 404.
        return new WebResourceResponse("text/plain", "UTF-8", null);
    }
}
项目:krakn    文件:XWalkCordovaResourceClient.java   
@Override
public WebResourceResponse shouldInterceptLoadRequest(XWalkView view, String url) {
    try {
        // Check the against the white-list.
        if ((url.startsWith("http:") || url.startsWith("https:")) && !appView.getWhitelist().isUrlWhiteListed(url)) {
            LOG.w(TAG, "URL blocked by whitelist: " + url);
            // Results in a 404.
            return new WebResourceResponse("text/plain", "UTF-8", null);
        }

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

        if (!origUri.equals(remappedUri) || needsSpecialsInAssetUrlFix(origUri) || needsKitKatContentUrlFix(origUri)) {
            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("IceCreamCordovaWebViewClient", "Error occurred while loading a file (returning a 404).", e);
        }
        // Results in a 404.
        return new WebResourceResponse("text/plain", "UTF-8", null);
    }
}
项目:krakn    文件:XWalkCordovaWebViewClient.java   
@Override
public WebResourceResponse shouldInterceptLoadRequest(XWalkView view, String url) {
    try {
        // Check the against the white-list.
        if ((url.startsWith("http:") || url.startsWith("https:")) && !Config.isUrlWhiteListed(url)) {
            LOG.w(TAG, "URL blocked by whitelist: " + url);
            // Results in a 404.
            return new WebResourceResponse("text/plain", "UTF-8", null);
        }

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

        if (!origUri.equals(remappedUri) || needsSpecialsInAssetUrlFix(origUri) || needsKitKatContentUrlFix(origUri)) {
            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("IceCreamCordovaWebViewClient", "Error occurred while loading a file (returning a 404).", e);
        }
        // Results in a 404.
        return new WebResourceResponse("text/plain", "UTF-8", null);
    }
}
项目:krakn    文件:IceCreamCordovaWebViewClient.java   
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
    try {
        // Check the against the white-list.
        if ((url.startsWith("http:") || url.startsWith("https:")) && !Config.isUrlWhiteListed(url)) {
            LOG.w(TAG, "URL blocked by whitelist: " + url);
            // Results in a 404.
            return new WebResourceResponse("text/plain", "UTF-8", null);
        }

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

        if (!origUri.equals(remappedUri) || needsSpecialsInAssetUrlFix(origUri) || needsKitKatContentUrlFix(origUri)) {
            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("IceCreamCordovaWebViewClient", "Error occurred while loading a file (returning a 404).", e);
        }
        // Results in a 404.
        return new WebResourceResponse("text/plain", "UTF-8", null);
    }
}
项目:krakn    文件:IceCreamCordovaWebViewClient.java   
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
    try {
        // Check the against the white-list.
        if ((url.startsWith("http:") || url.startsWith("https:")) && !Config.isUrlWhiteListed(url)) {
            LOG.w(TAG, "URL blocked by whitelist: " + url);
            // Results in a 404.
            return new WebResourceResponse("text/plain", "UTF-8", null);
        }

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

        if (!origUri.equals(remappedUri) || needsSpecialsInAssetUrlFix(origUri) || needsKitKatContentUrlFix(origUri)) {
            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("IceCreamCordovaWebViewClient", "Error occurred while loading a file (returning a 404).", e);
        }
        // Results in a 404.
        return new WebResourceResponse("text/plain", "UTF-8", null);
    }
}
项目:krakn    文件:XWalkCordovaResourceClient.java   
@Override
public WebResourceResponse shouldInterceptLoadRequest(XWalkView view, String url) {
    try {
        // Check the against the white-list.
        if ((url.startsWith("http:") || url.startsWith("https:")) && !appView.getWhitelist().isUrlWhiteListed(url)) {
            LOG.w(TAG, "URL blocked by whitelist: " + url);
            // Results in a 404.
            return new WebResourceResponse("text/plain", "UTF-8", null);
        }

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

        if (!origUri.equals(remappedUri) || needsSpecialsInAssetUrlFix(origUri) || needsKitKatContentUrlFix(origUri)) {
            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("IceCreamCordovaWebViewClient", "Error occurred while loading a file (returning a 404).", e);
        }
        // Results in a 404.
        return new WebResourceResponse("text/plain", "UTF-8", null);
    }
}
项目:krakn    文件:IceCreamCordovaWebViewClient.java   
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
    try {
        // Check the against the whitelist and lock out access to the WebView directory
        // Changing this will cause problems for your application
        if (isUrlHarmful(url)) {
            LOG.w(TAG, "URL blocked by whitelist: " + url);
            // Results in a 404.
            return new WebResourceResponse("text/plain", "UTF-8", null);
        }

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

        if (!origUri.equals(remappedUri) || needsSpecialsInAssetUrlFix(origUri) || needsKitKatContentUrlFix(origUri)) {
            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("IceCreamCordovaWebViewClient", "Error occurred while loading a file (returning a 404).", e);
        }
        // Results in a 404.
        return new WebResourceResponse("text/plain", "UTF-8", null);
    }
}
项目:krakn    文件:XWalkCordovaResourceClient.java   
@Override
public WebResourceResponse shouldInterceptLoadRequest(XWalkView view, String url) {
    try {
        // Check the against the white-list.
        if ((url.startsWith("http:") || url.startsWith("https:")) && !appView.getWhitelist().isUrlWhiteListed(url)) {
            LOG.w(TAG, "URL blocked by whitelist: " + url);
            // Results in a 404.
            return new WebResourceResponse("text/plain", "UTF-8", null);
        }

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

        if (!origUri.equals(remappedUri) || needsSpecialsInAssetUrlFix(origUri) || needsKitKatContentUrlFix(origUri)) {
            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("IceCreamCordovaWebViewClient", "Error occurred while loading a file (returning a 404).", e);
        }
        // Results in a 404.
        return new WebResourceResponse("text/plain", "UTF-8", null);
    }
}
项目:krakn    文件:XWalkCordovaWebViewClient.java   
@Override
public WebResourceResponse shouldInterceptLoadRequest(XWalkView view, String url) {
    try {
        // Check the against the white-list.
        if ((url.startsWith("http:") || url.startsWith("https:")) && !Config.isUrlWhiteListed(url)) {
            LOG.w(TAG, "URL blocked by whitelist: " + url);
            // Results in a 404.
            return new WebResourceResponse("text/plain", "UTF-8", null);
        }

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

        if (!origUri.equals(remappedUri) || needsSpecialsInAssetUrlFix(origUri) || needsKitKatContentUrlFix(origUri)) {
            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("IceCreamCordovaWebViewClient", "Error occurred while loading a file (returning a 404).", e);
        }
        // Results in a 404.
        return new WebResourceResponse("text/plain", "UTF-8", null);
    }
}
项目:krakn    文件:IceCreamCordovaWebViewClient.java   
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
    try {
        // Check the against the white-list.
        if ((url.startsWith("http:") || url.startsWith("https:")) && !Config.isUrlWhiteListed(url)) {
            LOG.w(TAG, "URL blocked by whitelist: " + url);
            // Results in a 404.
            return new WebResourceResponse("text/plain", "UTF-8", null);
        }

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

        if (!origUri.equals(remappedUri) || needsSpecialsInAssetUrlFix(origUri) || needsKitKatContentUrlFix(origUri)) {
            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("IceCreamCordovaWebViewClient", "Error occurred while loading a file (returning a 404).", e);
        }
        // Results in a 404.
        return new WebResourceResponse("text/plain", "UTF-8", null);
    }
}
项目:posjs2    文件:IceCreamCordovaWebViewClient.java   
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
    try {
        // Check the against the white-list.
        if ((url.startsWith("http:") || url.startsWith("https:")) && !Config.isUrlWhiteListed(url)) {
            LOG.w(TAG, "URL blocked by whitelist: " + url);
            // Results in a 404.
            return new WebResourceResponse("text/plain", "UTF-8", null);
        }

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

        if (!origUri.equals(remappedUri) || needsSpecialsInAssetUrlFix(origUri)) {
            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("IceCreamCordovaWebViewClient", "Error occurred while loading a file (returning a 404).", e);
        }
        // Results in a 404.
        return new WebResourceResponse("text/plain", "UTF-8", null);
    }
}
项目:hustElectricity    文件:IceCreamCordovaWebViewClient.java   
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
    try {
        // Check the against the whitelist and lock out access to the WebView directory
        // Changing this will cause problems for your application
        if (isUrlHarmful(url)) {
            LOG.w(TAG, "URL blocked by whitelist: " + url);
            // Results in a 404.
            return new WebResourceResponse("text/plain", "UTF-8", null);
        }

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

        if (!origUri.equals(remappedUri) || needsSpecialsInAssetUrlFix(origUri) || needsKitKatContentUrlFix(origUri)) {
            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("IceCreamCordovaWebViewClient", "Error occurred while loading a file (returning a 404).", e);
        }
        // Results in a 404.
        return new WebResourceResponse("text/plain", "UTF-8", null);
    }
}
项目:Wetube    文件:IceCreamCordovaWebViewClient.java   
@Override
public WebResourceResponse shouldInterceptLoadRequest(XWalkView view, String url) {
    try {
        // Check the against the whitelist and lock out access to the WebView directory
        // Changing this will cause problems for your application
        if (isUrlHarmful(url)) {
            LOG.w(TAG, "URL blocked by whitelist: " + url);
            // Results in a 404.
            return new WebResourceResponse("text/plain", "UTF-8", null);
        }

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

        if (!origUri.equals(remappedUri) || needsSpecialsInAssetUrlFix(origUri) || needsKitKatContentUrlFix(origUri)) {
            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("IceCreamCordovaWebViewClient", "Error occurred while loading a file (returning a 404).", e);
        }
        // Results in a 404.
        return new WebResourceResponse("text/plain", "UTF-8", null);
    }
}