diff --git a/app/src/webview/java/org/mozilla/focus/webview/TrackingProtectionWebViewClient.java b/app/src/webview/java/org/mozilla/focus/webview/TrackingProtectionWebViewClient.java index f675eb6a70..8854f1ff00 100644 --- a/app/src/webview/java/org/mozilla/focus/webview/TrackingProtectionWebViewClient.java +++ b/app/src/webview/java/org/mozilla/focus/webview/TrackingProtectionWebViewClient.java @@ -102,19 +102,20 @@ public AmazonWebResourceResponse shouldInterceptRequest(final AmazonWebView view return new AmazonWebResourceResponse(null, null, null); } - final UrlMatcher matcher = getMatcher(view.getContext()); + final UrlMatcher blockedSiteMatcher = getMatcher(view.getContext()); // Don't block the main frame from being loaded. This also protects against cases where we // open a link that redirects to another app (e.g. to the play store). - final Uri pageUri = Uri.parse(currentPageURL); - -// if ((!request.isForMainFrame()) && -// matcher.matches(resourceUri, pageUri)) { -// if (callback != null) { -// callback.countBlockedTracker(); -// } -// return new AmazonWebResourceResponse(null, null, null); -// } + final Uri currentPageUri = Uri.parse(currentPageURL); + + // Matches is true if the resourceUri is on the blocklist and is not a first party request. + // The matcher code could be better named to make this apparent. + if (blockedSiteMatcher.matches(resourceUri, currentPageUri)) { + if (callback != null) { + callback.countBlockedTracker(); + } + return new AmazonWebResourceResponse(null, null, null); + } return super.shouldInterceptRequest(view, request); }