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

Delta Between Two Patch Sets: src/org/adblockplus/libadblockplus/FilterEngine.java

Issue 6606493159784448: New JNI bindings (Closed)
Left Patch Set: Reuploaded full diff Created March 28, 2014, 3:56 p.m.
Right Patch Set: Removed TODO from AppInfo. Created April 11, 2014, 1:28 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
LEFTRIGHT
(no file at all)
1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
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/>.
16 */
17
18 package org.adblockplus.libadblockplus;
19
20 import java.util.List;
21
22 import com.github.rjeschke.neetutils.dispose.Disposable;
23 import com.github.rjeschke.neetutils.dispose.Disposer;
24
25 public final class FilterEngine implements Disposable
26 {
27 private final Disposer disposer;
28 protected final long ptr;
29
30 static
31 {
32 System.loadLibrary("adblockplus-jni");
33 registerNatives();
34 }
35
36 public FilterEngine(final JsEngine jsEngine)
37 {
38 this.ptr = ctor(jsEngine.ptr);
39 this.disposer = new Disposer(this, new DisposeWrapper(this.ptr));
40 }
41
42 public boolean isFirstRun()
43 {
44 return isFirstRun(this.ptr);
45 }
46
47 public Filter getFilter(final String text)
48 {
49 return getFilter(this.ptr, text);
50 }
51
52 public List<Filter> getListedFilters()
53 {
54 return getListedFilters(this.ptr);
55 }
56
57 public Subscription getSubscription(final String url)
58 {
59 return getSubscription(this.ptr, url);
60 }
61
62 public List<Subscription> getListedSubscriptions()
63 {
64 return getListedSubscriptions(this.ptr);
65 }
66
67 public List<Subscription> fetchAvailableSubscriptions()
68 {
69 return fetchAvailableSubscriptions(this.ptr);
70 }
71
72 public void removeFilterChangeCallback()
73 {
74 removeFilterChangeCallback(this.ptr);
75 }
76
77 public void setFilterChangeCallback(final FilterChangeCallback callback)
78 {
79 setFilterChangeCallback(this.ptr, callback.ptr);
80 }
81
82 public void forceUpdateCheck()
83 {
84 forceUpdateCheck(this.ptr, 0);
85 }
86
87 public void forceUpdateCheck(final UpdaterCallback callback)
88 {
89 forceUpdateCheck(this.ptr, callback != null ? callback.ptr : 0);
90 }
91
92 public List<String> getElementHidingSelectors(final String domain)
93 {
94 return getElementHidingSelectors(this.ptr, domain);
95 }
96
97 public Filter matches(final String url, final String contentType, final String documentUrl)
98 {
99 return matches(this.ptr, url, contentType, documentUrl);
100 }
101
102 public Filter matches(final String url, final String contentType, final String [] documentUrls)
103 {
104 return matches(this.ptr, url, contentType, documentUrls);
105 }
106
107 public JsValue getPref(final String pref)
108 {
109 return getPref(this.ptr, pref);
110 }
111
112 public void setPref(final String pref, final JsValue value)
113 {
114 setPref(this.ptr, pref, value.ptr);
115 }
116
117 @Override
118 public void dispose()
119 {
120 this.disposer.dispose();
121 }
122
123 private final static class DisposeWrapper implements Disposable
124 {
125 private final long ptr;
126
127 public DisposeWrapper(final long ptr)
128 {
129 this.ptr = ptr;
130 }
131
132 @Override
133 public void dispose()
134 {
135 dtor(this.ptr);
136 }
137 }
138
139 private final static native void registerNatives();
140
141 private final static native long ctor(long jsEnginePtr);
142
143 private final static native boolean isFirstRun(long ptr);
144
145 private final static native Filter getFilter(long ptr, String text);
146
147 private final static native List<Filter> getListedFilters(long ptr);
148
149 private final static native Subscription getSubscription(long ptr, String url) ;
150
151 private final static native List<Subscription> getListedSubscriptions(long ptr );
152
153 private final static native List<Subscription> fetchAvailableSubscriptions(lon g ptr);
154
155 private final static native void removeFilterChangeCallback(long ptr);
156
157 private final static native void setFilterChangeCallback(long ptr, long filter Ptr);
158
159 private final static native void forceUpdateCheck(long ptr, long updatePtr);
160
161 private final static native List<String> getElementHidingSelectors(long ptr, S tring domain);
162
163 private final static native JsValue getPref(long ptr, String pref);
164
165 private final static native Filter matches(long ptr, String url, String conten tType, String documentUrl);
166
167 private final static native Filter matches(long ptr, String url, String conten tType, String[] documentUrls);
168
169 private final static native void setPref(long ptr, String pref, long valuePtr) ;
170
171 private final static native void dtor(long ptr);
172 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld