Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: adblock-android/src/org/adblockplus/libadblockplus/android/AdblockEngine.java

Issue 29908555: Issue 7035 - Update libadblockplus dependency (Closed) Base URL: git@github.com:adblockplus/libadblockplus-android.git@d150f08d5d72de8938c7ebbdccd9b0c4e06b4070
Left Patch Set: Created Oct. 12, 2018, 9:13 a.m.
Right Patch Set: Issue 7035 - Update libadblockplus dependency Created Oct. 16, 2018, 3:17 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « adblock-android/src/org/adblockplus/libadblockplus/UpdateCheckDoneCallback.java ('k') | dependencies » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
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 19 matching lines...) Expand all
30 import org.adblockplus.libadblockplus.Filter; 30 import org.adblockplus.libadblockplus.Filter;
31 import org.adblockplus.libadblockplus.FilterChangeCallback; 31 import org.adblockplus.libadblockplus.FilterChangeCallback;
32 import org.adblockplus.libadblockplus.FilterEngine; 32 import org.adblockplus.libadblockplus.FilterEngine;
33 import org.adblockplus.libadblockplus.FilterEngine.ContentType; 33 import org.adblockplus.libadblockplus.FilterEngine.ContentType;
34 import org.adblockplus.libadblockplus.IsAllowedConnectionCallback; 34 import org.adblockplus.libadblockplus.IsAllowedConnectionCallback;
35 import org.adblockplus.libadblockplus.JsValue; 35 import org.adblockplus.libadblockplus.JsValue;
36 import org.adblockplus.libadblockplus.LogSystem; 36 import org.adblockplus.libadblockplus.LogSystem;
37 import org.adblockplus.libadblockplus.Platform; 37 import org.adblockplus.libadblockplus.Platform;
38 import org.adblockplus.libadblockplus.ShowNotificationCallback; 38 import org.adblockplus.libadblockplus.ShowNotificationCallback;
39 import org.adblockplus.libadblockplus.Subscription; 39 import org.adblockplus.libadblockplus.Subscription;
40 import org.adblockplus.libadblockplus.UpdateAvailableCallback;
41 import org.adblockplus.libadblockplus.UpdateCheckDoneCallback;
42 import org.adblockplus.libadblockplus.WebRequest; 40 import org.adblockplus.libadblockplus.WebRequest;
43 41
44 import android.content.Context; 42 import android.content.Context;
45 import android.content.pm.PackageInfo; 43 import android.content.pm.PackageInfo;
46 import android.content.pm.PackageManager; 44 import android.content.pm.PackageManager;
47 import android.os.Build.VERSION; 45 import android.os.Build.VERSION;
48 import android.util.Log; 46 import android.util.Log;
49 47
50 public final class AdblockEngine 48 public final class AdblockEngine
51 { 49 {
(...skipping 10 matching lines...) Expand all
62 * release the object, sometimes even on access. 60 * release the object, sometimes even on access.
63 * 61 *
64 * The only solution that really worked was to declare the variables holding t he references 62 * The only solution that really worked was to declare the variables holding t he references
65 * volatile, this seems to prevent the JNI from 'optimizing away' those object s (as a volatile 63 * volatile, this seems to prevent the JNI from 'optimizing away' those object s (as a volatile
66 * variable might be changed at any time from any thread). 64 * variable might be changed at any time from any thread).
67 */ 65 */
68 private volatile Platform platform; 66 private volatile Platform platform;
69 private volatile FilterEngine filterEngine; 67 private volatile FilterEngine filterEngine;
70 private volatile LogSystem logSystem; 68 private volatile LogSystem logSystem;
71 private volatile WebRequest webRequest; 69 private volatile WebRequest webRequest;
72 private volatile UpdateAvailableCallback updateAvailableCallback;
73 private volatile UpdateCheckDoneCallback updateCheckDoneCallback;
74 private volatile FilterChangeCallback filterChangeCallback; 70 private volatile FilterChangeCallback filterChangeCallback;
75 private volatile ShowNotificationCallback showNotificationCallback; 71 private volatile ShowNotificationCallback showNotificationCallback;
76 private volatile boolean elemhideEnabled; 72 private volatile boolean elemhideEnabled;
77 private volatile boolean enabled = true; 73 private volatile boolean enabled = true;
78 private volatile List<String> whitelistedDomains; 74 private volatile List<String> whitelistedDomains;
79 75
80 public static AppInfo generateAppInfo(final Context context, boolean developme ntBuild, 76 public static AppInfo generateAppInfo(final Context context, boolean developme ntBuild,
81 String application, String applicationVe rsion) 77 String application, String applicationVe rsion)
82 { 78 {
83 final String sdkVersion = String.valueOf(VERSION.SDK_INT); 79 final String sdkVersion = String.valueOf(VERSION.SDK_INT);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 164
169 public Builder setIsAllowedConnectionCallback(IsAllowedConnectionCallback ca llback) 165 public Builder setIsAllowedConnectionCallback(IsAllowedConnectionCallback ca llback)
170 { 166 {
171 this.isAllowedConnectionCallback = callback; 167 this.isAllowedConnectionCallback = callback;
172 return this; 168 return this;
173 } 169 }
174 170
175 public Builder useV8IsolateProvider(long v8IsolateProviderPtr) 171 public Builder useV8IsolateProvider(long v8IsolateProviderPtr)
176 { 172 {
177 this.v8IsolateProviderPtr = v8IsolateProviderPtr; 173 this.v8IsolateProviderPtr = v8IsolateProviderPtr;
178 return this;
179 }
180
181 public Builder setUpdateAvailableCallback(UpdateAvailableCallback callback)
182 {
183 engine.updateAvailableCallback = callback;
184 return this;
185 }
186
187 public Builder setUpdateCheckDoneCallback(UpdateCheckDoneCallback callback)
188 {
189 engine.updateCheckDoneCallback = callback;
190 return this; 174 return this;
191 } 175 }
192 176
193 public Builder setShowNotificationCallback(ShowNotificationCallback callback ) 177 public Builder setShowNotificationCallback(ShowNotificationCallback callback )
194 { 178 {
195 engine.showNotificationCallback = callback; 179 engine.showNotificationCallback = callback;
196 return this; 180 return this;
197 } 181 }
198 182
199 public Builder setFilterChangeCallback(FilterChangeCallback callback) 183 public Builder setFilterChangeCallback(FilterChangeCallback callback)
(...skipping 23 matching lines...) Expand all
223 } 207 }
224 } 208 }
225 }); 209 });
226 210
227 engine.webRequest = wrapper; 211 engine.webRequest = wrapper;
228 } 212 }
229 } 213 }
230 214
231 private void initCallbacks() 215 private void initCallbacks()
232 { 216 {
233 if (engine.updateAvailableCallback != null)
234 {
235 engine.filterEngine.setUpdateAvailableCallback(engine.updateAvailableCal lback);
236 }
237
238 if (engine.showNotificationCallback != null) 217 if (engine.showNotificationCallback != null)
239 { 218 {
240 engine.filterEngine.setShowNotificationCallback(engine.showNotificationC allback); 219 engine.filterEngine.setShowNotificationCallback(engine.showNotificationC allback);
241 } 220 }
242 221
243 if (engine.filterChangeCallback != null) 222 if (engine.filterChangeCallback != null)
244 { 223 {
245 engine.filterEngine.setFilterChangeCallback(engine.filterChangeCallback) ; 224 engine.filterEngine.setFilterChangeCallback(engine.filterChangeCallback) ;
246 } 225 }
247 } 226 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 return new Builder(appInfo, basePath); 264 return new Builder(appInfo, basePath);
286 } 265 }
287 266
288 public void dispose() 267 public void dispose()
289 { 268 {
290 Log.w(TAG, "Dispose"); 269 Log.w(TAG, "Dispose");
291 270
292 // engines first 271 // engines first
293 if (this.filterEngine != null) 272 if (this.filterEngine != null)
294 { 273 {
295 if (this.updateAvailableCallback != null)
296 {
297 this.filterEngine.removeUpdateAvailableCallback();
298 }
299 274
300 if (this.filterChangeCallback != null) 275 if (this.filterChangeCallback != null)
301 { 276 {
302 this.filterEngine.removeFilterChangeCallback(); 277 this.filterEngine.removeFilterChangeCallback();
303 } 278 }
304 279
305 if (this.showNotificationCallback != null) 280 if (this.showNotificationCallback != null)
306 { 281 {
307 this.filterEngine.removeShowNotificationCallback(); 282 this.filterEngine.removeShowNotificationCallback();
308 } 283 }
309 284
310 this.platform.dispose(); 285 this.platform.dispose();
311 this.platform = null; 286 this.platform = null;
312 } 287 }
313 288
314 // callbacks then 289 // callbacks then
315 if (this.updateAvailableCallback != null)
316 {
317 this.updateAvailableCallback.dispose();
318 this.updateAvailableCallback = null;
319 }
320
321 if (this.filterChangeCallback != null) 290 if (this.filterChangeCallback != null)
322 { 291 {
323 this.filterChangeCallback.dispose(); 292 this.filterChangeCallback.dispose();
324 this.filterChangeCallback = null; 293 this.filterChangeCallback = null;
325 } 294 }
326 295
327 if (this.showNotificationCallback != null) 296 if (this.showNotificationCallback != null)
328 { 297 {
329 this.showNotificationCallback.dispose(); 298 this.showNotificationCallback.dispose();
330 this.showNotificationCallback = null; 299 this.showNotificationCallback = null;
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 || !this.elemhideEnabled 588 || !this.elemhideEnabled
620 || this.isDomainWhitelisted(url, referrerChainArray) 589 || this.isDomainWhitelisted(url, referrerChainArray)
621 || this.isDocumentWhitelisted(url, referrerChainArray) 590 || this.isDocumentWhitelisted(url, referrerChainArray)
622 || this.isElemhideWhitelisted(url, referrerChainArray)) 591 || this.isElemhideWhitelisted(url, referrerChainArray))
623 { 592 {
624 return new ArrayList<String>(); 593 return new ArrayList<String>();
625 } 594 }
626 return this.filterEngine.getElementHidingSelectors(domain); 595 return this.filterEngine.getElementHidingSelectors(domain);
627 } 596 }
628 597
629 public void checkForUpdates()
630 {
631 this.filterEngine.forceUpdateCheck(this.updateCheckDoneCallback);
632 }
633
634 public FilterEngine getFilterEngine() 598 public FilterEngine getFilterEngine()
635 { 599 {
636 return this.filterEngine; 600 return this.filterEngine;
637 } 601 }
638 602
639 public void setWhitelistedDomains(List<String> domains) 603 public void setWhitelistedDomains(List<String> domains)
640 { 604 {
641 this.whitelistedDomains = domains; 605 this.whitelistedDomains = domains;
642 } 606 }
643 607
644 public List<String> getWhitelistedDomains() 608 public List<String> getWhitelistedDomains()
645 { 609 {
646 return whitelistedDomains; 610 return whitelistedDomains;
647 } 611 }
648 } 612 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld