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<List<String[]>> parseBlockList(AssetManager assets, String blockListName) {
// Initialize the header list.
- List<String[]> headers = new LinkedList<>();
-
- // Initialize the white lists.
- List<String[]> mainWhiteList = new LinkedList<>();
- List<String[]> finalWhiteList = new LinkedList<>();
- List<String[]> domainWhiteList = new LinkedList<>();
- List<String[]> domainInitialWhiteList = new LinkedList<>();
- List<String[]> domainFinalWhiteList = new LinkedList<>();
- List<String[]> thirdPartyWhiteList = new LinkedList<>();
- List<String[]> thirdPartyDomainWhiteList = new LinkedList<>();
- List<String[]> thirdPartyDomainInitialWhiteList = new LinkedList<>();
-
- // Initialize the black lists
- List<String[]> mainBlackList = new LinkedList<>();
- List<String[]> initialBlackList = new LinkedList<>();
- List<String[]> finalBlackList = new LinkedList<>();
- List<String[]> domainBlackList = new LinkedList<>();
- List<String[]> domainInitialBlackList = new LinkedList<>();
- List<String[]> domainFinalBlackList = new LinkedList<>();
- List<String[]> thirdPartyBlackList = new LinkedList<>();
- List<String[]> thirdPartyInitialBlackList = new LinkedList<>();
- List<String[]> thirdPartyDomainBlackList = new LinkedList<>();
- List<String[]> thirdPartyDomainInitialBlackList = new LinkedList<>();
- List<String[]> regularExpressionBlackList = new LinkedList<>();
- List<String[]> domainRegularExpressionBlackList = new LinkedList<>();
- List<String[]> thirdPartyRegularExpressionBlackList = new LinkedList<>();
- List<String[]> thirdPartyDomainRegularExpressionBlackList = new LinkedList<>();
+ List<String[]> headers = new ArrayList<>(); // 0.
+
+ // Initialize the whitelists.
+ List<String[]> mainWhiteList = new ArrayList<>(); // 1.
+ List<String[]> finalWhiteList = new ArrayList<>(); // 2.
+ List<String[]> domainWhiteList = new ArrayList<>(); // 3.
+ List<String[]> domainInitialWhiteList = new ArrayList<>(); // 4.
+ List<String[]> domainFinalWhiteList = new ArrayList<>(); // 5.
+ List<String[]> thirdPartyWhiteList = new ArrayList<>(); // 6.
+ List<String[]> thirdPartyDomainWhiteList = new ArrayList<>(); // 7.
+ List<String[]> thirdPartyDomainInitialWhiteList = new ArrayList<>(); // 8.
+
+ // Initialize the blacklists
+ List<String[]> mainBlackList = new ArrayList<>(); // 9.
+ List<String[]> initialBlackList = new ArrayList<>(); // 10.
+ List<String[]> finalBlackList = new ArrayList<>(); // 11.
+ List<String[]> domainBlackList = new ArrayList<>(); // 12.
+ List<String[]> domainInitialBlackList = new ArrayList<>(); // 13.
+ List<String[]> domainFinalBlackList = new ArrayList<>(); // 14.
+ List<String[]> domainRegularExpressionBlackList = new ArrayList<>(); // 15.
+ List<String[]> thirdPartyBlackList = new ArrayList<>(); // 16.
+ List<String[]> thirdPartyInitialBlackList = new ArrayList<>(); // 17.
+ List<String[]> thirdPartyDomainBlackList = new ArrayList<>(); // 18.
+ List<String[]> thirdPartyDomainInitialBlackList = new ArrayList<>(); // 19.
+ List<String[]> regularExpressionBlackList = new ArrayList<>(); // 20.
+ List<String[]> thirdPartyRegularExpressionBlackList = new ArrayList<>(); // 21.
+ List<String[]> thirdPartyDomainRegularExpressionBlackList = new ArrayList<>(); // 22.
// Populate the block lists. The `try` is required by `InputStreamReader`.
// 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.
// 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 //noinspection StatementWithEmptyBody
+ if (blockListEntry.contains("$websocket") || blockListEntry.contains("$third-party,websocket") || blockListEntry.contains("$script,websocket")) { // Ignore entries with `websocket`.
+ // Do nothing. Privacy Browser does not differentiate between websocket requests and other requests and these entries cause a lot of false positivies.
+
+ //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.
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);
// " - " + 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);
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);
// 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);
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);
// 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);
}
} 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);
}
} 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);
}
} 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);
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);
// 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);
}
} 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);
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);
// 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);
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);
// 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);
}
} 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);
}
} 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);
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);
//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);
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);
//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);
}
} 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);
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);
//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);
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);
// " , " + 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);
}
} 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);
}
// Create an entry string array.
- String[] domainEntry = {domain, entry};
+ String[] domainEntry = {domain, entry, originalBlockListEntry};
// Add the entry to the black list.
thirdPartyDomainRegularExpressionBlackList.add(domainEntry);
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);
// 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);
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);
// 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);
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);
//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);
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);
//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);
}
// Create an entry string array.
- String[] singleEntry = {entry};
+ String[] singleEntry = {entry, originalBlockListEntry};
// Add the entry to the black list.
thirdPartyRegularExpressionBlackList.add(singleEntry);
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);
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);
// 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);
}
} 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);
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);
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);
// " - " + 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);
}
} 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);
//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);
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);
// 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);
}
} 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);
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);
// " - " + 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);
}
} 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);
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);
//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);
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);
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);
//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);
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);
// 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);
}
} 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);
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);
//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);
}
} 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);
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);
//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);
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);
// 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);
}
} 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);
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);
// 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);
}
} 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);
}
} 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);
}
} 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);
return combinedLists;
}
- public boolean isBlocked(String currentUrl, String resourceUrl, ArrayList<List<String[]>> blockList) {
- // Get the list title.
- String blockListTitle = blockList.get(0).get(1)[0];
-
- Uri currentUri = Uri.parse(currentUrl);
- String currentDomain = currentUri.getHost();
-
- Uri resourceUri = Uri.parse(resourceUrl);
- String resourceDomain = resourceUri.getHost();
+ public boolean isBlocked(String currentDomain, String resourceUrl, boolean isThirdPartyRequest, ArrayList<List<String[]>> blockList) {
+ // Get the block list name.
+ String BLOCK_LIST_NAME_STRING = blockList.get(0).get(1)[0];
- boolean thirdPartyRequest = false;
-
- // If one of the domains is `about:blank` it will throw a null object reference on the string comparison.
- if ((currentDomain != null) && (resourceDomain != null)) {
- thirdPartyRequest = !resourceDomain.equals(currentDomain);
+ // Assert that currentDomain != null only if this is a third party request. Apparently, lint can't tell that this isn't redundant.
+ //noinspection RedundantIfStatement
+ if (isThirdPartyRequest) {
+ assert currentDomain != null;
}
// 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;
}
// 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;
// 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;
}
// 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;
}
// 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;
}
// Only check the third-party white lists if this is a third-party request.
- if (thirdPartyRequest) {
+ if (isThirdPartyRequest) {
// 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;
}
// 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;
}
// 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;
// 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;
}
// 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;
}
// 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;
// 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;
}
// 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;
}
// 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;
}
// 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;
}
// Only check the third-party black lists if this is a third-party request.
- if (thirdPartyRequest) {
+ if (isThirdPartyRequest) {
// 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;
}
// 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;
}
// 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;
}
// 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;
}
// 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;
}
// 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;
}
// 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;