com.tencent.smtt.sdk.WebView Java Examples

The following examples show how to use com.tencent.smtt.sdk.WebView. 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: WebViewFragment.java    From Dainty with Apache License 2.0 6 votes vote down vote up
private void blockAds(WebView view) {
    String tags = view.getUrl();
    //noinspection MismatchedQueryAndUpdateOfStringBuilder
    StringBuilder sb = new StringBuilder();
    sb.append("javascript: ");
    String[] allTag = tags.split(",");
    for (String tag : allTag) {
        String adTag = tag;
        if (adTag.trim().length() > 0) {
            adTag = adTag.trim();
            if (adTag.contains("#")) {
                adTag = adTag.substring(adTag.indexOf("#") + 1);
                sb.append("document.getElementById(\'").append(adTag).append("\').remove();");

            } else if (adTag.contains(".")) {
                adTag = adTag.substring(adTag.indexOf(".") + 1);
                sb.append("var esc=document.getElementsByClassName(\'").append(adTag).append("\');for (var i = esc.length - 1; i >= 0; i--){esc[i].remove();};");

            } else {
                sb.append("var esc=document.getElementsByTagName(\'").append(adTag).append("\');for (var i = esc.length - 1; i >= 0; i--){esc[i].remove();};");
            }
        }
    }
}
 
Example #2
Source File: X5WebView.java    From YCWebView with Apache License 2.0 6 votes vote down vote up
private void initListener() {
    this.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View view) {
            // 这里不能像普通WebView一样将view强转为WebView然后获取HitTestResult,因为x5传来的view不是
            // 标准的WebView
            WebView.HitTestResult result = X5WebView.this.getHitTestResult();
            if (result == null) {
                return false;
            }
            int type = result.getType();
            if (type == WebView.HitTestResult.IMAGE_TYPE || type == WebView.HitTestResult.SRC_IMAGE_ANCHOR_TYPE) {
                // 图片
                return new SaveImageProcessor().showActionMenu(X5WebView.this);
            }
            return false;
        }
    });
}
 
Example #3
Source File: X5WebViewClient.java    From YCWebView with Apache License 2.0 6 votes vote down vote up
/**
 * 当页面加载完成会调用该方法
 * @param view                              view
 * @param url                               url链接
 */
@Override
public void onPageFinished(WebView view, String url) {
    X5LogUtils.i("-------onPageFinished-------"+url);
    if (mIsLoading) {
        mIsLoading = false;
    }
    if (!X5WebUtils.isConnected(webView.getContext()) && webListener!=null) {
        //隐藏进度条方法
        webListener.hindProgressBar();
        //显示异常页面
        webListener.showErrorView(X5WebUtils.ErrorMode.NO_NET);
    }
    super.onPageFinished(view, url);
    //设置网页在加载的时候暂时不加载图片
    //webView.getSettings().setBlockNetworkImage(false);
    //页面finish后再发起图片加载
    if(!webView.getSettings().getLoadsImagesAutomatically()) {
        webView.getSettings().setLoadsImagesAutomatically(true);
    }
    //html加载完成之后,添加监听图片的点击js函数
    //addImageClickListener();
    addImageArrayClickListener(webView);
    isLoadFinish = true;
}
 
Example #4
Source File: CookieUtils.java    From AndroidHybridLib with Apache License 2.0 6 votes vote down vote up
private static void synCookies(Context context, WebView webView, String domain, Map<String, String> cookieMap) {
    if (cookieMap == null || TextUtils.isEmpty(domain)) {
        return;
    }
    CookieManager cookieManager = CookieManager.getInstance();
    cookieManager.setAcceptCookie(true);
    for (Map.Entry<String, String> entry : cookieMap.entrySet()) {
        String cookie = entry.getKey() + "=" + entry.getValue();
        cookieManager.setCookie(domain, cookie);
    }
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
        cookieManager.setAcceptThirdPartyCookies(webView, true);
        cookieManager.flush();
    } else {
        CookieSyncManager.createInstance(context);
        CookieSyncManager.getInstance().sync();
    }
}
 
