X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Fhelpers%2FBlockListHelper.java;h=2adfb6f7bd5f7e771c2828387205573288d43d84;hp=62ca537af240763cbcefcccab9ff1d1bd1e9b510;hb=f6538f0acbc299014c5128a29c5def62aee153a5;hpb=49e94a767e452d451a722bbb068e46458e404ed9 diff --git a/app/src/main/java/com/stoutner/privacybrowser/helpers/BlockListHelper.java b/app/src/main/java/com/stoutner/privacybrowser/helpers/BlockListHelper.java index 62ca537a..2adfb6f7 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/helpers/BlockListHelper.java +++ b/app/src/main/java/com/stoutner/privacybrowser/helpers/BlockListHelper.java @@ -21,46 +21,46 @@ package com.stoutner.privacybrowser.helpers; import android.content.res.AssetManager; import android.net.Uri; -import android.util.Log; + +import com.stoutner.privacybrowser.activities.MainWebViewActivity; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; -import java.util.LinkedList; import java.util.List; import java.util.regex.Pattern; public class BlockListHelper { public ArrayList> parseBlockList(AssetManager assets, String blockListName) { // Initialize the header list. - List headers = new LinkedList<>(); - - // Initialize the white lists. - List mainWhiteList = new LinkedList<>(); - List finalWhiteList = new LinkedList<>(); - List domainWhiteList = new LinkedList<>(); - List domainInitialWhiteList = new LinkedList<>(); - List domainFinalWhiteList = new LinkedList<>(); - List thirdPartyWhiteList = new LinkedList<>(); - List thirdPartyDomainWhiteList = new LinkedList<>(); - List thirdPartyDomainInitialWhiteList = new LinkedList<>(); - - // Initialize the black lists - List mainBlackList = new LinkedList<>(); - List initialBlackList = new LinkedList<>(); - List finalBlackList = new LinkedList<>(); - List domainBlackList = new LinkedList<>(); - List domainInitialBlackList = new LinkedList<>(); - List domainFinalBlackList = new LinkedList<>(); - List thirdPartyBlackList = new LinkedList<>(); - List thirdPartyInitialBlackList = new LinkedList<>(); - List thirdPartyDomainBlackList = new LinkedList<>(); - List thirdPartyDomainInitialBlackList = new LinkedList<>(); - List regularExpressionBlackList = new LinkedList<>(); - List domainRegularExpressionBlackList = new LinkedList<>(); - List thirdPartyRegularExpressionBlackList = new LinkedList<>(); - List thirdPartyDomainRegularExpressionBlackList = new LinkedList<>(); + List headers = new ArrayList<>(); // 0. + + // Initialize the whitelists. + List mainWhiteList = new ArrayList<>(); // 1. + List finalWhiteList = new ArrayList<>(); // 2. + List domainWhiteList = new ArrayList<>(); // 3. + List domainInitialWhiteList = new ArrayList<>(); // 4. + List domainFinalWhiteList = new ArrayList<>(); // 5. + List thirdPartyWhiteList = new ArrayList<>(); // 6. + List thirdPartyDomainWhiteList = new ArrayList<>(); // 7. + List thirdPartyDomainInitialWhiteList = new ArrayList<>(); // 8. + + // Initialize the blacklists + List mainBlackList = new ArrayList<>(); // 9. + List initialBlackList = new ArrayList<>(); // 10. + List finalBlackList = new ArrayList<>(); // 11. + List domainBlackList = new ArrayList<>(); // 12. + List domainInitialBlackList = new ArrayList<>(); // 13. + List domainFinalBlackList = new ArrayList<>(); // 14. + List domainRegularExpressionBlackList = new ArrayList<>(); // 15. + List thirdPartyBlackList = new ArrayList<>(); // 16. + List thirdPartyInitialBlackList = new ArrayList<>(); // 17. + List thirdPartyDomainBlackList = new ArrayList<>(); // 18. + List thirdPartyDomainInitialBlackList = new ArrayList<>(); // 19. + List regularExpressionBlackList = new ArrayList<>(); // 20. + List thirdPartyRegularExpressionBlackList = new ArrayList<>(); // 21. + List thirdPartyDomainRegularExpressionBlackList = new ArrayList<>(); // 22. // Populate the block lists. The `try` is required by `InputStreamReader`. @@ -73,6 +73,7 @@ public class BlockListHelper { // Parse the block list. while ((blockListEntry = bufferedReader.readLine()) != null) { + // Store the original block list entry. String originalBlockListEntry = blockListEntry; // Remove any `^` from the block list entry. Privacy Browser does not process them in the interest of efficiency. @@ -84,6 +85,11 @@ public class BlockListHelper { // Do nothing. Privacy Browser does not currently use these entries. //Log.i("BlockLists", "Not added: " + blockListEntry); + } else //noinspection StatementWithEmptyBody + if (blockListEntry.contains("$csp=script-src")) { // Ignore entries that contain `$csp=script-src`. + // Do nothing. It is uncertain what this directive is even supposed to mean, and it is blocking entire websites like androidcentral.com. https://redmine.stoutner.com/issues/306. + + //Log.i("BlockLists", headers.get(1)[0] + " not added: " + originalBlockListEntry); } else if (blockListEntry.startsWith("!")) { // Comment entries. if (blockListEntry.startsWith("! Version:")) { // Get the list version number. @@ -163,7 +169,7 @@ public class BlockListHelper { String secondEntry = entry.substring(wildcardIndex + 1); // Create an entry string array. - String[] domainDoubleEntry = {domain, firstEntry, secondEntry}; + String[] domainDoubleEntry = {domain, firstEntry, secondEntry, originalBlockListEntry}; // Add the entry to the white list. thirdPartyDomainInitialWhiteList.add(domainDoubleEntry); @@ -172,7 +178,7 @@ public class BlockListHelper { // " - " + originalBlockListEntry); } else { // Process a third-party domain initial white list single entry. // Create a domain entry string array. - String[] domainEntry = {domain, entry}; + String[] domainEntry = {domain, entry, originalBlockListEntry}; // Add the entry to the third party domain initial white list. thirdPartyDomainInitialWhiteList.add(domainEntry); @@ -211,7 +217,7 @@ public class BlockListHelper { String secondEntry = entry.substring(wildcardIndex + 1); // Create an entry string array. - String[] domainDoubleEntry = {domain, firstEntry, secondEntry}; + String[] domainDoubleEntry = {domain, firstEntry, secondEntry, originalBlockListEntry}; // Add the entry to the white list. thirdPartyDomainWhiteList.add(domainDoubleEntry); @@ -220,7 +226,7 @@ public class BlockListHelper { // originalBlockListEntry); } else { // Process a third-party domain single entry. // Create an entry string array. - String[] domainEntry = {domain, entry}; + String[] domainEntry = {domain, entry, originalBlockListEntry}; // Add the entry to the white list. thirdPartyDomainWhiteList.add(domainEntry); @@ -266,7 +272,7 @@ public class BlockListHelper { String fifthEntry = fourthEntry.substring(fourthWildcardIndex + 1); // Create an entry string array. - String[] quintupleEntry = {firstEntry, realSecondEntry, realThirdEntry, realFourthEntry, fifthEntry}; + String[] quintupleEntry = {firstEntry, realSecondEntry, realThirdEntry, realFourthEntry, fifthEntry, originalBlockListEntry}; // Add the entry to the white list. thirdPartyWhiteList.add(quintupleEntry); @@ -275,7 +281,7 @@ public class BlockListHelper { // realFourthEntry + " , " + fifthEntry + " - " + originalBlockListEntry); } else { // Process a third-party white list quadruple entry. // Create an entry string array. - String[] quadrupleEntry = {firstEntry, realSecondEntry, realThirdEntry, fourthEntry}; + String[] quadrupleEntry = {firstEntry, realSecondEntry, realThirdEntry, fourthEntry, originalBlockListEntry}; // Add the entry to the white list. thirdPartyWhiteList.add(quadrupleEntry); @@ -285,7 +291,7 @@ public class BlockListHelper { } } else { // Process a third-party white list triple entry. // Create an entry string array. - String[] tripleEntry = {firstEntry, realSecondEntry, thirdEntry}; + String[] tripleEntry = {firstEntry, realSecondEntry, thirdEntry, originalBlockListEntry}; // Add the entry to the white list. thirdPartyWhiteList.add(tripleEntry); @@ -295,7 +301,7 @@ public class BlockListHelper { } } else { // Process a third-party white list double entry. // Create an entry string array. - String[] doubleEntry = {firstEntry, secondEntry}; + String[] doubleEntry = {firstEntry, secondEntry, originalBlockListEntry}; // Add the entry to the white list. thirdPartyWhiteList.add(doubleEntry); @@ -304,7 +310,7 @@ public class BlockListHelper { } } else { // Process a third-party white list single entry. // Create an entry string array. - String[] singleEntry = {entry}; + String[] singleEntry = {entry, originalBlockListEntry}; // Add the entry to the white list. thirdPartyWhiteList.add(singleEntry); @@ -360,7 +366,7 @@ public class BlockListHelper { String thirdEntry = secondEntry.substring(secondWildcardIndex + 1); // Create an entry string array. - String[] domainTripleEntry = {domain, firstEntry, realSecondEntry, thirdEntry}; + String[] domainTripleEntry = {domain, firstEntry, realSecondEntry, thirdEntry, originalBlockListEntry}; // Add the entry to the white list. domainInitialWhiteList.add(domainTripleEntry); @@ -369,7 +375,7 @@ public class BlockListHelper { // thirdEntry + " - " + originalBlockListEntry); } else { // Process a domain initial double entry. // Create an entry string array. - String[] domainDoubleEntry = {domain, firstEntry, secondEntry}; + String[] domainDoubleEntry = {domain, firstEntry, secondEntry, originalBlockListEntry}; // Add the entry to the white list. domainInitialWhiteList.add(domainDoubleEntry); @@ -379,7 +385,7 @@ public class BlockListHelper { } } else { // Process a domain initial single entry. // Create an entry string array. - String[] domainEntry = {domain, entry}; + String[] domainEntry = {domain, entry, originalBlockListEntry}; // Add the entry to the white list. domainInitialWhiteList.add(domainEntry); @@ -416,7 +422,7 @@ public class BlockListHelper { String secondEntry = entry.substring(wildcardIndex + 1); // Create an entry string array. - String[] domainDoubleEntry = {domain, firstEntry, secondEntry}; + String[] domainDoubleEntry = {domain, firstEntry, secondEntry, originalBlockListEntry}; // Add the entry to the white list. domainFinalWhiteList.add(domainDoubleEntry); @@ -425,7 +431,7 @@ public class BlockListHelper { // originalBlockListEntry); } else { // Process a domain final white list single entry. // create an entry string array. - String[] domainEntry = {domain, entry}; + String[] domainEntry = {domain, entry, originalBlockListEntry}; // Add the entry to the white list. domainFinalWhiteList.add(domainEntry); @@ -481,7 +487,7 @@ public class BlockListHelper { String fourthEntry = thirdEntry.substring(thirdWildcardIndex + 1); // Create an entry string array. - String[] domainQuadrupleEntry = {domain, firstEntry, realSecondEntry, realThirdEntry, fourthEntry}; + String[] domainQuadrupleEntry = {domain, firstEntry, realSecondEntry, realThirdEntry, fourthEntry, originalBlockListEntry}; // Add the entry to the white list. domainWhiteList.add(domainQuadrupleEntry); @@ -490,7 +496,7 @@ public class BlockListHelper { // realThirdEntry + " , " + fourthEntry + " - " + originalBlockListEntry); } else { // Process a domain white list triple entry. // Create an entry string array. - String[] domainTripleEntry = {domain, firstEntry, realSecondEntry, thirdEntry}; + String[] domainTripleEntry = {domain, firstEntry, realSecondEntry, thirdEntry, originalBlockListEntry}; // Add the entry to the white list. domainWhiteList.add(domainTripleEntry); @@ -500,7 +506,7 @@ public class BlockListHelper { } } else { // Process a domain white list double entry. // Create an entry string array. - String[] domainDoubleEntry = {domain, firstEntry, secondEntry}; + String[] domainDoubleEntry = {domain, firstEntry, secondEntry, originalBlockListEntry}; // Add the entry to the white list. domainWhiteList.add(domainDoubleEntry); @@ -510,7 +516,7 @@ public class BlockListHelper { } } else { // Process a domain white list single entry. // Create an entry string array. - String[] domainEntry = {domain, entry}; + String[] domainEntry = {domain, entry, originalBlockListEntry}; // Add the entry to the white list. domainWhiteList.add(domainEntry); @@ -534,7 +540,7 @@ public class BlockListHelper { String secondEntry = entry.substring(wildcardIndex + 1); // Create an entry string array. - String[] doubleEntry = {firstEntry, secondEntry}; + String[] doubleEntry = {firstEntry, secondEntry, originalBlockListEntry}; // Add the entry to the white list. finalWhiteList.add(doubleEntry); @@ -542,7 +548,7 @@ public class BlockListHelper { //Log.i("BlockLists", headers.get(1)[0] + " final white list added: " + firstEntry + " , " + secondEntry + " - " + originalBlockListEntry); } else { // Process a final white list single entry. // Create an entry string array. - String[] singleEntry = {entry}; + String[] singleEntry = {entry, originalBlockListEntry}; // Add the entry to the white list. finalWhiteList.add(singleEntry); @@ -567,7 +573,7 @@ public class BlockListHelper { String thirdEntry = secondEntry.substring(secondWildcardIndex + 1); // Create an entry string array. - String[] tripleEntry = {firstEntry, realSecondEntry, thirdEntry}; + String[] tripleEntry = {firstEntry, realSecondEntry, thirdEntry, originalBlockListEntry}; // Add the entry to the white list. mainWhiteList.add(tripleEntry); @@ -575,7 +581,7 @@ public class BlockListHelper { //Log.i("BlockLists", headers.get(1)[0] + " main white list added: " + firstEntry + " , " + realSecondEntry + " , " + thirdEntry + " - " + originalBlockListEntry); } else { // Process a main white list double entry. // Create an entry string array. - String[] doubleEntry = {firstEntry, secondEntry}; + String[] doubleEntry = {firstEntry, secondEntry, originalBlockListEntry}; // Add the entry to the white list. mainWhiteList.add(doubleEntry); @@ -584,7 +590,7 @@ public class BlockListHelper { } } else { // Process a main white list single entry. // Create an entry string array. - String[] singleEntry = {blockListEntry}; + String[] singleEntry = {blockListEntry, originalBlockListEntry}; // Add the entry to the white list. mainWhiteList.add(singleEntry); @@ -610,7 +616,7 @@ public class BlockListHelper { String secondEntry = entry.substring(wildcardIndex + 1); // Create an entry string array. - String[] doubleEntry = {firstEntry, secondEntry}; + String[] doubleEntry = {firstEntry, secondEntry, originalBlockListEntry}; // Add the entry to the black list. finalBlackList.add(doubleEntry); @@ -618,7 +624,7 @@ public class BlockListHelper { //Log.i("BlockLists", headers.get(1)[0] + " final black list added: " + firstEntry + " , " + secondEntry + " - " + originalBlockListEntry); } else { // Process a final black list single entry. // create an entry string array. - String[] singleEntry = {entry}; + String[] singleEntry = {entry, originalBlockListEntry}; // Add the entry to the black list. finalBlackList.add(singleEntry); @@ -686,7 +692,7 @@ public class BlockListHelper { String thirdEntry = secondEntry.substring(secondWildcardIndex + 1); // Create an entry string array. - String[] tripleDomainEntry = {domain, firstEntry, realSecondEntry, thirdEntry}; + String[] tripleDomainEntry = {domain, firstEntry, realSecondEntry, thirdEntry, originalBlockListEntry}; // Add the entry to the black list. thirdPartyDomainInitialBlackList.add(tripleDomainEntry); @@ -695,7 +701,7 @@ public class BlockListHelper { // " , " + thirdEntry + " - " + originalBlockListEntry); } else { // Process a third-party domain initial black list double entry. // Create an entry string array. - String[] doubleDomainEntry = {domain, firstEntry, secondEntry}; + String[] doubleDomainEntry = {domain, firstEntry, secondEntry, originalBlockListEntry}; // Add the entry to the black list. thirdPartyDomainInitialBlackList.add(doubleDomainEntry); @@ -705,7 +711,7 @@ public class BlockListHelper { } } else { // Process a third-party domain initial black list single entry. // Create an entry string array. - String[] singleEntry = {domain, entry}; + String[] singleEntry = {domain, entry, originalBlockListEntry}; // Add the entry to the black list. thirdPartyDomainInitialBlackList.add(singleEntry); @@ -736,7 +742,7 @@ public class BlockListHelper { } // Create an entry string array. - String[] domainEntry = {domain, entry}; + String[] domainEntry = {domain, entry, originalBlockListEntry}; // Add the entry to the black list. thirdPartyDomainRegularExpressionBlackList.add(domainEntry); @@ -789,7 +795,7 @@ public class BlockListHelper { String secondEntry = entry.substring(wildcardIndex + 1); // Create an entry string array. - String[] domainDoubleEntry = {domain, firstEntry, secondEntry}; + String[] domainDoubleEntry = {domain, firstEntry, secondEntry, originalBlockListEntry}; // Add the entry to the white list. thirdPartyDomainWhiteList.add(domainDoubleEntry); @@ -798,7 +804,7 @@ public class BlockListHelper { // originalBlockListEntry); } else { // Process a third-party domain white list single entry. // Create an entry string array. - String[] domainEntry = {domain, entry}; + String[] domainEntry = {domain, entry, originalBlockListEntry}; // Add the entry to the white list. thirdPartyDomainWhiteList.add(domainEntry); @@ -815,7 +821,7 @@ public class BlockListHelper { String secondEntry = entry.substring(wildcardIndex + 1); // Create an entry string array. - String[] domainDoubleEntry = {domain, firstEntry, secondEntry}; + String[] domainDoubleEntry = {domain, firstEntry, secondEntry, originalBlockListEntry}; // Add the entry to the black list thirdPartyDomainBlackList.add(domainDoubleEntry); @@ -824,7 +830,7 @@ public class BlockListHelper { // originalBlockListEntry); } else { // Process a third-party domain black list single entry. // Create an entry string array. - String[] domainEntry = {domain, entry}; + String[] domainEntry = {domain, entry, originalBlockListEntry}; // Add the entry to the black list. thirdPartyDomainBlackList.add(domainEntry); @@ -845,7 +851,7 @@ public class BlockListHelper { String secondEntry = entry.substring(wildcardIndex + 1); // Create an entry string array. - String[] doubleEntry = {firstEntry, secondEntry}; + String[] doubleEntry = {firstEntry, secondEntry, originalBlockListEntry}; // Add the entry to the black list. thirdPartyBlackList.add(doubleEntry); @@ -853,7 +859,7 @@ public class BlockListHelper { //Log.i("BlockLists", headers.get(1)[0] + " third-party black list added: " + firstEntry + " , " + secondEntry + " - " + originalBlockListEntry); } else { // Process a third-party black list single entry. // Create an entry string array. - String[] singleEntry = {entry}; + String[] singleEntry = {entry, originalBlockListEntry}; // Add an entry to the black list. thirdPartyBlackList.add(singleEntry); @@ -878,7 +884,7 @@ public class BlockListHelper { String secondEntry = entry.substring(wildcardIndex + 1); // Create an entry string array. - String[] thirdPartyDoubleEntry = {firstEntry, secondEntry}; + String[] thirdPartyDoubleEntry = {firstEntry, secondEntry, originalBlockListEntry}; // Add the entry to the black list. thirdPartyInitialBlackList.add(thirdPartyDoubleEntry); @@ -886,7 +892,7 @@ public class BlockListHelper { //Log.i("BlockLists", headers.get(1)[0] + " third-party initial black list added: " + firstEntry + " , " + secondEntry + " - " + originalBlockListEntry); } else { // Process a third-party initial black list single entry. // Create an entry string array. - String[] singleEntry = {entry}; + String[] singleEntry = {entry, originalBlockListEntry}; // Add the entry to the black list. thirdPartyInitialBlackList.add(singleEntry); @@ -905,7 +911,7 @@ public class BlockListHelper { } // Create an entry string array. - String[] singleEntry = {entry}; + String[] singleEntry = {entry, originalBlockListEntry}; // Add the entry to the black list. thirdPartyRegularExpressionBlackList.add(singleEntry); @@ -920,7 +926,7 @@ public class BlockListHelper { entry = entry.substring(0, entry.length() - 1); // Create an entry string array. - String[] singleEntry = {entry}; + String[] singleEntry = {entry, originalBlockListEntry}; // Add the entry to the black list. thirdPartyBlackList.add(singleEntry); @@ -951,7 +957,7 @@ public class BlockListHelper { String fourthEntry = thirdEntry.substring(thirdWildcardIndex + 1); // Create an entry string array. - String[] quadrupleEntry = {firstEntry, realSecondEntry, realThirdEntry, fourthEntry}; + String[] quadrupleEntry = {firstEntry, realSecondEntry, realThirdEntry, fourthEntry, originalBlockListEntry}; // Add the entry to the black list. thirdPartyBlackList.add(quadrupleEntry); @@ -960,7 +966,7 @@ public class BlockListHelper { // fourthEntry + " - " + originalBlockListEntry); } else { // Process a third-party black list triple entry. // Create an entry string array. - String[] tripleEntry = {firstEntry, realSecondEntry, thirdEntry}; + String[] tripleEntry = {firstEntry, realSecondEntry, thirdEntry, originalBlockListEntry}; // Add the entry to the black list. thirdPartyBlackList.add(tripleEntry); @@ -970,7 +976,7 @@ public class BlockListHelper { } } else { // Process a third-party black list double entry. // Create an entry string array. - String[] doubleEntry = {firstEntry, secondEntry}; + String[] doubleEntry = {firstEntry, secondEntry, originalBlockListEntry}; // Add the entry to the black list. thirdPartyBlackList.add(doubleEntry); @@ -983,7 +989,7 @@ public class BlockListHelper { String entry = blockListEntry.substring(0, blockListEntry.indexOf("$")); // Create an entry string array. - String[] singleEntry = {entry}; + String[] singleEntry = {entry, originalBlockListEntry}; // Add the entry to the black list. thirdPartyBlackList.add(singleEntry); @@ -1037,7 +1043,7 @@ public class BlockListHelper { String thirdEntry = secondEntry.substring((secondWildcardIndex + 1)); // Create an entry string array. - String[] domainTripleEntry = {domain, firstEntry, realSecondEntry, thirdEntry}; + String[] domainTripleEntry = {domain, firstEntry, realSecondEntry, thirdEntry, originalBlockListEntry}; // Add the entry to the white list. domainWhiteList.add(domainTripleEntry); @@ -1046,7 +1052,7 @@ public class BlockListHelper { // " - " + originalBlockListEntry); } else { // Process a domain white list double entry. // Create an entry string array. - String[] domainDoubleEntry = {domain, firstEntry, secondEntry}; + String[] domainDoubleEntry = {domain, firstEntry, secondEntry, originalBlockListEntry}; // Add the entry to the white list. domainWhiteList.add(domainDoubleEntry); @@ -1055,7 +1061,7 @@ public class BlockListHelper { } } else { // Process a domain white list single entry. // Create an entry string array. - String[] domainEntry = {domain, entry}; + String[] domainEntry = {domain, entry, originalBlockListEntry}; // Add the entry to the white list. domainWhiteList.add(domainEntry); @@ -1098,7 +1104,7 @@ public class BlockListHelper { //Log.i("BlockLists", headers.get(1)[0] + " not added: " + originalBlockListEntry); } else { // Process a domain initial black list entry // Create an entry string array. - String[] domainEntry = {domain, entryBase}; + String[] domainEntry = {domain, entryBase, originalBlockListEntry}; // Add the entry to the black list. domainInitialBlackList.add(domainEntry); @@ -1118,7 +1124,7 @@ public class BlockListHelper { String secondEntry = entryBase.substring(wildcardIndex + 1); // Create an entry string array. - String[] domainDoubleEntry = {domain, firstEntry, secondEntry}; + String[] domainDoubleEntry = {domain, firstEntry, secondEntry, originalBlockListEntry}; // Add the entry to the black list. domainFinalBlackList.add(domainDoubleEntry); @@ -1127,7 +1133,7 @@ public class BlockListHelper { // originalBlockListEntry); } else { // Process a domain final black list single entry. // Create an entry string array. - String[] domainEntry = {domain, entryBase}; + String[] domainEntry = {domain, entryBase, originalBlockListEntry}; // Add the entry to the black list. domainFinalBlackList.add(domainEntry); @@ -1136,7 +1142,7 @@ public class BlockListHelper { } } else if (entry.contains("\\")) { // Process a domain regular expression black list entry. // Create an entry string array. - String[] domainEntry = {domain, entry}; + String[] domainEntry = {domain, entry, originalBlockListEntry}; // Add the entry to the black list. domainRegularExpressionBlackList.add(domainEntry); @@ -1159,7 +1165,7 @@ public class BlockListHelper { String thirdEntry = secondEntry.substring(secondWildcardIndex + 1); // Create an entry string array. - String[] domainTripleEntry = {domain, firstEntry, realSecondEntry, thirdEntry}; + String[] domainTripleEntry = {domain, firstEntry, realSecondEntry, thirdEntry, originalBlockListEntry}; // Add the entry to the black list. domainBlackList.add(domainTripleEntry); @@ -1168,7 +1174,7 @@ public class BlockListHelper { // " - " + originalBlockListEntry); } else { // Process a domain black list double entry. // Create an entry string array. - String[] domainDoubleEntry = {domain, firstEntry, secondEntry}; + String[] domainDoubleEntry = {domain, firstEntry, secondEntry, originalBlockListEntry}; // Add the entry to the black list. domainBlackList.add(domainDoubleEntry); @@ -1178,7 +1184,7 @@ public class BlockListHelper { } } else { // Process a domain black list single entry. // Create an entry string array. - String[] domainEntry = {domain, entry}; + String[] domainEntry = {domain, entry, originalBlockListEntry}; // Add the entry to the black list. domainBlackList.add(domainEntry); @@ -1206,7 +1212,7 @@ public class BlockListHelper { String secondEntry = blockListEntry.substring(wildcardIndex + 1); // Create an entry string array. - String[] doubleEntry = {firstEntry, secondEntry}; + String[] doubleEntry = {firstEntry, secondEntry, originalBlockListEntry}; // Add the entry to the white list. mainWhiteList.add(doubleEntry); @@ -1214,7 +1220,7 @@ public class BlockListHelper { //Log.i("BlockLists", headers.get(1)[0] + " main white list added: " + firstEntry + " , " + secondEntry + " - " + originalBlockListEntry); } else { // Process a white list single entry. // Create an entry string array. - String[] singleEntry = {blockListEntry}; + String[] singleEntry = {blockListEntry, originalBlockListEntry}; // Add the entry to the white list. mainWhiteList.add(singleEntry); @@ -1226,7 +1232,7 @@ public class BlockListHelper { blockListEntry = blockListEntry.substring(0, blockListEntry.indexOf("$")); // Create an entry string array. - String[] singleEntry = {blockListEntry}; + String[] singleEntry = {blockListEntry, originalBlockListEntry}; // Add the entry to the black list. regularExpressionBlackList.add(singleEntry); @@ -1256,7 +1262,7 @@ public class BlockListHelper { String secondEntry = entry.substring(wildcardIndex + 1); // Create an entry string array. - String[] doubleEntry = {firstEntry, secondEntry}; + String[] doubleEntry = {firstEntry, secondEntry, originalBlockListEntry}; // Add the entry to the black list. initialBlackList.add(doubleEntry); @@ -1264,7 +1270,7 @@ public class BlockListHelper { //Log.i("BlockLists", headers.get(1)[0] + " initial black list added: " + firstEntry + " , " + secondEntry + " - " + originalBlockListEntry); } else { // Process an initial black list single entry. // Create an entry string array. - String[] singleEntry = {entry}; + String[] singleEntry = {entry, originalBlockListEntry}; // Add the entry to the black list. initialBlackList.add(singleEntry); @@ -1294,7 +1300,7 @@ public class BlockListHelper { String thirdEntry = secondEntry.substring(secondWildcardIndex + 1); // Create an entry string array. - String[] tripleEntry = {firstEntry, realSecondEntry, thirdEntry}; + String[] tripleEntry = {firstEntry, realSecondEntry, thirdEntry, originalBlockListEntry}; // Add the entry to the black list. finalBlackList.add(tripleEntry); @@ -1303,7 +1309,7 @@ public class BlockListHelper { // originalBlockListEntry); } else { // Process a final black list double entry. // Create an entry string array. - String[] doubleEntry = {firstEntry, secondEntry}; + String[] doubleEntry = {firstEntry, secondEntry, originalBlockListEntry}; // Add the entry to the black list. finalBlackList.add(doubleEntry); @@ -1312,7 +1318,7 @@ public class BlockListHelper { } } else { // Process a final black list single entry. // Create an entry sting array. - String[] singleEntry = {entry}; + String[] singleEntry = {entry, originalBlockListEntry}; // Add the entry to the black list. finalBlackList.add(singleEntry); @@ -1337,7 +1343,7 @@ public class BlockListHelper { String thirdEntry = secondEntry.substring(secondWildcardIndex + 1); // Create an entry string array. - String[] tripleEntry = {firstEntry, realSecondEntry, thirdEntry}; + String[] tripleEntry = {firstEntry, realSecondEntry, thirdEntry, originalBlockListEntry}; // Add the entry to the black list. mainBlackList.add(tripleEntry); @@ -1345,7 +1351,7 @@ public class BlockListHelper { //Log.i("BlockLists", headers.get(1)[0] + " main black list added: " + firstEntry + " , " + realSecondEntry + " , " + thirdEntry + " - " + originalBlockListEntry); } else { // Process a main black list double entry. // Create an entry string array. - String[] doubleEntry = {firstEntry, secondEntry}; + String[] doubleEntry = {firstEntry, secondEntry, originalBlockListEntry}; // Add the entry to the black list. mainBlackList.add(doubleEntry); @@ -1354,7 +1360,7 @@ public class BlockListHelper { } } else { // Process a main black list single entry. // Create an entry string array. - String[] singleEntry = {blockListEntry}; + String[] singleEntry = {blockListEntry, originalBlockListEntry}; // Add the entry to the black list. mainBlackList.add(singleEntry); @@ -1391,7 +1397,7 @@ public class BlockListHelper { String secondEntry = entry.substring(wildcardIndex + 1); // Create an entry string array. - String[] doubleEntry = {firstEntry, secondEntry}; + String[] doubleEntry = {firstEntry, secondEntry, originalBlockListEntry}; // Add the entry to the black list. initialBlackList.add(doubleEntry); @@ -1399,7 +1405,7 @@ public class BlockListHelper { //Log.i("BlockLists", headers.get(1)[0] + " initial black list added: " + firstEntry + " , " + secondEntry + " - " + originalBlockListEntry); } else { // Process an initial black list single entry. // Create an entry string array. - String[] singleEntry = {entry}; + String[] singleEntry = {entry, originalBlockListEntry}; // Add the entry to the black list. initialBlackList.add(singleEntry); @@ -1427,7 +1433,7 @@ public class BlockListHelper { String thirdEntry = secondEntry.substring(secondWildcardIndex + 1); // Create an entry string array. - String[] tripleEntry = {firstEntry, realSecondEntry, thirdEntry}; + String[] tripleEntry = {firstEntry, realSecondEntry, thirdEntry, originalBlockListEntry}; // Add the entry to the black list. finalBlackList.add(tripleEntry); @@ -1436,7 +1442,7 @@ public class BlockListHelper { // originalBlockListEntry); } else { // Process a final black list double entry. // Create an entry string array. - String[] doubleEntry = {firstEntry, secondEntry}; + String[] doubleEntry = {firstEntry, secondEntry, originalBlockListEntry}; // Add the entry to the black list. finalBlackList.add(doubleEntry); @@ -1445,7 +1451,7 @@ public class BlockListHelper { } } else { // Process a final black list single entry. // Create an entry string array. - String[] singleEntry = {entry}; + String[] singleEntry = {entry, originalBlockListEntry}; // Add the entry to the black list. finalBlackList.add(singleEntry); @@ -1486,7 +1492,7 @@ public class BlockListHelper { String fifthEntry = fourthEntry.substring(fourthWildcardIndex + 1); // Create an entry string array. - String[] quintupleEntry = {firstEntry, realSecondEntry, realThirdEntry, realFourthEntry, fifthEntry}; + String[] quintupleEntry = {firstEntry, realSecondEntry, realThirdEntry, realFourthEntry, fifthEntry, originalBlockListEntry}; // Add the entry to the black list. mainBlackList.add(quintupleEntry); @@ -1495,7 +1501,7 @@ public class BlockListHelper { // realFourthEntry + " , " + fifthEntry + " - " + originalBlockListEntry); } else { // Process a main black list quadruple entry. // Create an entry string array. - String[] quadrupleEntry = {firstEntry, realSecondEntry, realThirdEntry, fourthEntry}; + String[] quadrupleEntry = {firstEntry, realSecondEntry, realThirdEntry, fourthEntry, originalBlockListEntry}; // Add the entry to the black list. mainBlackList.add(quadrupleEntry); @@ -1505,7 +1511,7 @@ public class BlockListHelper { } } else { // Process a main black list triple entry. // Create an entry string array. - String[] tripleEntry = {firstEntry, realSecondEntry, thirdEntry}; + String[] tripleEntry = {firstEntry, realSecondEntry, thirdEntry, originalBlockListEntry}; // Add the entry to the black list. mainBlackList.add(tripleEntry); @@ -1514,7 +1520,7 @@ public class BlockListHelper { } } else { // Process a main black list double entry. // Create an entry string array. - String[] doubleEntry = {firstEntry, secondEntry}; + String[] doubleEntry = {firstEntry, secondEntry, originalBlockListEntry}; // Add the entry to the black list. mainBlackList.add(doubleEntry); @@ -1523,7 +1529,7 @@ public class BlockListHelper { } } else { // Process a main black list single entry. // Create an entry string array. - String[] singleEntry = {blockListEntry}; + String[] singleEntry = {blockListEntry, originalBlockListEntry}; // Add the entry to the black list. mainBlackList.add(singleEntry); @@ -1575,15 +1581,18 @@ public class BlockListHelper { } public boolean isBlocked(String currentUrl, String resourceUrl, ArrayList> blockList) { - // Get the list title. - String blockListTitle = blockList.get(0).get(1)[0]; + // Get the block list name. + String BLOCK_LIST_NAME_STRING = blockList.get(0).get(1)[0]; + // Get the current domain. Uri currentUri = Uri.parse(currentUrl); String currentDomain = currentUri.getHost(); + // Get the resource domain. Uri resourceUri = Uri.parse(resourceUrl); String resourceDomain = resourceUri.getHost(); + // Initialize the third-party request tracker. boolean thirdPartyRequest = false; // If one of the domains is `about:blank` it will throw a null object reference on the string comparison. @@ -1593,30 +1602,36 @@ public class BlockListHelper { // Process the white lists. // Main white list. - for (String[] whiteListEntry : blockList.get(1)) { + for (String[] whiteListEntry : blockList.get(MainWebViewActivity.MAIN_WHITELIST)) { switch (whiteListEntry.length) { - case 1: // There is one entry. + case 2: // There is one entry. if (resourceUrl.contains(whiteListEntry[0])) { - Log.i("BlockLists", "Request allowed by " + blockListTitle + " main white list: " + whiteListEntry[0] + " - " + resourceUrl); + // Store the entry in the resource request log. + MainWebViewActivity.whiteListResultStringArray = new String[] {String.valueOf(MainWebViewActivity.REQUEST_ALLOWED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.MAIN_WHITELIST), whiteListEntry[0], whiteListEntry[1]}; // Not blocked. return false; } break; - case 2: + case 3: // There are two entries. if (resourceUrl.contains(whiteListEntry[0]) && resourceUrl.contains(whiteListEntry[1])) { - Log.i("BlockLists", "Request allowed by " + blockListTitle + " main white list: " + whiteListEntry[0] + " , " + whiteListEntry[1] + " - " + resourceUrl); + // Store the entry in the resource request log. + MainWebViewActivity.whiteListResultStringArray = new String[] {String.valueOf(MainWebViewActivity.REQUEST_ALLOWED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.MAIN_WHITELIST), whiteListEntry[0] + "\n" + whiteListEntry[1], + whiteListEntry[2]}; // Not blocked. return false; } break; - case 3: + case 4: // There are three entries. if (resourceUrl.contains(whiteListEntry[0]) && resourceUrl.contains(whiteListEntry[1]) && resourceUrl.contains(whiteListEntry[2])) { - Log.i("BlockLists", "Request allowed by " + blockListTitle + " main white list: " + whiteListEntry[0] + " , " + whiteListEntry[1] + " , " + whiteListEntry[2] + " - " + - resourceUrl); + // Store the entry in the resource request log. + MainWebViewActivity.whiteListResultStringArray = new String[] {String.valueOf(MainWebViewActivity.REQUEST_ALLOWED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.MAIN_WHITELIST), whiteListEntry[0] + "\n" + whiteListEntry[1] + "\n" + whiteListEntry[2], whiteListEntry[3]}; // Not blocked. return false; @@ -1626,17 +1641,21 @@ public class BlockListHelper { } // Final white list. - for (String[] whiteListEntry : blockList.get(2)) { - if (whiteListEntry.length == 1) { // There is one entry. + for (String[] whiteListEntry : blockList.get(MainWebViewActivity.FINAL_WHITELIST)) { + if (whiteListEntry.length == 2) { // There is one entry. if (resourceUrl.contains(whiteListEntry[0])) { - Log.i("BlockLists", "Request allowed by " + blockListTitle + " final white list: " + whiteListEntry[0] + " - " + resourceUrl); + // Store the entry in the resource request log. + MainWebViewActivity.whiteListResultStringArray = new String[] {String.valueOf(MainWebViewActivity.REQUEST_ALLOWED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.FINAL_WHITELIST), whiteListEntry[0], whiteListEntry[1]}; // Not blocked. return false; } } else { // There are two entries. if (resourceUrl.contains(whiteListEntry[0]) && resourceUrl.contains(whiteListEntry[1])) { - Log.i("BlockLists", "Request allowed by " + blockListTitle + " final white list: " + whiteListEntry[0] + " , " + whiteListEntry[1] + " - " + resourceUrl); + // Store the entry in the resource request log. + MainWebViewActivity.whiteListResultStringArray = new String[] {String.valueOf(MainWebViewActivity.REQUEST_ALLOWED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.FINAL_WHITELIST), whiteListEntry[0] + "\n" + whiteListEntry[1], whiteListEntry[2]}; // Not blocked. return false; @@ -1647,42 +1666,49 @@ public class BlockListHelper { // Only check the domain lists if the current domain is not null (like `about:blank`). if (currentDomain != null) { // Domain white list. - for (String[] whiteListEntry : blockList.get(3)) { + for (String[] whiteListEntry : blockList.get(MainWebViewActivity.DOMAIN_WHITELIST)) { switch (whiteListEntry.length) { - case 2: // There is one entry. + case 3: // There is one entry. if (currentDomain.endsWith(whiteListEntry[0]) && resourceUrl.contains(whiteListEntry[1])) { - Log.i("BlockLists", "Request allowed by " + blockListTitle + " domain white list: " + whiteListEntry[0] + " , " + whiteListEntry[1] + " --" + resourceUrl); + // Store the entry in the resource request log. + MainWebViewActivity.whiteListResultStringArray = new String[] {String.valueOf(MainWebViewActivity.REQUEST_ALLOWED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.DOMAIN_WHITELIST), whiteListEntry[0] + "\n" + whiteListEntry[1], whiteListEntry[2]}; // Not blocked. return false; } break; - case 3: // There are two entries. + case 4: // There are two entries. if (currentDomain.endsWith(whiteListEntry[0]) && resourceUrl.contains(whiteListEntry[1]) && resourceUrl.contains(whiteListEntry[2])) { - Log.i("BlockLists", "Request allowed by " + blockListTitle + " domain white list: " + whiteListEntry[0] + " , " + whiteListEntry[1] + " , " + whiteListEntry[2] + - " - " + resourceUrl); + // Store the entry in the resource request log. + MainWebViewActivity.whiteListResultStringArray = new String[] {String.valueOf(MainWebViewActivity.REQUEST_ALLOWED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.DOMAIN_WHITELIST), whiteListEntry[0] + "\n" + whiteListEntry[1] + "\n" + whiteListEntry[2], whiteListEntry[3]}; // Not blocked. return false; } break; - case 4: // There are three entries. + case 5: // There are three entries. if (currentDomain.endsWith(whiteListEntry[0]) && resourceUrl.contains(whiteListEntry[1]) && resourceUrl.contains(whiteListEntry[2]) && resourceUrl.contains(whiteListEntry[3])) { - Log.i("BlockLists", "Request allowed by " + blockListTitle + " domain white list: " + whiteListEntry[0] + " , " + whiteListEntry[1] + " , " + whiteListEntry[2] + - " , " + whiteListEntry[3] + " - " + resourceUrl); + // Store the entry in the resource request log. + MainWebViewActivity.whiteListResultStringArray = new String[] {String.valueOf(MainWebViewActivity.REQUEST_ALLOWED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.DOMAIN_WHITELIST), whiteListEntry[0] + "\n" + whiteListEntry[1] + "\n" + whiteListEntry[2] + "\n" + whiteListEntry[3], + whiteListEntry[4]}; // Not blocked. return false; } break; - case 5: // There are four entries. + case 6: // There are four entries. if (currentDomain.endsWith(whiteListEntry[0]) && resourceUrl.contains(whiteListEntry[1]) && resourceUrl.contains(whiteListEntry[2]) && resourceUrl.contains(whiteListEntry[3]) && resourceUrl.contains(whiteListEntry[4])) { - Log.i("BlockLists", "Request allowed by " + blockListTitle + " domain white list: " + whiteListEntry[0] + " , " + whiteListEntry[1] + " , " + whiteListEntry[2] + - " , " + whiteListEntry[3] + " , " + whiteListEntry[4] + " - " + resourceUrl); + // Store the entry in the resource request log. + MainWebViewActivity.whiteListResultStringArray = new String[] {String.valueOf(MainWebViewActivity.REQUEST_ALLOWED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.DOMAIN_WHITELIST), whiteListEntry[0] + "\n" + whiteListEntry[1] + "\n" + whiteListEntry[2] + "\n" + whiteListEntry[3] + "\n" + + whiteListEntry[4], whiteListEntry[5]}; // Not blocked. return false; @@ -1692,31 +1718,36 @@ public class BlockListHelper { } // Domain initial white list. - for (String[] whiteListEntry : blockList.get(4)) { + for (String[] whiteListEntry : blockList.get(MainWebViewActivity.DOMAIN_INITIAL_WHITELIST)) { switch (whiteListEntry.length) { - case 2: // There is one entry. + case 3: // There is one entry. if (currentDomain.endsWith(whiteListEntry[0]) && resourceUrl.startsWith(whiteListEntry[1])) { - Log.i("BlockLists", "Request allowed by " + blockListTitle + " domain initial white list: " + whiteListEntry[0] + " , " + whiteListEntry[1] + " - " + resourceUrl); + // Store the entry in the resource request log. + MainWebViewActivity.whiteListResultStringArray = new String[] {String.valueOf(MainWebViewActivity.REQUEST_ALLOWED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.DOMAIN_INITIAL_WHITELIST), whiteListEntry[0] + "\n" + whiteListEntry[1], whiteListEntry[2]}; // Not blocked. return false; } break; - case 3: // There are two entries. + case 4: // There are two entries. if (currentDomain.endsWith(whiteListEntry[0]) && resourceUrl.startsWith(whiteListEntry[1]) && resourceUrl.contains(whiteListEntry[2])) { - Log.i("BlockLists", "Request allowed by " + blockListTitle + " domain initial white list: " + whiteListEntry[0] + " , " + whiteListEntry[1] + " , " + - whiteListEntry[2] + " - " + resourceUrl); + // Store the entry in the resource request log. + MainWebViewActivity.whiteListResultStringArray = new String[] {String.valueOf(MainWebViewActivity.REQUEST_ALLOWED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.DOMAIN_INITIAL_WHITELIST), whiteListEntry[0] + "\n" + whiteListEntry[1] + "\n" + whiteListEntry[2], whiteListEntry[3]}; // Not blocked. return false; } break; - case 4: // There are three entries. + case 5: // There are three entries. if (currentDomain.endsWith(whiteListEntry[0]) && resourceUrl.startsWith(whiteListEntry[1]) && resourceUrl.contains(whiteListEntry[2]) && resourceUrl.startsWith(whiteListEntry[3])) { - Log.i("BlockLists", "Request allowed by " + blockListTitle + " domain initial white list: " + whiteListEntry[0] + " , " + whiteListEntry[1] + " , " + - whiteListEntry[2] + " , " + whiteListEntry[3] + " - " + resourceUrl); + // Store the entry in the resource request log. + MainWebViewActivity.whiteListResultStringArray = new String[] {String.valueOf(MainWebViewActivity.REQUEST_ALLOWED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.DOMAIN_INITIAL_WHITELIST), whiteListEntry[0] + "\n" + whiteListEntry[1] + "\n" + whiteListEntry[2] + "\n" + whiteListEntry[3], + whiteListEntry[4]}; // Not blocked. return false; @@ -1726,21 +1757,25 @@ public class BlockListHelper { } // Domain final white list. - for (String[] whiteListEntry : blockList.get(5)) { + for (String[] whiteListEntry : blockList.get(MainWebViewActivity.DOMAIN_FINAL_WHITELIST)) { switch (whiteListEntry.length) { - case 2: // There is one entry; + case 3: // There is one entry; if (currentDomain.endsWith(whiteListEntry[0]) && resourceUrl.endsWith(whiteListEntry[1])) { - Log.i("BlockLists", "Request allowed by " + blockListTitle + " domain final white list: " + whiteListEntry[0] + " , " + whiteListEntry[1] + " - " + resourceUrl); + // Store the entry in the resource request log. + MainWebViewActivity.whiteListResultStringArray = new String[] {String.valueOf(MainWebViewActivity.REQUEST_ALLOWED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.DOMAIN_FINAL_WHITELIST), whiteListEntry[0] + "\n" + whiteListEntry[1], whiteListEntry[2]}; // Not blocked. return false; } break; - case 3: // There are two entries; + case 4: // There are two entries; if (currentDomain.endsWith(whiteListEntry[0]) && resourceUrl.contains(whiteListEntry[1]) && resourceUrl.endsWith(whiteListEntry[2])) { - Log.i("BlockLists", "Request allowed by " + blockListTitle + " domain final white list: " + whiteListEntry[0] + " , " + whiteListEntry[1] + " , " + - whiteListEntry[2] + " - " + resourceUrl); + // Store the entry in the resource request log. + MainWebViewActivity.whiteListResultStringArray = new String[] {String.valueOf(MainWebViewActivity.REQUEST_ALLOWED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.DOMAIN_FINAL_WHITELIST), whiteListEntry[0] + "\n" + whiteListEntry[1] + "\n" + whiteListEntry[2], whiteListEntry[3]}; + // Not blocked. return false; @@ -1753,51 +1788,59 @@ public class BlockListHelper { // Only check the third-party white lists if this is a third-party request. if (thirdPartyRequest) { // Third-party white list. - for (String[] whiteListEntry : blockList.get(6)) { + for (String[] whiteListEntry : blockList.get(MainWebViewActivity.THIRD_PARTY_WHITELIST)) { switch (whiteListEntry.length) { - case 1: // There is one entry + case 2: // There is one entry if (resourceUrl.contains(whiteListEntry[0])) { - Log.i("BlockLists", "Request allowed by " + blockListTitle + " third-party white list: " + whiteListEntry[0] + " - " + resourceUrl); + // Store the entry in the resource request log. + MainWebViewActivity.whiteListResultStringArray = new String[] {String.valueOf(MainWebViewActivity.REQUEST_ALLOWED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.THIRD_PARTY_WHITELIST), whiteListEntry[0], whiteListEntry[1]}; // Not blocked. return false; } break; - case 2: // There are two entries. + case 3: // There are two entries. if (resourceUrl.contains(whiteListEntry[0]) && resourceUrl.contains(whiteListEntry[1])) { - Log.i("BlockLists", "Request allowed by " + blockListTitle + " third-party white list: " + whiteListEntry[0] + " , " + whiteListEntry[1] + " - " + resourceUrl); + // Store the entry in the resource request log. + MainWebViewActivity.whiteListResultStringArray = new String[] {String.valueOf(MainWebViewActivity.REQUEST_ALLOWED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.THIRD_PARTY_WHITELIST), whiteListEntry[0] + "\n" + whiteListEntry[1], whiteListEntry[2]}; // Not blocked. return false; } break; - case 3: // There are three entries. + case 4: // There are three entries. if (resourceUrl.contains(whiteListEntry[0]) && resourceUrl.contains(whiteListEntry[1]) && resourceUrl.contains(whiteListEntry[2])) { - Log.i("BlockLists", "Request allowed by " + blockListTitle + " third-party white list: " + whiteListEntry[0] + " , " + whiteListEntry[1] + " , " + whiteListEntry[2] + - " - " + resourceUrl); + // Store the entry in the resource request log. + MainWebViewActivity.whiteListResultStringArray = new String[] {String.valueOf(MainWebViewActivity.REQUEST_ALLOWED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.THIRD_PARTY_WHITELIST), whiteListEntry[0] + "\n" + whiteListEntry[1] + "\n" + whiteListEntry[2], whiteListEntry[3]}; // Not blocked. return false; } break; - case 4: // There are four entries. + case 5: // There are four entries. if (resourceUrl.contains(whiteListEntry[0]) && resourceUrl.contains(whiteListEntry[1]) && resourceUrl.contains(whiteListEntry[2]) && resourceUrl.contains(whiteListEntry[3])) { - Log.i("BlockLists", "Request allowed by " + blockListTitle + " third-party white list: " + whiteListEntry[0] + " , " + whiteListEntry[1] + " , " + whiteListEntry[2] + - " , " + whiteListEntry[3] + " - " + resourceUrl); - + // Store the entry in the resource request log. + MainWebViewActivity.whiteListResultStringArray = new String[] {String.valueOf(MainWebViewActivity.REQUEST_ALLOWED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.THIRD_PARTY_WHITELIST), whiteListEntry[0] + "\n" + whiteListEntry[1] + "\n" + whiteListEntry[2] + "\n" + whiteListEntry[3], + whiteListEntry[4]}; // Not blocked. return false; } break; - case 5: // There are five entries. + case 6: // There are five entries. if (resourceUrl.contains(whiteListEntry[0]) && resourceUrl.contains(whiteListEntry[1]) && resourceUrl.contains(whiteListEntry[2]) && resourceUrl.contains(whiteListEntry[3]) && resourceUrl.contains(whiteListEntry[4])) { - Log.i("BlockLists", "Request allowed by " + blockListTitle + " third-party white list: " + whiteListEntry[0] + " , " + whiteListEntry[1] + " , " + whiteListEntry[2] + - " , " + whiteListEntry[3] + " , " + whiteListEntry[4] + " - " + resourceUrl); + // Store the entry in the resource request log. + MainWebViewActivity.whiteListResultStringArray = new String[] {String.valueOf(MainWebViewActivity.REQUEST_ALLOWED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.THIRD_PARTY_WHITELIST), whiteListEntry[0] + "\n" + whiteListEntry[1] + "\n" + whiteListEntry[2] + "\n" + whiteListEntry[3] + "\n" + + whiteListEntry[4], whiteListEntry[5]}; // Not blocked. return false; @@ -1807,18 +1850,21 @@ public class BlockListHelper { } // Third-party domain white list. - for (String[] whiteListEntry : blockList.get(7)) { - if (whiteListEntry.length == 2) { // There is one entry. + for (String[] whiteListEntry : blockList.get(MainWebViewActivity.THIRD_PARTY_DOMAIN_WHITELIST)) { + if (whiteListEntry.length == 3) { // There is one entry. if (currentDomain.endsWith(whiteListEntry[0]) && resourceUrl.contains(whiteListEntry[1])) { - Log.i("BlockLists", "Request allowed by " + blockListTitle + " third-party domain white list: " + whiteListEntry[0] + " , " + whiteListEntry[1] + " - " + resourceUrl); + // Store the entry in the resource request log. + MainWebViewActivity.whiteListResultStringArray = new String[] {String.valueOf(MainWebViewActivity.REQUEST_ALLOWED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.THIRD_PARTY_DOMAIN_WHITELIST), whiteListEntry[0] + "\n" + whiteListEntry[1], whiteListEntry[2]}; // Not blocked. return false; } } else { // There are two entries. if (currentDomain.endsWith(whiteListEntry[0]) && resourceUrl.contains(whiteListEntry[1]) && resourceUrl.contains(whiteListEntry[2])) { - Log.i("BlockLists", "Request allowed by " + blockListTitle + " third-party domain white list: " + whiteListEntry[0] + " , " + whiteListEntry[1] + " , " + - whiteListEntry[2] + " - " + resourceUrl); + // Store the entry in the resource request log. + MainWebViewActivity.whiteListResultStringArray = new String[] {String.valueOf(MainWebViewActivity.REQUEST_ALLOWED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.THIRD_PARTY_DOMAIN_WHITELIST), whiteListEntry[0] + "\n" + whiteListEntry[1] + "\n" + whiteListEntry[2], whiteListEntry[3]}; // Not blocked. return false; @@ -1827,19 +1873,21 @@ public class BlockListHelper { } // Third-party domain initial white list. - for (String[] whiteListEntry : blockList.get(8)) { - if (whiteListEntry.length == 2) { // There is one entry. + for (String[] whiteListEntry : blockList.get(MainWebViewActivity.THIRD_PARTY_DOMAIN_INITIAL_WHITELIST)) { + if (whiteListEntry.length == 3) { // There is one entry. if (currentDomain.endsWith(whiteListEntry[0]) && resourceUrl.startsWith(whiteListEntry[1])) { - Log.i("BlockLists", "Request allowed by " + blockListTitle + " third-party domain initial white list: " + whiteListEntry[0] + " , " + whiteListEntry[1] + " - " + - resourceUrl); + // Store the entry in the resource request log. + MainWebViewActivity.whiteListResultStringArray = new String[] {String.valueOf(MainWebViewActivity.REQUEST_ALLOWED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.THIRD_PARTY_DOMAIN_INITIAL_WHITELIST), whiteListEntry[0] + "\n" + whiteListEntry[1], whiteListEntry[2]}; // Not blocked. return false; } } else { // There are two entries. if (currentDomain.endsWith(whiteListEntry[0]) && resourceUrl.startsWith(whiteListEntry[1]) && resourceUrl.contains(whiteListEntry[2])) { - Log.i("BlockLists", "Request allowed by " + blockListTitle + " third-party domain initial white list: " + whiteListEntry[0] + " , " + whiteListEntry[1] + " , " + - whiteListEntry[2] + " - " + resourceUrl); + // Store the entry in the resource request log. + MainWebViewActivity.whiteListResultStringArray = new String[] {String.valueOf(MainWebViewActivity.REQUEST_ALLOWED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.THIRD_PARTY_DOMAIN_WHITELIST), whiteListEntry[0] + "\n" + whiteListEntry[1] + "\n" + whiteListEntry[2], whiteListEntry[3]}; // Not blocked. return false; @@ -1850,51 +1898,59 @@ public class BlockListHelper { // Process the black lists. // Main black list. - for (String[] blackListEntry : blockList.get(9)) { + for (String[] blackListEntry : blockList.get(MainWebViewActivity.MAIN_BLACKLIST)) { switch (blackListEntry.length) { - case 1: // There is one entry. + case 2: // There is one entry. if (resourceUrl.contains(blackListEntry[0])) { - Log.i("BlockLists", "Request blocked by " + blockListTitle + " main black list: " + blackListEntry[0] + " - " + resourceUrl); + // Store the entry in the resource request log. + MainWebViewActivity.resourceRequests.add(new String[] {String.valueOf(MainWebViewActivity.REQUEST_BLOCKED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.MAIN_BLACKLIST), blackListEntry[0], blackListEntry[1]}); // Blocked. return true; } break; - case 2: // There are two entries. + case 3: // There are two entries. if (resourceUrl.contains(blackListEntry[0]) && resourceUrl.contains(blackListEntry[1])) { - Log.i("BlockLists", "Request blocked by " + blockListTitle + " main black list: " + blackListEntry[0] + " , " + blackListEntry[1] + " - " + resourceUrl); + // Store the entry in the resource request log. + MainWebViewActivity.resourceRequests.add(new String[] {String.valueOf(MainWebViewActivity.REQUEST_BLOCKED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.MAIN_BLACKLIST), blackListEntry[0] + "\n" + blackListEntry[1], blackListEntry[2]}); // Blocked. return true; } break; - case 3: // There are three entries. + case 4: // There are three entries. if (resourceUrl.contains(blackListEntry[0]) && resourceUrl.contains(blackListEntry[1]) && resourceUrl.contains(blackListEntry[2])) { - Log.i("BlockLists", "Request blocked by " + blockListTitle + " main black list: " + blackListEntry[0] + " , " + blackListEntry[1] + " , " + blackListEntry[2] + " - " + - resourceUrl); + // Store the entry in the resource request log. + MainWebViewActivity.resourceRequests.add(new String[] {String.valueOf(MainWebViewActivity.REQUEST_BLOCKED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.MAIN_BLACKLIST), blackListEntry[0] + "\n" + blackListEntry[1] + "\n" + blackListEntry[2], blackListEntry[3]}); // Blocked. return true; } break; - case 4: // There are four entries. + case 5: // There are four entries. if (resourceUrl.contains(blackListEntry[0]) && resourceUrl.contains(blackListEntry[1]) && resourceUrl.contains(blackListEntry[2]) && resourceUrl.contains(blackListEntry[3])) { - Log.i("BlockLists", "Request blocked by " + blockListTitle + " main black list: " + blackListEntry[0] + " , " + blackListEntry[1] + " , " + blackListEntry[2] + " , " + - blackListEntry[3] + " - " + resourceUrl); + // Store the entry in the resource request log. + MainWebViewActivity.resourceRequests.add(new String[] {String.valueOf(MainWebViewActivity.REQUEST_BLOCKED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.MAIN_BLACKLIST), blackListEntry[0] + "\n" + blackListEntry[1] + "\n" + blackListEntry[2] + "\n" + blackListEntry[3], blackListEntry[4]}); // Blocked. return true; } break; - case 5: // There are five entries. + case 6: // There are five entries. if (resourceUrl.contains(blackListEntry[0]) && resourceUrl.contains(blackListEntry[1]) && resourceUrl.contains(blackListEntry[2]) && resourceUrl.contains(blackListEntry[3]) && resourceUrl.contains(blackListEntry[4])) { - Log.i("BlockLists", "Request blocked by " + blockListTitle + " main black list: " + blackListEntry[0] + " , " + blackListEntry[1] + " , " + blackListEntry[2] + " , " + - blackListEntry[3] + ", " + blackListEntry[4] + " - " + resourceUrl); + // Store the entry in the resource request log. + MainWebViewActivity.resourceRequests.add(new String[] {String.valueOf(MainWebViewActivity.REQUEST_BLOCKED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.MAIN_BLACKLIST), blackListEntry[0] + "\n" + blackListEntry[1] + "\n" + blackListEntry[2] + "\n" + blackListEntry[3] + "\n" + + blackListEntry[4], blackListEntry[5]}); // Blocked. return true; @@ -1904,17 +1960,21 @@ public class BlockListHelper { } // Initial black list. - for (String[] blackListEntry : blockList.get(10)) { - if (blackListEntry.length == 1) { // There is one entry. + for (String[] blackListEntry : blockList.get(MainWebViewActivity.INITIAL_BLACKLIST)) { + if (blackListEntry.length == 2) { // There is one entry. if (resourceUrl.startsWith(blackListEntry[0])) { - Log.i("BlockLists", "Request blocked by " + blockListTitle + " initial black list: " + blackListEntry[0] + " - " + resourceUrl); + // Store the entry in the resource request log. + MainWebViewActivity.resourceRequests.add(new String[] {String.valueOf(MainWebViewActivity.REQUEST_BLOCKED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.INITIAL_BLACKLIST), blackListEntry[0], blackListEntry[1]}); // Blocked. return true; } } else { // There are two entries if (resourceUrl.startsWith(blackListEntry[0]) && resourceUrl.contains(blackListEntry[1])) { - Log.i("BlockLists", "Request blocked by " + blockListTitle + " initial black list: " + blackListEntry[0] + " , " + blackListEntry[1] + " - " + resourceUrl); + // Store the entry in the resource request log. + MainWebViewActivity.resourceRequests.add(new String[] {String.valueOf(MainWebViewActivity.REQUEST_BLOCKED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.INITIAL_BLACKLIST), blackListEntry[0] + "\n" + blackListEntry[1], blackListEntry[2]}); // Blocked. return true; @@ -1923,30 +1983,35 @@ public class BlockListHelper { } // Final black list. - for (String[] blackListEntry : blockList.get(11)) { + for (String[] blackListEntry : blockList.get(MainWebViewActivity.FINAL_BLACKLIST)) { switch (blackListEntry.length) { - case 1: // There is one entry. + case 2: // There is one entry. if (resourceUrl.endsWith(blackListEntry[0])) { - Log.i("BlockLists", "Request blocked by " + blockListTitle + " final black list: " + blackListEntry[0] + " - " + resourceUrl); + // Store the entry in the resource request log. + MainWebViewActivity.resourceRequests.add(new String[] {String.valueOf(MainWebViewActivity.REQUEST_BLOCKED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.FINAL_BLACKLIST), blackListEntry[0], blackListEntry[1]}); // Blocked. return true; } break; - case 2: // There are two entries. + case 3: // There are two entries. if (resourceUrl.contains(blackListEntry[0]) && resourceUrl.endsWith(blackListEntry[1])) { - Log.i("BlockLists", "Request blocked by " + blockListTitle + " final black list: " + blackListEntry[0] + " , " + blackListEntry[1] + " - " + resourceUrl); + // Store the entry in the resource request log. + MainWebViewActivity.resourceRequests.add(new String[] {String.valueOf(MainWebViewActivity.REQUEST_BLOCKED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.FINAL_BLACKLIST), blackListEntry[0] + "\n" + blackListEntry[1], blackListEntry[2]}); // Blocked. return true; } break; - case 3: // There are three entries. + case 4: // There are three entries. if (resourceUrl.contains(blackListEntry[0]) && resourceUrl.contains(blackListEntry[1]) && resourceUrl.endsWith(blackListEntry[2])) { - Log.i("BlockLists", "Request blocked by " + blockListTitle + " final black list: " + blackListEntry[0] + " , " + blackListEntry[1] + " , " + blackListEntry[2] + " - " + - resourceUrl); + // Store the entry in the resource request log. + MainWebViewActivity.resourceRequests.add(new String[] {String.valueOf(MainWebViewActivity.REQUEST_BLOCKED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.FINAL_BLACKLIST), blackListEntry[0] + "\n" + blackListEntry[1] + "\n" + blackListEntry[2], blackListEntry[3]}); // Blocked. return true; @@ -1958,31 +2023,36 @@ public class BlockListHelper { // Only check the domain lists if the current domain is not null (like `about:blank`). if (currentDomain != null) { // Domain black list. - for (String[] blackListEntry : blockList.get(12)) { + for (String[] blackListEntry : blockList.get(MainWebViewActivity.DOMAIN_BLACKLIST)) { switch (blackListEntry.length) { - case 2: // There is one entry. + case 3: // There is one entry. if (currentDomain.endsWith(blackListEntry[0]) && resourceUrl.contains(blackListEntry[1])) { - Log.i("BlockLists", "Request blocked by " + blockListTitle + " domain black list: " + blackListEntry[0] + " , " + blackListEntry[1] + " - " + resourceUrl); + // Store the entry in the resource request log. + MainWebViewActivity.resourceRequests.add(new String[] {String.valueOf(MainWebViewActivity.REQUEST_BLOCKED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.DOMAIN_BLACKLIST), blackListEntry[0] + "\n" + blackListEntry[1], blackListEntry[2]}); // Blocked. return true; } break; - case 3: // There are two entries. + case 4: // There are two entries. if (currentDomain.endsWith(blackListEntry[0]) && resourceUrl.contains(blackListEntry[1]) && resourceUrl.contains(blackListEntry[2])) { - Log.i("BlockLists", "Request blocked by " + blockListTitle + " domain black list: " + blackListEntry[0] + " , " + blackListEntry[1] + " , " + blackListEntry[2] + - " - " + resourceUrl); + // Store the entry in the resource request log. + MainWebViewActivity.resourceRequests.add(new String[] {String.valueOf(MainWebViewActivity.REQUEST_BLOCKED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.DOMAIN_BLACKLIST), blackListEntry[0] + "\n" + blackListEntry[1] + "\n" + blackListEntry[2], blackListEntry[3]}); // Blocked. return true; } break; - case 4: // There are three entries. + case 5: // There are three entries. if (currentDomain.endsWith(blackListEntry[0]) && resourceUrl.contains(blackListEntry[1]) && resourceUrl.contains(blackListEntry[2]) && resourceUrl.contains(blackListEntry[3])) { - Log.i("BlockLists", "Request blocked by " + blockListTitle + " domain black list: " + blackListEntry[0] + " , " + blackListEntry[1] + " , " + blackListEntry[2] + - " , " + blackListEntry[3] + " - " + resourceUrl); + // Store the entry in the resource request log. + MainWebViewActivity.resourceRequests.add(new String[] {String.valueOf(MainWebViewActivity.REQUEST_BLOCKED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.DOMAIN_BLACKLIST), blackListEntry[0] + "\n" + blackListEntry[1] + "\n" + blackListEntry[2] + "\n" + blackListEntry[3], + blackListEntry[4]}); // Blocked. return true; @@ -1992,9 +2062,12 @@ public class BlockListHelper { } // Domain initial black list. - for (String[] blackListEntry : blockList.get(13)) { + for (String[] blackListEntry : blockList.get(MainWebViewActivity.DOMAIN_INITIAL_BLACKLIST)) { + // Store the entry in the resource request log. if (currentDomain.endsWith(blackListEntry[0]) && resourceUrl.startsWith(blackListEntry[1])) { - Log.i("BlockLists", "Request blocked by " + blockListTitle + " domain initial black list: " + blackListEntry[0] + " , " + blackListEntry[1] + " - " + resourceUrl); + MainWebViewActivity.resourceRequests.add(new String[] {String.valueOf(MainWebViewActivity.REQUEST_BLOCKED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.DOMAIN_INITIAL_BLACKLIST), blackListEntry[0] + "\n" + blackListEntry[1], + blackListEntry[2]}); // Blocked. return true; @@ -2002,21 +2075,24 @@ public class BlockListHelper { } // Domain final black list. - for (String[] blackListEntry : blockList.get(14)) { + for (String[] blackListEntry : blockList.get(MainWebViewActivity.DOMAIN_FINAL_BLACKLIST)) { switch (blackListEntry.length) { - case 2: // There is one entry. + case 3: // There is one entry. if (currentDomain.endsWith(blackListEntry[0]) && resourceUrl.endsWith(blackListEntry[1])) { - Log.i("BlockLists", "Request blocked by " + blockListTitle + " domain final black list: " + blackListEntry[0] + " , " + blackListEntry[1] + " - " + resourceUrl); + // Store the entry in the resource request log. + MainWebViewActivity.resourceRequests.add(new String[] {String.valueOf(MainWebViewActivity.REQUEST_BLOCKED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.DOMAIN_FINAL_BLACKLIST), blackListEntry[0] + "\n" + blackListEntry[1], blackListEntry[2]}); // Blocked. return true; } break; - case 3: // There are two entries. + case 4: // There are two entries. if (currentDomain.endsWith(blackListEntry[0]) && resourceUrl.contains(blackListEntry[1]) && resourceUrl.endsWith(blackListEntry[2])) { - Log.i("BlockLists", "Request blocked by " + blockListTitle + " domain final black list: " + blackListEntry[0] + " , " + blackListEntry[1] + " , " + blackListEntry[2] + - " - " + resourceUrl); + // Store the entry in the resource request log. + MainWebViewActivity.resourceRequests.add(new String[] {String.valueOf(MainWebViewActivity.REQUEST_BLOCKED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.DOMAIN_FINAL_BLACKLIST), blackListEntry[0] + "\n" + blackListEntry[1] + "\n" + blackListEntry[2], blackListEntry[3]}); // Blocked. return true; @@ -2026,9 +2102,11 @@ public class BlockListHelper { } // Domain regular expression black list. - for (String[] blackListEntry : blockList.get(15)) { + for (String[] blackListEntry : blockList.get(MainWebViewActivity.DOMAIN_REGULAR_EXPRESSION_BLACKLIST)) { if (currentDomain.endsWith(blackListEntry[0]) && Pattern.matches(blackListEntry[1], resourceUrl)) { - Log.i("BlockLists", "Request blocked by " + blockListTitle + " domain regular expression black list: " + blackListEntry[0] + " , " + blackListEntry[1] + " - " + resourceUrl); + // Store the entry in the resource request log. + MainWebViewActivity.resourceRequests.add(new String[] {String.valueOf(MainWebViewActivity.REQUEST_BLOCKED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.DOMAIN_REGULAR_EXPRESSION_BLACKLIST), blackListEntry[0] + "\n" + blackListEntry[1], blackListEntry[2]}); // Blocked. return true; @@ -2039,40 +2117,47 @@ public class BlockListHelper { // Only check the third-party black lists if this is a third-party request. if (thirdPartyRequest) { // Third-party black list. - for (String[] blackListEntry : blockList.get(16)) { + for (String[] blackListEntry : blockList.get(MainWebViewActivity.THIRD_PARTY_BLACKLIST)) { switch (blackListEntry.length) { - case 1: // There is one entry. + case 2: // There is one entry. if (resourceUrl.contains(blackListEntry[0])) { - Log.i("BlockLists", "Request blocked by " + blockListTitle + " third-party black list: " + blackListEntry[0] + " - " + resourceUrl); + // Store the entry in the resource request log. + MainWebViewActivity.resourceRequests.add(new String[] {String.valueOf(MainWebViewActivity.REQUEST_BLOCKED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.THIRD_PARTY_BLACKLIST), blackListEntry[0], blackListEntry[1]}); // Blocked. return true; } break; - case 2: // There are two entries. + case 3: // There are two entries. if (resourceUrl.contains(blackListEntry[0]) && resourceUrl.contains(blackListEntry[1])) { - Log.i("BlockLists", "Request blocked by " + blockListTitle + " third-party black list: " + blackListEntry[0] + " , " + blackListEntry[1] + " - " + resourceUrl); + // Store the entry in the resource request log. + MainWebViewActivity.resourceRequests.add(new String[] {String.valueOf(MainWebViewActivity.REQUEST_BLOCKED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.THIRD_PARTY_BLACKLIST), blackListEntry[0] + "\n" + blackListEntry[1], blackListEntry[2]}); // Blocked. return true; } break; - case 3: // There are three entries. + case 4: // There are three entries. if (resourceUrl.contains(blackListEntry[0]) && resourceUrl.contains(blackListEntry[1]) && resourceUrl.contains(blackListEntry[2])) { - Log.i("BlockLists", "Request blocked by " + blockListTitle + " third-party black list: " + blackListEntry[0] + " , " + blackListEntry[1] + " , " + blackListEntry[2] + - " - " + resourceUrl); + // Store the entry in the resource request log. + MainWebViewActivity.resourceRequests.add(new String[] {String.valueOf(MainWebViewActivity.REQUEST_BLOCKED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.THIRD_PARTY_BLACKLIST), blackListEntry[0] + "\n" + blackListEntry[1] + "\n" + blackListEntry[2], blackListEntry[3]}); // Blocked. return true; } break; - case 4: // There are four entries. + case 5: // There are four entries. if (resourceUrl.contains(blackListEntry[0]) && resourceUrl.contains(blackListEntry[1]) && resourceUrl.contains(blackListEntry[2]) && resourceUrl.contains(blackListEntry[3])) { - Log.i("BlockLists", "Request blocked by " + blockListTitle + " third-party black list: " + blackListEntry[0] + " , " + blackListEntry[1] + " , " + blackListEntry[2] + - " , " + blackListEntry[3] + " - " + resourceUrl); + // Store the entry in the resource request log. + MainWebViewActivity.resourceRequests.add(new String[] {String.valueOf(MainWebViewActivity.REQUEST_BLOCKED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.THIRD_PARTY_BLACKLIST), blackListEntry[0] + "\n" + blackListEntry[1] + "\n" + blackListEntry[2] + "\n" + blackListEntry[3], + blackListEntry[4]}); // Blocked. return true; @@ -2082,17 +2167,21 @@ public class BlockListHelper { } // Third-party initial black list. - for (String[] blackListEntry : blockList.get(17)) { - if (blackListEntry.length == 1) { // There is one entry. + for (String[] blackListEntry : blockList.get(MainWebViewActivity.THIRD_PARTY_INITIAL_BLACKLIST)) { + if (blackListEntry.length == 2) { // There is one entry. if (resourceUrl.startsWith(blackListEntry[0])) { - Log.i("BlockLists", "Request blocked by " + blockListTitle + " third-party initial black list: " + blackListEntry[0] + " - " + resourceUrl); + // Store the entry in the resource request log. + MainWebViewActivity.resourceRequests.add(new String[] {String.valueOf(MainWebViewActivity.REQUEST_BLOCKED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.THIRD_PARTY_INITIAL_BLACKLIST), blackListEntry[0], blackListEntry[1]}); // Blocked. return true; } } else { // There are two entries. if (resourceUrl.startsWith(blackListEntry[0]) && resourceUrl.contains(blackListEntry[1])) { - Log.i("BlockLists", "Request blocked by " + blockListTitle + " third-party initial black list: " + blackListEntry[0] + " , " + blackListEntry[1] + " - " + resourceUrl); + // Store the entry in the resource request log. + MainWebViewActivity.resourceRequests.add(new String[] {String.valueOf(MainWebViewActivity.REQUEST_BLOCKED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.THIRD_PARTY_INITIAL_BLACKLIST), blackListEntry[0] + "\n" + blackListEntry[1], blackListEntry[2]}); // Blocked. return true; @@ -2101,18 +2190,21 @@ public class BlockListHelper { } // Third-party domain black list. - for (String[] blackListEntry : blockList.get(18)) { - if (blackListEntry.length == 2) { // There is one entry. + for (String[] blackListEntry : blockList.get(MainWebViewActivity.THIRD_PARTY_DOMAIN_BLACKLIST)) { + if (blackListEntry.length == 3) { // There is one entry. if (currentDomain.endsWith(blackListEntry[0]) && resourceUrl.contains(blackListEntry[1])) { - Log.i("BlockLists", "Request blocked by " + blockListTitle + " third-party domain black list: " + blackListEntry[0] + " , " + blackListEntry[1] + " - " + resourceUrl); + // Store the entry in the resource request log. + MainWebViewActivity.resourceRequests.add(new String[] {String.valueOf(MainWebViewActivity.REQUEST_BLOCKED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.THIRD_PARTY_DOMAIN_BLACKLIST), blackListEntry[0] + "\n" + blackListEntry[1], blackListEntry[2]}); // Blocked. return true; } } else { // There are two entries. if (currentDomain.endsWith(blackListEntry[0]) && resourceUrl.contains(blackListEntry[1]) && resourceUrl.contains(blackListEntry[2])) { - Log.i("BlockLists", "Request blocked by " + blockListTitle + " third-party domain black list: " + blackListEntry[0] + " , " + blackListEntry[1] + " , " + - blackListEntry[2] + " - " + resourceUrl); + // Store the entry in the resource request log. + MainWebViewActivity.resourceRequests.add(new String[] {String.valueOf(MainWebViewActivity.REQUEST_BLOCKED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.THIRD_PARTY_DOMAIN_BLACKLIST), blackListEntry[0] + "\n" + blackListEntry[1] + "\n" + blackListEntry[2], blackListEntry[3]}); // Blocked. return true; @@ -2121,32 +2213,35 @@ public class BlockListHelper { } // Third-party domain initial black list. - for (String[] blackListEntry : blockList.get(19)) { + for (String[] blackListEntry : blockList.get(MainWebViewActivity.THIRD_PARTY_DOMAIN_INITIAL_BLACKLIST)) { switch (blackListEntry.length) { - case 2: // There is one entry. + case 3: // There is one entry. if (currentDomain.endsWith(blackListEntry[0]) && resourceUrl.startsWith(blackListEntry[1])) { - Log.i("BlockLists", "Request blocked by " + blockListTitle + " third-party domain initial black list: " + blackListEntry[0] + " , " + blackListEntry[1] + " - " + - resourceUrl); - + // Store the entry in the resource request log. + MainWebViewActivity.resourceRequests.add(new String[] {String.valueOf(MainWebViewActivity.REQUEST_BLOCKED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.THIRD_PARTY_DOMAIN_INITIAL_BLACKLIST), blackListEntry[0] + "\n" + blackListEntry[1], blackListEntry[2]}); // Blocked. return true; } break; - case 3: // There are two entries. + case 4: // There are two entries. if (currentDomain.endsWith(blackListEntry[0]) && resourceUrl.startsWith(blackListEntry[1]) && resourceUrl.contains(blackListEntry[2])) { - Log.i("BlockLists", "Request blocked by " + blockListTitle + " third-party domain initial black list: " + blackListEntry[0] + " , " + blackListEntry[1] + " , " + - blackListEntry[2] + " - " + resourceUrl); + // Store the entry in the resource request log. + MainWebViewActivity.resourceRequests.add(new String[] {String.valueOf(MainWebViewActivity.REQUEST_BLOCKED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.THIRD_PARTY_DOMAIN_INITIAL_BLACKLIST), blackListEntry[0] + "\n" + blackListEntry[1] + "\n" + blackListEntry[2], blackListEntry[3]}); // Blocked. return true; } break; - case 4: // There are three entries. + case 5: // There are three entries. if (currentDomain.endsWith(blackListEntry[0]) && resourceUrl.startsWith(blackListEntry[1]) && resourceUrl.contains(blackListEntry[2]) && resourceUrl.contains(blackListEntry[3])) { - Log.i("BlockLists", "Request blocked by " + blockListTitle + " third-party domain initial black list: " + blackListEntry[0] + " , " + blackListEntry[1] + " , " + - blackListEntry[2] + blackListEntry[3] + " - " + resourceUrl); + // Store the entry in the resource request log. + MainWebViewActivity.resourceRequests.add(new String[] {String.valueOf(MainWebViewActivity.REQUEST_BLOCKED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.THIRD_PARTY_DOMAIN_INITIAL_BLACKLIST), blackListEntry[0] + "\n" + blackListEntry[1] + "\n" + blackListEntry[2] + "\n" + blackListEntry[3], + blackListEntry[4]}); // Blocked. return true; @@ -2156,9 +2251,11 @@ public class BlockListHelper { } // Third-party regular expression black list. - for (String[] blackListEntry : blockList.get(20)) { + for (String[] blackListEntry : blockList.get(MainWebViewActivity.THIRD_PARTY_REGULAR_EXPRESSION_BLACKLIST)) { if (Pattern.matches(blackListEntry[0], resourceUrl)) { - Log.i("BlockLists", "Request blocked by " + blockListTitle + " third-party regular expression black list: " + blackListEntry[0] + " - " + resourceUrl); + // Store the entry in the resource request log. + MainWebViewActivity.resourceRequests.add(new String[] {String.valueOf(MainWebViewActivity.REQUEST_BLOCKED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.THIRD_PARTY_REGULAR_EXPRESSION_BLACKLIST), blackListEntry[0], blackListEntry[1]}); // Blocked. return true; @@ -2166,10 +2263,11 @@ public class BlockListHelper { } // Third-party domain regular expression black list. - for (String[] blackListEntry : blockList.get(21)) { + for (String[] blackListEntry : blockList.get(MainWebViewActivity.THIRD_PARTY_DOMAIN_REGULAR_EXPRESSION_BLACKLIST)) { if (currentDomain.endsWith(blackListEntry[0]) && Pattern.matches(blackListEntry[1], resourceUrl)) { - Log.i("BlockLists", "Request blocked by " + blockListTitle + " third-party domain regular expression black list: " + blackListEntry[0] + " , " + blackListEntry[1] + " - " + - resourceUrl); + // Store the entry in the resource request log. + MainWebViewActivity.resourceRequests.add(new String[] {String.valueOf(MainWebViewActivity.REQUEST_BLOCKED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.THIRD_PARTY_DOMAIN_REGULAR_EXPRESSION_BLACKLIST), blackListEntry[0] + "\n" + blackListEntry[1], blackListEntry[2]}); // Blocked. return true; @@ -2178,9 +2276,11 @@ public class BlockListHelper { } // Regular expression black list. - for (String[] blackListEntry : blockList.get(22)) { + for (String[] blackListEntry : blockList.get(MainWebViewActivity.REGULAR_EXPRESSION_BLACKLIST)) { if (Pattern.matches(blackListEntry[0], resourceUrl)) { - Log.i("BlockLists", "Request blocked by " + blockListTitle + " regular expression black list: " + blackListEntry[0] + " - " + resourceUrl); + // Store the entry in the resource request log. + MainWebViewActivity.resourceRequests.add(new String[] {String.valueOf(MainWebViewActivity.REQUEST_BLOCKED), resourceUrl, BLOCK_LIST_NAME_STRING, + String.valueOf(MainWebViewActivity.REGULAR_EXPRESSION_BLACKLIST), blackListEntry[0], blackListEntry[1]}); // blocked. return true;