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

Side by Side Diff: libadblockplus-android/src/org/adblockplus/libadblockplus/FilterEngine.java

Issue 29536629: Issue 5556 - Update to use libadblockplus revision hg:566f64c8a2a8 (Closed) Base URL: github.com:abby-sergz/libadblockplus-android.git
Patch Set: address comment Created Sept. 8, 2017, 12:20 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 package org.adblockplus.libadblockplus; 18 package org.adblockplus.libadblockplus;
19 19
20 import java.util.List; 20 import java.util.List;
21 21
22 public final class FilterEngine implements Disposable 22 public final class FilterEngine
23 { 23 {
24 private final Disposer disposer;
25 protected final long ptr; 24 protected final long ptr;
26 25
27 static 26 static
28 { 27 {
29 System.loadLibrary("adblockplus-jni"); 28 System.loadLibrary("adblockplus-jni");
30 registerNatives(); 29 registerNatives();
31 } 30 }
32 31
33 public static enum ContentType 32 public static enum ContentType
34 { 33 {
35 OTHER, SCRIPT, IMAGE, STYLESHEET, OBJECT, SUBDOCUMENT, DOCUMENT, XMLHTTPREQU EST, 34 OTHER, SCRIPT, IMAGE, STYLESHEET, OBJECT, SUBDOCUMENT, DOCUMENT, WEBSOCKET,
36 OBJECT_SUBREQUEST, FONT, MEDIA 35 WEBRTC, PING, XMLHTTPREQUEST, OBJECT_SUBREQUEST, MEDIA, FONT, GENERICBLOCK,
36 ELEMHIDE, GENERICHIDE
37 } 37 }
38 38
39 public FilterEngine(final JsEngine jsEngine, final IsAllowedConnectionCallback isSubscriptionDownloadAllowedCallback) 39 FilterEngine(long jniPlatformPtr)
40 { 40 {
41 this.ptr = ctor(jsEngine.ptr, isSubscriptionDownloadAllowedCallback); 41 this.ptr = jniPlatformPtr;
42 this.disposer = new Disposer(this, new DisposeWrapper(this.ptr));
43 }
44
45 public FilterEngine(final JsEngine jsEngine)
46 {
47 this(jsEngine, null);
48 } 42 }
49 43
50 public boolean isFirstRun() 44 public boolean isFirstRun()
51 { 45 {
52 return isFirstRun(this.ptr); 46 return isFirstRun(this.ptr);
53 } 47 }
54 48
55 public Filter getFilter(final String text) 49 public Filter getFilter(final String text)
56 { 50 {
57 return getFilter(this.ptr, text); 51 return getFilter(this.ptr, text);
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 /** 189 /**
196 * Schedules updating of a subscription corresponding to the passed URL. 190 * Schedules updating of a subscription corresponding to the passed URL.
197 * @param subscriptionUrl may contain query parameters, only the beginning of the string is used 191 * @param subscriptionUrl may contain query parameters, only the beginning of the string is used
198 * to find a corresponding subscription. 192 * to find a corresponding subscription.
199 */ 193 */
200 public void updateFiltersAsync(String subscriptionUrl) 194 public void updateFiltersAsync(String subscriptionUrl)
201 { 195 {
202 updateFiltersAsync(this.ptr, subscriptionUrl); 196 updateFiltersAsync(this.ptr, subscriptionUrl);
203 } 197 }
204 198
205 @Override
206 public void dispose()
207 {
208 this.disposer.dispose();
209 }
210
211 private final static class DisposeWrapper implements Disposable
212 {
213 private final long ptr;
214
215 public DisposeWrapper(final long ptr)
216 {
217 this.ptr = ptr;
218 }
219
220 @Override
221 public void dispose()
222 {
223 dtor(this.ptr);
224 }
225 }
226
227 private final static native void registerNatives(); 199 private final static native void registerNatives();
228 200
229 private final static native long ctor(long jsEnginePtr, IsAllowedConnectionCal lback isSubscriptionDownloadAllowedCallback);
230
231 private final static native boolean isFirstRun(long ptr); 201 private final static native boolean isFirstRun(long ptr);
232 202
233 private final static native Filter getFilter(long ptr, String text); 203 private final static native Filter getFilter(long ptr, String text);
234 204
235 private final static native List<Filter> getListedFilters(long ptr); 205 private final static native List<Filter> getListedFilters(long ptr);
236 206
237 private final static native Subscription getSubscription(long ptr, String url) ; 207 private final static native Subscription getSubscription(long ptr, String url) ;
238 208
239 private final static native List<Subscription> getListedSubscriptions(long ptr ); 209 private final static native List<Subscription> getListedSubscriptions(long ptr );
240 210
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 246
277 private final static native String getAllowedConnectionType(long ptr); 247 private final static native String getAllowedConnectionType(long ptr);
278 248
279 private final static native void setAcceptableAdsEnabled(long ptr, boolean ena bled); 249 private final static native void setAcceptableAdsEnabled(long ptr, boolean ena bled);
280 250
281 private final static native boolean isAcceptableAdsEnabled(long ptr); 251 private final static native boolean isAcceptableAdsEnabled(long ptr);
282 252
283 private final static native String getAcceptableAdsSubscriptionURL(long ptr); 253 private final static native String getAcceptableAdsSubscriptionURL(long ptr);
284 254
285 private final static native void updateFiltersAsync(long ptr, String subscript ionUrl); 255 private final static native void updateFiltersAsync(long ptr, String subscript ionUrl);
286
287 private final static native void dtor(long ptr);
288 } 256 }
OLDNEW

Powered by Google App Engine
This is Rietveld