Example #5
Source File: X5WebViewClient.java    From YCWebView with Apache License 2.0 6 votes vote down vote up
/**
 * android与js交互:
 * 首先我们拿到html中加载图片的标签img.
 * 然后取出其对应的src属性
 * 循环遍历设置图片的点击事件
 * 将src作为参数传给java代码
 * 这个循环将所图片放入数组,当js调用本地方法时传入。
 * 当然如果采用方式一获取图片的话,本地方法可以不需要传入这个数组
 * 通过js代码找到标签为img的代码块,设置点击的监听方法与本地的openImage方法进行连接
 * @param webView                       webview
 */
private void addImageArrayClickListener(WebView webView) {
    webView.loadUrl("javascript:(function(){" +
            "var objs = document.getElementsByTagName(\"img\"); " +
            "var array=new Array(); " +
            "for(var j=0;j<objs.length;j++){" +
            "    array[j]=objs[j].src; " +
            "}"+
            "for(var i=0;i<objs.length;i++)  " +
            "{"
            + "    objs[i].onclick=function()  " +
            "    {  "
            + "        window.imagelistener.openImage(this.src,array);  " +
            "    }  " +
            "}" +
            "})()");
}
 
Example #6
Source File: RNX5WebViewManager.java    From react-native-x5 with MIT License 6 votes vote down vote up
@Override
protected WebView createViewInstance(ThemedReactContext reactContext) {
    X5WeView webView = new X5WeView(reactContext);

    webView.setWebChromeClient(new WebChromeClient() {
        @Override
        public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissionsCallback callback) {
            callback.invoke(origin, true, false);
        }
    });
    reactContext.addLifecycleEventListener(webView);
    mWebViewConfig.configWebView(webView);
    webView.getSettings().setBuiltInZoomControls(true);
    webView.getSettings().setDisplayZoomControls(false);

    // Fixes broken full-screen modals/galleries due to body height being 0.
    webView.setLayoutParams(
            new LayoutParams(LayoutParams.MATCH_PARENT,
                    LayoutParams.MATCH_PARENT));

    if (ReactBuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        WebView.setWebContentsDebuggingEnabled(true);
    }

    return webView;
}
 
Example #7
Source File: X5WebViewClient.java    From x5webview-cordova-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * On received http auth request.
 * The method reacts on all registered authentication tokens. There is one and only one authentication token for any host + realm combination
 */
@Override
public void onReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler, String host, String realm) {

    // Get the authentication token (if specified)
    AuthenticationToken token = this.getAuthenticationToken(host, realm);
    if (token != null) {
        handler.proceed(token.getUserName(), token.getPassword());
        return;
    }

    // Check if there is some plugin which can resolve this auth challenge
    PluginManager pluginManager = this.parentEngine.pluginManager;
    if (pluginManager != null && pluginManager.onReceivedHttpAuthRequest(null, new X5CordovaHttpAuthHandler(handler), host, realm)) {
        parentEngine.client.clearLoadTimeoutTimer();
        return;
    }

    // By default handle 401 like we'd normally do!
    super.onReceivedHttpAuthRequest(view, handler, host, realm);
}
 
Example #8
Source File: AgentWebX5Fragment.java    From AgentWebX5 with Apache License 2.0 6 votes vote down vote up
@Override
        public boolean shouldOverrideUrlLoading(final WebView view, String url) {
            LogUtils.i("Info", "mWebViewClient shouldOverrideUrlLoading:" + url);
            //intent:// scheme的处理 如果返回false , 则交给 DefaultWebClient 处理 , 默认会打开该Activity  , 如果Activity不存在则跳到应用市场上去.  true 表示拦截
            //例如优酷视频播放 ,intent://play?vid=XODEzMjU1MTI4&refer=&tuid=&ua=Mozilla%2F5.0%20(Linux%3B%20Android%207.0%3B%20SM-G9300%20Build%2FNRD90M%3B%20wv)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Version%2F4.0%20Chrome%2F58.0.3029.83%20Mobile%20Safari%2F537.36&source=exclusive-pageload&cookieid=14971464739049EJXvh|Z6i1re#Intent;scheme=youku;package=com.youku.phone;end;
            //优酷想唤起自己应用播放该视频 , 下面拦截地址返回 true  则会在应用内 H5 播放 ,禁止优酷唤起播放该视频, 如果返回 false , DefaultWebClient  会根据intent 协议处理 该地址 , 首先匹配该应用存不存在 ,如果存在 , 唤起该应用播放 , 如果不存在 , 则跳到应用市场下载该应用 .
            if (url.startsWith("intent://"))
                return true;
            else if (url.startsWith("youku"))
                return true;
//            else if(isAlipay(view,url))  //不需要,defaultWebClient内部会自动处理
//                return true;


            return false;
        }
 
