| 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) | 33 public JsEngine(final AppInfo appInfo, final LogSystem logSystem, final WebReq
uest webRequest) |
| 34 { | 34 { |
| 35 this(ctor(appInfo, logSystem)); | 35 this(ctor(appInfo, logSystem, webRequest != null ? webRequest.ptr : 0)); |
| 36 } |
| 37 |
| 38 public JsEngine(final AppInfo appInfo, final WebRequest webRequest) |
| 39 { |
| 40 this(appInfo, null, webRequest); |
| 36 } | 41 } |
| 37 | 42 |
| 38 public JsEngine(final AppInfo appInfo) | 43 public JsEngine(final AppInfo appInfo) |
| 39 { | 44 { |
| 40 this(appInfo, null); | 45 this(appInfo, null, null); |
| 41 } | 46 } |
| 42 | 47 |
| 43 protected JsEngine(final long ptr) | 48 protected JsEngine(final long ptr) |
| 44 { | 49 { |
| 45 this.ptr = ptr; | 50 this.ptr = ptr; |
| 46 this.disposer = new Disposer(this, new DisposeWrapper(ptr)); | 51 this.disposer = new Disposer(this, new DisposeWrapper(ptr)); |
| 47 } | 52 } |
| 48 | 53 |
| 49 public void setEventCallback(final String eventName, final EventCallback callb
ack) | 54 public void setEventCallback(final String eventName, final EventCallback callb
ack) |
| 50 { | 55 { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 81 public void triggerEvent(final String eventName) | 86 public void triggerEvent(final String eventName) |
| 82 { | 87 { |
| 83 triggerEvent(this.ptr, eventName, null); | 88 triggerEvent(this.ptr, eventName, null); |
| 84 } | 89 } |
| 85 | 90 |
| 86 public void setDefaultFileSystem(final String basePath) | 91 public void setDefaultFileSystem(final String basePath) |
| 87 { | 92 { |
| 88 setDefaultFileSystem(this.ptr, basePath); | 93 setDefaultFileSystem(this.ptr, basePath); |
| 89 } | 94 } |
| 90 | 95 |
| 91 public void setWebRequest(final WebRequest webRequest) | |
| 92 { | |
| 93 setWebRequest(this.ptr, webRequest.ptr); | |
| 94 } | |
| 95 | |
| 96 public JsValue newValue(final long value) | 96 public JsValue newValue(final long value) |
| 97 { | 97 { |
| 98 return newValue(this.ptr, value); | 98 return newValue(this.ptr, value); |
| 99 } | 99 } |
| 100 | 100 |
| 101 public JsValue newValue(final boolean value) | 101 public JsValue newValue(final boolean value) |
| 102 { | 102 { |
| 103 return newValue(this.ptr, value); | 103 return newValue(this.ptr, value); |
| 104 } | 104 } |
| 105 | 105 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 125 | 125 |
| 126 @Override | 126 @Override |
| 127 public void dispose() | 127 public void dispose() |
| 128 { | 128 { |
| 129 dtor(this.ptr); | 129 dtor(this.ptr); |
| 130 } | 130 } |
| 131 } | 131 } |
| 132 | 132 |
| 133 private final static native void registerNatives(); | 133 private final static native void registerNatives(); |
| 134 | 134 |
| 135 private final static native long ctor(AppInfo appInfo, LogSystem logSystem); | 135 private final static native long ctor(AppInfo appInfo, LogSystem logSystem, lo
ng webRequestPtr); |
| 136 | 136 |
| 137 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); |
| 138 | 138 |
| 139 private final static native void removeEventCallback(long ptr, String eventNam
e); | 139 private final static native void removeEventCallback(long ptr, String eventNam
e); |
| 140 | 140 |
| 141 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); |
| 142 | 142 |
| 143 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); |
| 144 | 144 |
| 145 private final static native void setDefaultFileSystem(long ptr, String basePat
h); | 145 private final static native void setDefaultFileSystem(long ptr, String basePat
h); |
| 146 | 146 |
| 147 private final static native void setWebRequest(long ptr, long webRequestPtr); | |
| 148 | |
| 149 private final static native JsValue newValue(long ptr, long value); | 147 private final static native JsValue newValue(long ptr, long value); |
| 150 | 148 |
| 151 private final static native JsValue newValue(long ptr, boolean value); | 149 private final static native JsValue newValue(long ptr, boolean value); |
| 152 | 150 |
| 153 private final static native JsValue newValue(long ptr, String value); | 151 private final static native JsValue newValue(long ptr, String value); |
| 154 | 152 |
| 155 private final static native void dtor(long ptr); | 153 private final static native void dtor(long ptr); |
| 156 } | 154 } |
| OLD | NEW |