org.apache.cordova.Config#isUrlWhiteListed ( )源码实例Demo

下面列出了org.apache.cordova.Config#isUrlWhiteListed ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: phonegapbootcampsite   文件: CordovaWebView.java
/**
 * Load URL in webview.
 *
 * @param url
 */
void loadUrlNow(String url) {
    if (LOG.isLoggable(LOG.DEBUG) && !url.startsWith("javascript:")) {
        LOG.d(TAG, ">>> loadUrlNow()");
    }
    if (url.startsWith("file://") || url.startsWith("javascript:") || Config.isUrlWhiteListed(url)) {
        super.loadUrl(url);
    }
}
 
源代码2 项目: phonegapbootcampsite   文件: CordovaWebView.java
/**
 * Load the specified URL in the Cordova webview or a new browser instance.
 *
 * NOTE: If openExternal is false, only URLs listed in whitelist can be loaded.
 *
 * @param url           The url to load.
 * @param openExternal  Load url in browser instead of Cordova webview.
 * @param clearHistory  Clear the history stack, so new page becomes top of history
 * @param params        Parameters for new app
 */
public void showWebPage(String url, boolean openExternal, boolean clearHistory, HashMap<String, Object> params) {
    LOG.d(TAG, "showWebPage(%s, %b, %b, HashMap", url, openExternal, clearHistory);

    // If clearing history
    if (clearHistory) {
        this.clearHistory();
    }

    // If loading into our webview
    if (!openExternal) {

        // Make sure url is in whitelist
        if (url.startsWith("file://") || Config.isUrlWhiteListed(url)) {
            // TODO: What about params?
            // Load new URL
            this.loadUrl(url);
            return;
        }
        // Load in default viewer if not
        LOG.w(TAG, "showWebPage: Cannot load URL into webview since it is not in white list.  Loading into browser instead. (URL=" + url + ")");
    }
    try {
        // Omitting the MIME type for file: URLs causes "No Activity found to handle Intent".
        // Adding the MIME type to http: URLs causes them to not be handled by the downloader.
        Intent intent = new Intent(Intent.ACTION_VIEW);
        Uri uri = Uri.parse(url);
        if ("file".equals(uri.getScheme())) {
            intent.setDataAndType(uri, resourceApi.getMimeType(uri));
        } else {
            intent.setData(uri);
        }
        cordova.getActivity().startActivity(intent);
    } catch (android.content.ActivityNotFoundException e) {
        LOG.e(TAG, "Error loading url " + url, e);
    }
}
 
/**
 * Load URL in webview.
 *
 * @param url
 */
void loadUrlNow(String url) {
    if (LOG.isLoggable(LOG.DEBUG) && !url.startsWith("javascript:")) {
        LOG.d(TAG, ">>> loadUrlNow()");
    }
    if (url.startsWith("file://") || url.startsWith("javascript:") || Config.isUrlWhiteListed(url)) {
        super.loadUrl(url);
    }
}
 
/**
 * Load the specified URL in the Cordova webview or a new browser instance.
 *
 * NOTE: If openExternal is false, only URLs listed in whitelist can be loaded.
 *
 * @param url           The url to load.
 * @param openExternal  Load url in browser instead of Cordova webview.
 * @param clearHistory  Clear the history stack, so new page becomes top of history
 * @param params        Parameters for new app
 */
