| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 Eyeo GmbH |
| 4 * | 4 * |
| 5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
| 7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
| 8 * | 8 * |
| 9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 import java.util.concurrent.atomic.AtomicBoolean; | 59 import java.util.concurrent.atomic.AtomicBoolean; |
| 60 import java.util.regex.Pattern; | 60 import java.util.regex.Pattern; |
| 61 | 61 |
| 62 /** | 62 /** |
| 63 * WebView with ad blocking | 63 * WebView with ad blocking |
| 64 */ | 64 */ |
| 65 public class AdblockWebView extends WebView | 65 public class AdblockWebView extends WebView |
| 66 { | 66 { |
| 67 private static final String TAG = Utils.getTag(AdblockWebView.class); | 67 private static final String TAG = Utils.getTag(AdblockWebView.class); |
| 68 | 68 |
| 69 // basePath to store subscription files |
| 70 public static final String BASE_PATH_DIRECTORY = "adblock"; |
| 71 |
| 69 /** | 72 /** |
| 70 * Default (in some conditions) start redraw delay after DOM modified with inj
ected JS (millis) | 73 * Default (in some conditions) start redraw delay after DOM modified with inj
ected JS (millis) |
| 71 */ | 74 */ |
| 72 public static final int ALLOW_DRAW_DELAY = 200; | 75 public static final int ALLOW_DRAW_DELAY = 200; |
| 73 /* | 76 /* |
| 74 The value could be different for devices and completely unclear why we need
it and | 77 The value could be different for devices and completely unclear why we need
it and |
| 75 how to measure actual value | 78 how to measure actual value |
| 76 */ | 79 */ |
| 77 | 80 |
| 78 protected static final String HEADER_REFERRER = "Referer"; | 81 protected static final String HEADER_REFERRER = "Referer"; |
| (...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 947 { | 950 { |
| 948 intWebViewClient = new AdblockWebViewClient(); | 951 intWebViewClient = new AdblockWebViewClient(); |
| 949 applyAdblockEnabled(); | 952 applyAdblockEnabled(); |
| 950 } | 953 } |
| 951 | 954 |
| 952 private void createAdblockEngine() | 955 private void createAdblockEngine() |
| 953 { | 956 { |
| 954 w("Creating AdblockEngine"); | 957 w("Creating AdblockEngine"); |
| 955 | 958 |
| 956 // assuming `this.debugMode` can be used as `developmentBuild` value | 959 // assuming `this.debugMode` can be used as `developmentBuild` value |
| 957 adblockEngine = AdblockEngine.create( | 960 adblockEngine = AdblockEngine |
| 958 AdblockEngine.generateAppInfo(this.getContext(), debugMode), | 961 .builder( |
| 959 this.getContext().getCacheDir().getAbsolutePath(), | 962 AdblockEngine.generateAppInfo(this.getContext(), debugMode), |
| 960 true); | 963 this.getContext().getDir(BASE_PATH_DIRECTORY, Context.MODE_PRIVATE).getA
bsolutePath()) |
| 964 .enableElementHiding(true) |
| 965 .build(); |
| 961 } | 966 } |
| 962 | 967 |
| 963 private class ElemHideThread extends Thread | 968 private class ElemHideThread extends Thread |
| 964 { | 969 { |
| 965 private String selectorsString; | 970 private String selectorsString; |
| 966 private CountDownLatch finishedLatch; | 971 private CountDownLatch finishedLatch; |
| 967 private AtomicBoolean isCancelled; | 972 private AtomicBoolean isCancelled; |
| 968 | 973 |
| 969 public ElemHideThread(CountDownLatch finishedLatch) | 974 public ElemHideThread(CountDownLatch finishedLatch) |
| 970 { | 975 { |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1415 w("Busy with elemhide selectors, delayed disposing scheduled"); | 1420 w("Busy with elemhide selectors, delayed disposing scheduled"); |
| 1416 elemHideThread.setFinishedRunnable(disposeRunnable); | 1421 elemHideThread.setFinishedRunnable(disposeRunnable); |
| 1417 } | 1422 } |
| 1418 else | 1423 else |
| 1419 { | 1424 { |
| 1420 disposeRunnable.run(); | 1425 disposeRunnable.run(); |
| 1421 } | 1426 } |
| 1422 } | 1427 } |
| 1423 } | 1428 } |
| 1424 } | 1429 } |
| OLD | NEW |