Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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-present eyeo GmbH | 3 * Copyright (C) 2006-present 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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
229 | 229 |
230 private void runScript(String script) | 230 private void runScript(String script) |
231 { | 231 { |
232 d("runScript started"); | 232 d("runScript started"); |
233 evaluateJavascript(script, null); | 233 evaluateJavascript(script, null); |
234 d("runScript finished"); | 234 d("runScript finished"); |
235 } | 235 } |
236 | 236 |
237 public void setProvider(final AdblockEngineProvider provider) | 237 public void setProvider(final AdblockEngineProvider provider) |
238 { | 238 { |
239 if (this.provider != null && provider != null && this.provider == provider) | 239 if (this.provider != null && provider != null && this.provider == provider) |
sergei
2018/01/19 13:56:41
So, if both this.provider and provider are null th
diegocarloslima
2018/01/19 15:56:11
We can add the @NonNull annotation for AdblockEngi
anton
2018/01/22 06:17:36
I'd prefer to fix it by adding `null` check.
| |
240 { | 240 { |
241 return; | 241 return; |
242 } | 242 } |
243 | 243 |
244 final Runnable setRunnable = new Runnable() | 244 final Runnable setRunnable = new Runnable() |
245 { | 245 { |
246 @Override | 246 @Override |
247 public void run() | 247 public void run() |
248 { | 248 { |
249 AdblockWebView.this.provider = provider; | 249 AdblockWebView.this.provider = provider; |
250 AdblockWebView.this.provider.retain(true); // asynchronously | 250 if (AdblockWebView.this.provider != null) |
251 { | |
252 AdblockWebView.this.provider.retain(true); // asynchronously | |
253 } | |
251 } | 254 } |
252 }; | 255 }; |
253 | 256 |
254 if (this.provider != null) | 257 if (this.provider != null) |
255 { | 258 { |
256 // as adblockEngine can be busy with elemhide thread we need to use callba ck | 259 // as adblockEngine can be busy with elemhide thread we need to use callba ck |
257 this.dispose(setRunnable); | 260 this.dispose(setRunnable); |
258 } | 261 } |
259 else | 262 else |
260 { | 263 { |
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
958 { | 961 { |
959 this.finishedLatch = finishedLatch; | 962 this.finishedLatch = finishedLatch; |
960 isCancelled = new AtomicBoolean(false); | 963 isCancelled = new AtomicBoolean(false); |
961 } | 964 } |
962 | 965 |
963 @Override | 966 @Override |
964 public void run() | 967 public void run() |
965 { | 968 { |
966 try | 969 try |
967 { | 970 { |
968 if (provider.getCounter() == 0) | 971 if (provider.getCounter() == 0) |
sergei
2018/01/19 13:56:41
Can it actually happen and if so, why it cannot ha
anton
2018/01/22 06:17:36
I've just reviewed the code and it seems that it c
| |
969 { | 972 { |
970 w("FilterEngine already disposed"); | 973 w("FilterEngine already disposed"); |
971 selectorsString = EMPTY_ELEMHIDE_ARRAY_STRING; | 974 selectorsString = EMPTY_ELEMHIDE_ARRAY_STRING; |
972 } | 975 } |
973 else | 976 else |
974 { | 977 { |
975 String[] referrers = new String[] | 978 String[] referrers = new String[] |
976 { | 979 { |
977 url | 980 url |
978 }; | 981 }; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1074 w("elemHideThread set to null"); | 1077 w("elemHideThread set to null"); |
1075 elemHideThread = null; | 1078 elemHideThread = null; |
1076 } | 1079 } |
1077 } | 1080 } |
1078 }; | 1081 }; |
1079 | 1082 |
1080 private void initAbpLoading() | 1083 private void initAbpLoading() |
1081 { | 1084 { |
1082 getSettings().setJavaScriptEnabled(true); | 1085 getSettings().setJavaScriptEnabled(true); |
1083 buildInjectJs(); | 1086 buildInjectJs(); |
1084 initProvider(); | 1087 ensureProvider(); |
1085 } | 1088 } |
1086 | 1089 |
1087 private void initProvider() | 1090 private void ensureProvider() |
sergei
2018/01/19 13:56:41
Would it be better to call it ensureAbpProvider()?
anton
2018/01/22 06:17:36
Acknowledged.
| |
1088 { | 1091 { |
1089 // if AdblockWebView works as drop-in replacement for WebView 'provider' is not set. | 1092 // if AdblockWebView works as drop-in replacement for WebView 'provider' is not set. |
1090 // Thus AdblockWebView is using SingleInstanceEngineProvider instance | 1093 // Thus AdblockWebView is using SingleInstanceEngineProvider instance |
1091 if (provider == null) | 1094 if (provider == null) |
1092 { | 1095 { |
1093 setProvider(new SingleInstanceEngineProvider( | 1096 setProvider(new SingleInstanceEngineProvider( |
1094 getContext(), AdblockEngine.BASE_PATH_DIRECTORY, debugMode)); | 1097 getContext(), AdblockEngine.BASE_PATH_DIRECTORY, debugMode)); |
1095 } | 1098 } |
1096 } | 1099 } |
1097 | 1100 |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1425 w("Busy with elemhide selectors, delayed disposing scheduled"); | 1428 w("Busy with elemhide selectors, delayed disposing scheduled"); |
1426 elemHideThread.setFinishedRunnable(disposeRunnable); | 1429 elemHideThread.setFinishedRunnable(disposeRunnable); |
1427 } | 1430 } |
1428 else | 1431 else |
1429 { | 1432 { |
1430 disposeRunnable.run(); | 1433 disposeRunnable.run(); |
1431 } | 1434 } |
1432 } | 1435 } |
1433 } | 1436 } |
1434 } | 1437 } |
LEFT | RIGHT |