public void showWebPage(String url, boolean openExternal, boolean clearHistory, HashMap<String, Object> params) {
    LOG.d(TAG, "showWebPage(%s, %b, %b, HashMap", url, openExternal, clearHistory);

    // If clearing history
    if (clearHistory) {
        this.clearHistory();
    }

    // If loading into our webview
    if (!openExternal) {

        // Make sure url is in whitelist
        if (url.startsWith("file://") || Config.isUrlWhiteListed(url)) {
            // TODO: What about params?
            // Load new URL
            this.loadUrl(url);
            return;
        }
        // Load in default viewer if not
        LOG.w(TAG, "showWebPage: Cannot load URL into webview since it is not in white list.  Loading into browser instead. (URL=" + url + ")");
    }
    try {
        // Omitting the MIME type for file: URLs causes "No Activity found to handle Intent".
        // Adding the MIME type to http: URLs causes them to not be handled by the downloader.
        Intent intent = new Intent(Intent.ACTION_VIEW);
        Uri uri = Uri.parse(url);
        if ("file".equals(uri.getScheme())) {
            intent.setDataAndType(uri, resourceApi.getMimeType(uri));
        } else {
            intent.setData(uri);
        }
        cordova.getActivity().startActivity(intent);
    } catch (android.content.ActivityNotFoundException e) {
        LOG.e(TAG, "Error loading url " + url, e);
    }
}
 
/**
 * Load URL in webview.
 *
 * @param url
 */
void loadUrlNow(String url) {
    if (LOG.isLoggable(LOG.DEBUG) && !url.startsWith("javascript:")) {
        LOG.d(TAG, ">>> loadUrlNow()");
    }
    if (url.startsWith("file://") || url.startsWith("javascript:") || Config.isUrlWhiteListed(url)) {
        super.loadUrl(url);
    }
}
 
源代码6 项目: wildfly-samples   文件: CordovaWebView.java
/**
 * Load URL in webview.
 *
 * @param url
 */
void loadUrlNow(String url) {
    if (LOG.isLoggable(LOG.DEBUG) && !url.startsWith("javascript:")) {
        LOG.d(TAG, ">>> loadUrlNow()");
    }
    if (url.startsWith("file://") || url.startsWith("javascript:") || Config.isUrlWhiteListed(url)) {
        super.loadUrl(url);
    }
}
 
源代码7 项目: wildfly-samples   文件: CordovaWebView.java
/**
 * Load the specified URL in the Cordova webview or a new browser instance.
 *
 * NOTE: If openExternal is false, only URLs listed in whitelist can be loaded.
 *
 * @param url           The url to load.
 * @param openExternal  Load url in browser instead of Cordova webview.
 * @param clearHistory  Clear the history stack, so new page becomes top of history
 * @param params        Parameters for new app
 */
public void showWebPage(String url, boolean openExternal, boolean clearHistory, HashMap<String, Object> params) {
    LOG.d(TAG, "showWebPage(%s, %b, %b, HashMap", url, openExternal, clearHistory);

    // If clearing history
    if (clearHistory) {
        this.clearHistory();
    }

    // If loading into our webview
    if (!openExternal) {

        // Make sure url is in whitelist
        if (url.startsWith("file://") || Config.isUrlWhiteListed(url)) {
            // TODO: What about params?
            // Load new URL
            this.loadUrl(url);
            return;
        }
        // Load in default viewer if not
        LOG.w(TAG, "showWebPage: Cannot load URL into webview since it is not in white list.  Loading into browser instead. (URL=" + url + ")");
    }
    try {
        // Omitting the MIME type for file: URLs causes "No Activity found to handle Intent".
        // Adding the MIME type to http: URLs causes them to not be handled by the downloader.
        Intent intent = new Intent(Intent.ACTION_VIEW);
        Uri uri = Uri.parse(url);
        if ("file".equals(uri.getScheme())) {
            intent.setDataAndType(uri, resourceApi.getMimeType(uri));
        } else {
            intent.setData(uri);
        }
        cordova.getActivity().startActivity(intent);
    } catch (android.content.ActivityNotFoundException e) {
        LOG.e(TAG, "Error loading url " + url, e);
    }
}
 
/**
 * Load URL in webview.
 *
 * @param url
 */
void loadUrlNow(String url) {
    if (LOG.isLoggable(LOG.DEBUG) && !url.startsWith("javascript:")) {
        LOG.d(TAG, ">>> loadUrlNow()");
    }
    if (url.startsWith("file://") || url.startsWith("javascript:") || Config.isUrlWhiteListed(url)) {
        super.loadUrl(url);
    }
}
 
 方法所在类
 同类方法