Java Code Examples for com.tencent.smtt.export.external.interfaces.SslErrorHandler#proceed()

The following examples show how to use com.tencent.smtt.export.external.interfaces.SslErrorHandler#proceed() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: X5WebViewClient.java    From x5webview-cordova-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * Notify the host application that an SSL error occurred while loading a resource.
 * The host application must call either handler.cancel() or handler.proceed().
 * Note that the decision may be retained for use in response to future SSL errors.
 * The default behavior is to cancel the load.
 *
 * @param view          The WebView that is initiating the callback.
 * @param handler       An SslErrorHandler object that will handle the user's response.
 * @param error         The SSL error object.
 */
@TargetApi(8)
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {

    final String packageName = parentEngine.cordova.getActivity().getPackageName();
    final PackageManager pm = parentEngine.cordova.getActivity().getPackageManager();

    ApplicationInfo appInfo;
    try {
        appInfo = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA);
        if ((appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
            // debug = true
            handler.proceed();
            return;
        } else {
            // debug = false
            super.onReceivedSslError(view, handler, error);
        }
    } catch (NameNotFoundException e) {
        // When it doubt, lock it out!
        super.onReceivedSslError(view, handler, error);
    }
}
 
Example 2
Source File: X5WebViewClient.java    From cordova-plugin-x5-tbs with Apache License 2.0 6 votes vote down vote up
/**
 * Notify the host application that an SSL error occurred while loading a resource.
 * The host application must call either handler.cancel() or handler.proceed().
 * Note that the decision may be retained for use in response to future SSL errors.
 * The default behavior is to cancel the load.
 *
 * @param view    The WebView that is initiating the callback.
 * @param handler An SslErrorHandler object that will handle the user's response.
 * @param error   The SSL error object.
 */
@TargetApi(8)
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {

  final String packageName = parentEngine.cordova.getActivity().getPackageName();
  final PackageManager pm = parentEngine.cordova.getActivity().getPackageManager();

  ApplicationInfo appInfo;
  try {
    appInfo = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA);
    if ((appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
      // debug = true
      handler.proceed();
      return;
    } else {
      // debug = false
      super.onReceivedSslError(view, handler, error);
    }
  } catch (NameNotFoundException e) {
    // When it doubt, lock it out!
    super.onReceivedSslError(view, handler, error);
  }
}
 
Example 3
Source File: X5WebViewClient.java    From YCWebView with Apache License 2.0 6 votes vote down vote up
/**
 * 在加载资源时通知主机应用程序发生SSL错误
 * 作用:处理https请求
 *      webView加载一些别人的url时候,有时候会发生证书认证错误的情况,这时候希望能够正常的呈现页面给用户,
 *      我们需要忽略证书错误,需要调用WebViewClient类的onReceivedSslError方法,
 *      调用handler.proceed()来忽略该证书错误。
 * @param view                              view
 * @param handler                           handler,表示一个处理SSL错误的请求,提供了方法操作(proceed/cancel)请求
 * @param error                             error
 */
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
    super.onReceivedSslError(view, handler, error);
    X5LogUtils.i("-------onReceivedSslError-------"+ error.getUrl());
    if (error!=null){
        String url = error.getUrl();
        if (webListener!=null){
            webListener.showErrorView(X5WebUtils.ErrorMode.SSL_ERROR);
        }
        X5LogUtils.i("onReceivedSslError----异常url----"+url);
    }
    //https忽略证书问题
    if (handler!=null){
        //表示等待证书响应
        handler.proceed();
        // handler.cancel();      //表示挂起连接,为默认方式
        // handler.handleMessage(null);    //可做其他处理
    }
}
 
Example 4
Source File: X5WebViewClient.java    From cordova-plugin-x5engine-webview with Apache License 2.0 6 votes vote down vote up
/**
 * Notify the host application that an SSL error occurred while loading a resource.
 * The host application must call either handler.cancel() or handler.proceed().
 * Note that the decision may be retained for use in response to future SSL errors.
 * The default behavior is to cancel the load.
 *
 * @param view          The WebView that is initiating the callback.
 * @param handler       An SslErrorHandler object that will handle the user's response.
 * @param error         The SSL error object.
 */
@TargetApi(8)
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {

    final String packageName = parentEngine.cordova.getActivity().getPackageName();
    final PackageManager pm = parentEngine.cordova.getActivity().getPackageManager();

    ApplicationInfo appInfo;
    try {
        appInfo = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA);
        if ((appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
            // debug = true
            handler.proceed();
            return;
        } else {
            // debug = false
            super.onReceivedSslError(view, handler, error);
        }
    } catch (NameNotFoundException e) {
        // When it doubt, lock it out!
        super.onReceivedSslError(view, handler, error);
    }
}
 
Example 5
Source File: x5_MainActivity.java    From styT with Apache License 2.0 4 votes vote down vote up
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
    handler.proceed();
    super.onReceivedSslError(view, handler, error);
}
 
Example 6
Source File: MyTestActivity.java    From AndroidFrame with Apache License 2.0 4 votes vote down vote up
@Override
public void onReceivedSslError(WebView webView, SslErrorHandler sslErrorHandler, SslError sslError) {
    Log.e(LOG_TAG, "------------onReceivedSslError----------");
    sslErrorHandler.proceed();
}
 
Example 7
Source File: x5_MainActivity.java    From stynico with MIT License 4 votes vote down vote up
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error)
{
          handler.proceed();//接受信任所有网站的证书,使用此方法可以解决淘宝,天猫等网站无法正常在本地加载的问题
          //Toast.makeText(MainActivity.this,"1",Toast.LENGTH_SHORT).show();

      }
 
Example 8
Source File: CrazyDailyWebView.java    From CrazyDaily with Apache License 2.0 4 votes vote down vote up
@Override
public void onReceivedSslError(WebView webView, SslErrorHandler handler, SslError sslError) {
    handler.proceed();//处理证书
}
 
Example 9
Source File: MyX5WebViewClient.java    From ByWebView with Apache License 2.0 4 votes vote down vote up
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
    handler.proceed(); //解决方案, 不要调用super.xxxx
}
 
Example 10
Source File: CBrowserWindow7.java    From appcan-android with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler,
                               SslError error) {

    handler.proceed();
}
 
Example 11
Source File: CBrowserWindow.java    From appcan-android with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
    handler.proceed();
}