Project

General

Profile

Issue #1101 ยป tab.patch

Robert Schultz, 11/25/2014 04:54 PM

View differences:

Tab-new.java 2014-11-25 17:42:15.753684970 +0100
623 623
            mWebViewController.onReceivedHttpAuthRequest(Tab.this, view, handler, host, realm);
624 624
        }
625 625

  
626
        @Override
626
        protected boolean isBlockedSite(Uri uri) {
627
            String host = uri.getHost();
628
            String[] blockedSites = {"2mdn.net", "doubleclick.net",
629
                        "admeld.com",
630
                        "admob.com"
631
                };
632

  
633
            for (String sites : blockedSites) {
634
                for (String site : sites.split(" ")) {
635
                    if (host.toLowerCase().endsWith(site.toLowerCase())) { return true; }
636
                }
637
            }
638
            return false;
639
        }
640

  
641

  
642
         @Override
627 643
        public WebResourceResponse shouldInterceptRequest(WebView view,
628 644
                String url) {
645

  
646
            if (!url.startsWith("data:") && (isBlockedSite(Uri.parse(url)))) {
647
                    Uri uri2 = Uri.parse(url);
648
                    return new WebResourceResponse("text/plain", "utf-8",
649
                    new ByteArrayInputStream(("[The following URL was blocked " + uri2.getHost() + "]").getBytes()));
650
            }
651

  
629 652
            WebResourceResponse res = HomeProvider.shouldInterceptRequest(
630 653
                    mContext, url);
631 654
            return res;
    (1-1/1)