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

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

Issue 29379647: Issue 4948 - add possibility to not send data depending on connection properties (Closed)
Patch Set: updated dependency to binaries, updated comment for allowed connection type Created March 30, 2017, 2:12 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-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 18 matching lines...) Expand all
29 System.loadLibrary("adblockplus-jni"); 29 System.loadLibrary("adblockplus-jni");
30 registerNatives(); 30 registerNatives();
31 } 31 }
32 32
33 public static enum ContentType 33 public static enum ContentType
34 { 34 {
35 OTHER, SCRIPT, IMAGE, STYLESHEET, OBJECT, SUBDOCUMENT, DOCUMENT, XMLHTTPREQU EST, 35 OTHER, SCRIPT, IMAGE, STYLESHEET, OBJECT, SUBDOCUMENT, DOCUMENT, XMLHTTPREQU EST,
36 OBJECT_SUBREQUEST, FONT, MEDIA 36 OBJECT_SUBREQUEST, FONT, MEDIA
37 } 37 }
38 38
39 public FilterEngine(final JsEngine jsEngine, final IsAllowedConnectionCallback isAllowedConnectionCallback)
40 {
41 long jisAllowedConnectionCallbackPtr =
42 (isAllowedConnectionCallback != null
43 ? isAllowedConnectionCallback.ptr
44 : 0l);
45 this.ptr = ctor(jsEngine.ptr, jisAllowedConnectionCallbackPtr);
46 this.disposer = new Disposer(this, new DisposeWrapper(this.ptr));
47 }
48
39 public FilterEngine(final JsEngine jsEngine) 49 public FilterEngine(final JsEngine jsEngine)
40 { 50 {
41 this.ptr = ctor(jsEngine.ptr); 51 this(jsEngine, null);
42 this.disposer = new Disposer(this, new DisposeWrapper(this.ptr));
43 } 52 }
44 53
45 public boolean isFirstRun() 54 public boolean isFirstRun()
46 { 55 {
47 return isFirstRun(this.ptr); 56 return isFirstRun(this.ptr);
48 } 57 }
49 58
50 public Filter getFilter(final String text) 59 public Filter getFilter(final String text)
51 { 60 {
52 return getFilter(this.ptr, text); 61 return getFilter(this.ptr, text);
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 public void setPref(final String pref, final JsValue value) 164 public void setPref(final String pref, final JsValue value)
156 { 165 {
157 setPref(this.ptr, pref, value.ptr); 166 setPref(this.ptr, pref, value.ptr);
158 } 167 }
159 168
160 public String getHostFromURL(String url) 169 public String getHostFromURL(String url)
161 { 170 {
162 return getHostFromURL(this.ptr, url); 171 return getHostFromURL(this.ptr, url);
163 } 172 }
164 173
174 public void setAllowedConnectionType(String value)
175 {
176 setAllowedConnectionType(this.ptr, value);
177 }
178
179 public String getAllowedConnectionType()
180 {
181 return getAllowedConnectionType(this.ptr);
182 }
183
165 @Override 184 @Override
166 public void dispose() 185 public void dispose()
167 { 186 {
168 this.disposer.dispose(); 187 this.disposer.dispose();
169 } 188 }
170 189
171 private final static class DisposeWrapper implements Disposable 190 private final static class DisposeWrapper implements Disposable
172 { 191 {
173 private final long ptr; 192 private final long ptr;
174 193
175 public DisposeWrapper(final long ptr) 194 public DisposeWrapper(final long ptr)
176 { 195 {
177 this.ptr = ptr; 196 this.ptr = ptr;
178 } 197 }
179 198
180 @Override 199 @Override
181 public void dispose() 200 public void dispose()
182 { 201 {
183 dtor(this.ptr); 202 dtor(this.ptr);
184 } 203 }
185 } 204 }
186 205
187 private final static native void registerNatives(); 206 private final static native void registerNatives();
188 207
189 private final static native long ctor(long jsEnginePtr); 208 private final static native long ctor(long jsEnginePtr, long isAllowedConnecti onCallbackPtr);
190 209
191 private final static native boolean isFirstRun(long ptr); 210 private final static native boolean isFirstRun(long ptr);
192 211
193 private final static native Filter getFilter(long ptr, String text); 212 private final static native Filter getFilter(long ptr, String text);
194 213
195 private final static native List<Filter> getListedFilters(long ptr); 214 private final static native List<Filter> getListedFilters(long ptr);
196 215
197 private final static native Subscription getSubscription(long ptr, String url) ; 216 private final static native Subscription getSubscription(long ptr, String url) ;
198 217
199 private final static native List<Subscription> getListedSubscriptions(long ptr ); 218 private final static native List<Subscription> getListedSubscriptions(long ptr );
(...skipping 25 matching lines...) Expand all
225 private final static native Filter matches(long ptr, String url, ContentType c ontentType, String[] documentUrls); 244 private final static native Filter matches(long ptr, String url, ContentType c ontentType, String[] documentUrls);
226 245
227 private final static native boolean isDocumentWhitelisted(long ptr, String url , String[] documentUrls); 246 private final static native boolean isDocumentWhitelisted(long ptr, String url , String[] documentUrls);
228 247
229 private final static native boolean isElemhideWhitelisted(long ptr, String url , String[] documentUrls); 248 private final static native boolean isElemhideWhitelisted(long ptr, String url , String[] documentUrls);
230 249
231 private final static native void setPref(long ptr, String pref, long valuePtr) ; 250 private final static native void setPref(long ptr, String pref, long valuePtr) ;
232 251
233 private final static native String getHostFromURL(long ptr, String url); 252 private final static native String getHostFromURL(long ptr, String url);
234 253
254 private final static native void setAllowedConnectionType(long ptr, String val ue);
255
256 private final static native String getAllowedConnectionType(long ptr);
257
235 private final static native void dtor(long ptr); 258 private final static native void dtor(long ptr);
236 } 259 }
OLDNEW

Powered by Google App Engine
This is Rietveld