Example #9
Source File: DefaultWebClient.java    From AgentWebX5 with Apache License 2.0 6 votes vote down vote up
private boolean handleLinked(String url) {
	if (url.startsWith(android.webkit.WebView.SCHEME_TEL)
			|| url.startsWith(SCHEME_SMS)
			|| url.startsWith(android.webkit.WebView.SCHEME_MAILTO)
			|| url.startsWith(android.webkit.WebView.SCHEME_GEO)) {
		try {
			Activity mActivity = null;
			if ((mActivity = mWeakReference.get()) == null)
				return false;
			Intent intent = new Intent(Intent.ACTION_VIEW);
			intent.setData(Uri.parse(url));
			mActivity.startActivity(intent);
		} catch (ActivityNotFoundException ignored) {
			if (AgentWebX5Config.DEBUG) {
				ignored.printStackTrace();
			}
		}
		return true;
	}
	return false;
}
 
Example #10
Source File: BridgeWebViewClient.java    From JsBridge with MIT License 6 votes vote down vote up
@Override
public void onPageFinished(WebView view, String url) {
    //modify:hjhrq1991,web为渲染即跳转导致系统未调用onPageStarted就调用onPageFinished方法引起的js桥初始化失败
    if (BridgeConfig.toLoadJs != null && !url.contains("about:blank") && !isRedirected) {
        BridgeUtil.webViewLoadLocalJs(view, BridgeConfig.toLoadJs, BridgeConfig.defaultJs, BridgeConfig.customJs);
    }

    if (webView.getStartupMessage() != null) {
        for (Message m : webView.getStartupMessage()) {
            webView.dispatchMessage(m);
        }
        webView.setStartupMessage(null);
    }

    if (bridgeWebViewClientListener != null) {
        bridgeWebViewClientListener.onPageFinished(view, url);
    }
}
 
Example #11
Source File: RNX5WebViewManager.java    From react-native-x5 with MIT License 6 votes vote down vote up
@Override
public void receiveCommand(WebView root, int commandId, @Nullable ReadableArray args) {
    switch (commandId) {
        case COMMAND_GO_BACK:
            root.goBack();
            break;
        case COMMAND_GO_FORWARD:
            root.goForward();
            break;
        case COMMAND_RELOAD:
            root.reload();
            break;
        case COMMAND_STOP_LOADING:
            root.stopLoading();
            break;
        case COMMAND_POST_MESSAGE:
            try {
                JSONObject eventInitDict = new JSONObject();
                eventInitDict.put("data", args.getString(0));
                root.loadUrl("javascript:(document.dispatchEvent(new MessageEvent('message', " + eventInitDict.toString() + ")))");
            } catch (JSONException e) {
                throw new RuntimeException(e);
            }
            break;
    }
}
 
Example #12
Source File: BridgeUtil.java    From JsBridge with MIT License 5 votes vote down vote up
/**
 * js 文件将注入为第一个script引用
 *
 * @param view webview
 * @param url url
 */
public static void webViewLoadJs(WebView view, String url) {
    String js = "var newscript = document.createElement(\"script\");";
    js += "newscript.src=\"" + url + "\";";
    js += "document.scripts[0].parentNode.insertBefore(newscript,document.scripts[0]);";
    view.loadUrl("javascript:" + js);
}
 
