OLD | NEW |
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 12 matching lines...) Expand all Loading... |
23 { | 23 { |
24 private final Disposer disposer; | 24 private final Disposer disposer; |
25 protected final long ptr; | 25 protected final long ptr; |
26 | 26 |
27 static | 27 static |
28 { | 28 { |
29 System.loadLibrary("adblockplus-jni"); | 29 System.loadLibrary("adblockplus-jni"); |
30 registerNatives(); | 30 registerNatives(); |
31 } | 31 } |
32 | 32 |
| 33 public JsEngine(final AppInfo appInfo, final LogSystem logSystem) |
| 34 { |
| 35 this(ctor(appInfo, logSystem != null ? logSystem.ptr : 0)); |
| 36 } |
| 37 |
33 public JsEngine(final AppInfo appInfo) | 38 public JsEngine(final AppInfo appInfo) |
34 { | 39 { |
35 this(ctor(appInfo)); | 40 this(appInfo, null); |
36 } | 41 } |
37 | 42 |
38 protected JsEngine(final long ptr) | 43 protected JsEngine(final long ptr) |
39 { | 44 { |
40 this.ptr = ptr; | 45 this.ptr = ptr; |
41 this.disposer = new Disposer(this, new DisposeWrapper(ptr)); | 46 this.disposer = new Disposer(this, new DisposeWrapper(ptr)); |
42 } | 47 } |
43 | 48 |
44 public void setEventCallback(final String eventName, final EventCallback callb
ack) | 49 public void setEventCallback(final String eventName, final EventCallback callb
ack) |
45 { | 50 { |
(...skipping 30 matching lines...) Expand all Loading... |
76 public void triggerEvent(final String eventName) | 81 public void triggerEvent(final String eventName) |
77 { | 82 { |
78 triggerEvent(this.ptr, eventName, null); | 83 triggerEvent(this.ptr, eventName, null); |
79 } | 84 } |
80 | 85 |
81 public void setDefaultFileSystem(final String basePath) | 86 public void setDefaultFileSystem(final String basePath) |
82 { | 87 { |
83 setDefaultFileSystem(this.ptr, basePath); | 88 setDefaultFileSystem(this.ptr, basePath); |
84 } | 89 } |
85 | 90 |
86 public void setDefaultLogSystem() | |
87 { | |
88 setDefaultLogSystem(this.ptr); | |
89 } | |
90 | |
91 public void setLogSystem(final LogSystem logSystem) | |
92 { | |
93 setLogSystem(this.ptr, logSystem.ptr); | |
94 } | |
95 | |
96 public void setWebRequest(final WebRequest webRequest) | 91 public void setWebRequest(final WebRequest webRequest) |
97 { | 92 { |
98 setWebRequest(this.ptr, webRequest.ptr); | 93 setWebRequest(this.ptr, webRequest.ptr); |
99 } | 94 } |
100 | 95 |
101 public JsValue newValue(final long value) | 96 public JsValue newValue(final long value) |
102 { | 97 { |
103 return newValue(this.ptr, value); | 98 return newValue(this.ptr, value); |
104 } | 99 } |
105 | 100 |
(...skipping 24 matching lines...) Expand all Loading... |
130 | 125 |
131 @Override | 126 @Override |
132 public void dispose() | 127 public void dispose() |
133 { | 128 { |
134 dtor(this.ptr); | 129 dtor(this.ptr); |
135 } | 130 } |
136 } | 131 } |
137 | 132 |
138 private final static native void registerNatives(); | 133 private final static native void registerNatives(); |
139 | 134 |
140 private final static native long ctor(AppInfo appInfo); | 135 private final static native long ctor(AppInfo appInfo, long logSystemPtr); |
141 | 136 |
142 private final static native void setEventCallback(long ptr, String eventName,
long callback); | 137 private final static native void setEventCallback(long ptr, String eventName,
long callback); |
143 | 138 |
144 private final static native void removeEventCallback(long ptr, String eventNam
e); | 139 private final static native void removeEventCallback(long ptr, String eventNam
e); |
145 | 140 |
146 private final static native JsValue evaluate(long ptr, String source, String f
ilename); | 141 private final static native JsValue evaluate(long ptr, String source, String f
ilename); |
147 | 142 |
148 private final static native void triggerEvent(long ptr, String eventName, long
[] args); | 143 private final static native void triggerEvent(long ptr, String eventName, long
[] args); |
149 | 144 |
150 private final static native void setDefaultFileSystem(long ptr, String basePat
h); | 145 private final static native void setDefaultFileSystem(long ptr, String basePat
h); |
151 | 146 |
152 private final static native void setLogSystem(long ptr, long logSystemPtr); | |
153 | |
154 private final static native void setDefaultLogSystem(long ptr); | |
155 | |
156 private final static native void setWebRequest(long ptr, long webRequestPtr); | 147 private final static native void setWebRequest(long ptr, long webRequestPtr); |
157 | 148 |
158 private final static native JsValue newValue(long ptr, long value); | 149 private final static native JsValue newValue(long ptr, long value); |
159 | 150 |
160 private final static native JsValue newValue(long ptr, boolean value); | 151 private final static native JsValue newValue(long ptr, boolean value); |
161 | 152 |
162 private final static native JsValue newValue(long ptr, String value); | 153 private final static native JsValue newValue(long ptr, String value); |
163 | 154 |
164 private final static native void dtor(long ptr); | 155 private final static native void dtor(long ptr); |
165 } | 156 } |
OLD | NEW |