Example #13
Source File: X5WebViewClient.java    From YCWebView with Apache License 2.0 5 votes vote down vote up
/**
 * 回退操作
 * @param webView                           webView
 * @return
 */
public final boolean pageGoBack(@NonNull WebView webView) {
    //判断是否可以回退操作
    if (pageCanGoBack()) {
        //获取最后停留的页面url
        final String url = popBackUrl();
        //如果不为空
        if (!TextUtils.isEmpty(url)) {
            webView.loadUrl(url);
            return true;
        }
    }
    return false;
}
 
Example #14
Source File: X5WebViewClient.java    From YCWebView with Apache License 2.0 5 votes vote down vote up
/**
 * 通过js代码找到标签为img的代码块,设置点击的监听方法与本地的openImage方法进行连接
 * @param webView                       webview
 */
private void addImageClickListener(WebView webView) {
    webView.loadUrl("javascript:(function(){" +
            "var objs = document.getElementsByTagName(\"img\"); " +
            "for(var i=0;i<objs.length;i++)  " +
            "{"
            + "    objs[i].onclick=function()  " +
            "    {  "
            + "        window.imagelistener.openImage(this.src);  " +
            "    }  " +
            "}" +
            "})()");
}
 
Example #15
Source File: CBrowserMainFrame.java    From appcan-android with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void onProgressChanged(WebView view, int newProgress) {
    if (view != null) {
        EBrowserView target = (EBrowserView) view;
        EBrowserWindow bWindow = target.getBrowserWindow();
        if (bWindow != null) {
            bWindow.setGlobalProgress(newProgress);
            if (100 == newProgress) {
                bWindow.hiddenProgress();
            }
        }
    }
}
 
Example #16
Source File: X5WebChromeClient.java    From YCWebView with Apache License 2.0 5 votes vote down vote up
/**
 * 处理prompt弹出框
 * @param webView                           view
 * @param url                               url链接
 * @param message                           参数message:代表prompt()的内容(不是url)
 * @param defaultValue                      参数result:代表输入框的返回值
 * @param jsPromptResult                    jsPromptResult
 * @return
 */
@Override
public boolean onJsPrompt(WebView webView, String url, String message,
                          String defaultValue, JsPromptResult jsPromptResult) {
    //根据协议的参数,判断是否是所需要的url
    //假定传入进来的 message = "js://openActivity?arg1=111&arg2=222",代表需要打开本地页面,并且带入相应的参数
    //同时也是约定好的需要拦截的
    /*Uri uri = Uri.parse(message);
    String scheme = uri.getScheme();
    if ("js".equals(scheme)) {
        if (uri.getAuthority().equals("openActivity")) {
            HashMap<String, String> params = new HashMap<>();
            Set<String> collection = uri.getQueryParameterNames();
            for (String name : collection) {
                params.put(name, uri.getQueryParameter(name));
            }
            Intent intent = new Intent(webView.getContext(), MainActivity.class);
            intent.putExtra("params", params);
            webView.getContext().startActivity(intent);
            //代表应用内部处理完成
            jsPromptResult.confirm("success");
        } else if("demo".equals(uri.getAuthority()));{
            //代表应用内部处理完成
            jsPromptResult.confirm("js调用了Android的方法成功啦");
            return true;
        }
        return true;
    }*/
    return super.onJsPrompt(webView, url, message, defaultValue, jsPromptResult);
}
 
Example #17
Source File: X5WebViewEngine.java    From cordova-plugin-x5-webview with Apache License 2.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.KITKAT)
private void enableRemoteDebugging() {
    try {
        WebView.setWebContentsDebuggingEnabled(true);
    } catch (IllegalArgumentException e) {
        LOG.d(TAG, "You have one job! To turn on Remote Web Debugging! YOU HAVE FAILED! ");
        e.printStackTrace();
    }
}
 
Example #18
Source File: WrapperWebViewClient.java    From AgentWebX5 with Apache License 2.0 5 votes vote down vote up
public void onReceivedClientCertRequest(WebView view, ClientCertRequest request) {
    if(mWebViewClient!=null){
        mWebViewClient.onReceivedClientCertRequest(view,request);
        return;
    }
    super.onReceivedClientCertRequest(view,request);
}
 
Example #19
Source File: BridgeWebViewClient.java    From JsBridge with MIT License 5 votes vote down vote up
@Override
public void onReceivedHttpAuthRequest(WebView webView, HttpAuthHandler httpAuthHandler, String s, String s1) {
    boolean interrupt = false;
    if (bridgeWebViewClientListener != null) {
        interrupt = bridgeWebViewClientListener.onReceivedHttpAuthRequest(webView, httpAuthHandler, s, s1);
    }
    if (!interrupt) {
        super.onReceivedHttpAuthRequest(webView, httpAuthHandler, s, s1);
    }
}
 
Example #20
Source File: LoaderImpl.java    From AgentWebX5 with Apache License 2.0 5 votes vote down vote up
LoaderImpl(WebView webView, Map<String, String> map) {
    this.mWebView = webView;
    if (this.mWebView == null)
        new NullPointerException("webview is null");

    this.headers = map;
    mHandler = new Handler(Looper.getMainLooper());
}
 
Example #21
Source File: X5WebViewClient.java    From cordova-plugin-x5-webview with Apache License 2.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@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 (!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) || needsSpecialsInAssetUrlFix(origUri) || needsKitKatContentUrlFix(origUri)) {
            CordovaResourceApi.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);
    }
}
 
Example #22
Source File: X5WebViewClient.java    From YCWebView with Apache License 2.0 5 votes vote down vote up
/**
 * 构造方法
 * @param webView                           需要传进来webview
 * @param context                           上下文
 */
public X5WebViewClient(WebView webView ,Context context) {
    this.context = context;
    this.webView = webView;
    //将js对象与java对象进行映射
    //webView.addJavascriptInterface(new ImageJavascriptInterface(context), "imagelistener");
}
 
Example #23
Source File: X5WebViewClient.java    From YCWebView with Apache License 2.0 5 votes vote down vote up
/**
 * 通知主机应用程序在加载资源时从服务器接收到HTTP错误
 * @param view                              view
 * @param request                           request,添加于API21,封装了一个Web资源的请求信息,
 *                                          包含:请求地址,请求方法,请求头,是否主框架,是否用户点击,是否重定向
 * @param errorResponse                     errorResponse,封装了一个Web资源的响应信息,
 *                                          包含:响应数据流,编码,MIME类型,API21后添加了响应头,状态码与状态描述
 */
@Override
public void onReceivedHttpError(WebView view, WebResourceRequest request,
                                WebResourceResponse errorResponse) {
    super.onReceivedHttpError(view, request, errorResponse);
    int statusCode = errorResponse.getStatusCode();
    String reasonPhrase = errorResponse.getReasonPhrase();
    X5LogUtils.i("-------onReceivedHttpError-------"+ statusCode + "-------"+reasonPhrase);
    if (statusCode == 404) {
        //用javascript隐藏系统定义的404页面信息
        //String data = "Page NO FOUND!";
        //view.loadUrl("javascript:document.body.innerHTML=\"" + data + "\"");
        if (webListener!=null){
            webListener.showErrorView(X5WebUtils.ErrorMode.STATE_404);
        }
    } else if (statusCode == 500){
        //避免出现默认的错误界面
        //view.loadUrl("about:blank");
        if (webListener!=null){
            webListener.showErrorView(X5WebUtils.ErrorMode.STATE_500);
        }
    } else {
        if (webListener!=null){
            webListener.showErrorView(X5WebUtils.ErrorMode.RECEIVED_ERROR);
        }
    }
}
 
Example #24
Source File: X5WebViewEngine.java    From cordova-plugin-x5-webview with Apache License 2.0 5 votes vote down vote up
private static void exposeJsInterface(WebView webView, CordovaBridge bridge) {
    if ((Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1)) {
        LOG.i(TAG, "Disabled addJavascriptInterface() bridge since Android version is old.");
        // Bug being that Java Strings do not get converted to JS strings automatically.
        // This isn't hard to work-around on the JS side, but it's easier to just
        // use the prompt bridge instead.
        return;
    }
    X5ExposedJsApi exposedJsApi = new X5ExposedJsApi(bridge);
    webView.addJavascriptInterface(exposedJsApi, "_cordovaNative");
}
 
Example #25
Source File: MyTestActivity.java    From AndroidFrame with Apache License 2.0 5 votes vote down vote up
@Override
public void onReceivedTitle(WebView webView, String s) {
    String js = "javascript:var evt1 = document.createEvent('Event');"
            + "evt1.initEvent('AndroidJavascriptBridgeReady', false, false);";
    if (android.os.Build.VERSION.SDK_INT <= 18) {
        mWebview.loadUrl(js);
    } else {
        mWebview.evaluateJavascript(js, null);
    }
}
 
Example #26
Source File: RNX5WebViewManager.java    From react-native-x5 with MIT License 5 votes vote down vote up
@ReactProp(name = "onContentSizeChange")
public void setOnContentSizeChange(WebView view, boolean sendContentSizeChangeEvents) {
    if (sendContentSizeChangeEvents) {
        view.setPictureListener(getPictureListener());
    } else {
        view.setPictureListener(null);
    }
}
 
Example #27
Source File: DefaultWebCreator.java    From AgentWebX5 with Apache License 2.0 5 votes vote down vote up
private ViewGroup createGroupWithWeb() {
        Activity mActivity = this.mActivity;

        FrameLayout mFrameLayout = new FrameLayout(mActivity);
        mFrameLayout.setBackgroundColor(Color.WHITE);
        com.tencent.smtt.sdk.WebView mWebView = null;
        View target=mIWebLayout==null?(this.mWebView= (WebView) web()):webLayout();
        FrameLayout.LayoutParams mLayoutParams = new FrameLayout.LayoutParams(-1, -1);
        mFrameLayout.addView(target, mLayoutParams);
        if (isNeedDefaultProgress) {
            FrameLayout.LayoutParams lp = null;
            WebProgress mWebProgress = new WebProgress(mActivity);
            if (height_dp > 0)
                lp = new FrameLayout.LayoutParams(-2, AgentWebX5Utils.dp2px(mActivity, height_dp));
            else
                lp = mWebProgress.offerLayoutParams();
            if (color != -1)
                mWebProgress.setColor(color);
            lp.gravity = Gravity.TOP;
            mFrameLayout.addView((View) (this.mBaseProgressSpec = mWebProgress), lp);
            mWebProgress.setVisibility(View.GONE);
        } else if (!isNeedDefaultProgress && progressView != null) {
//            FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(-2, -2);
            mFrameLayout.addView((View) (this.mBaseProgressSpec = (BaseProgressSpec) progressView), progressView.offerLayoutParams());
        }
        return this.mFrameLayout=mFrameLayout;

    }
 
Example #28
Source File: BridgeWebViewClient.java    From JsBridge with MIT License 5 votes vote down vote up
@Override
public WebResourceResponse shouldInterceptRequest(WebView webView, String s) {
    if (bridgeWebViewClientListener != null) {
        return bridgeWebViewClientListener.shouldInterceptRequest(webView, s);
    } else {
        return super.shouldInterceptRequest(webView, s);
    }
}
 
Example #29
Source File: X5CookieManager.java    From cordova-plugin-x5-webview with Apache License 2.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public X5CookieManager(WebView webview) {
    webView = webview;
    cookieManager = CookieManager.getInstance();

    //REALLY? Nobody has seen this UNTIL NOW?
    // Instead of android.webkit.CookieManager.setAcceptFileSchemeCookies
    cookieManager.setAcceptCookie(true);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        cookieManager.setAcceptThirdPartyCookies(webView, true);
    }
}
 
Example #30
Source File: X5WebViewClient.java    From AndroidHybridLib with Apache License 2.0 5 votes vote down vote up
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {
    if (null != request) {
        WebResourceResponse localResource = mWebViewClientPresenter.shouldInterceptRequest(request.getUrl());
        // 不为空,则拦截
        if (null != localResource) {
            return localResource;
        }
    }
    return super.shouldInterceptRequest(view, request);
}