| Left: | ||
| Right: |
| 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, final WebReq uest webRequest) | 33 public JsEngine(final AppInfo appInfo, final LogSystem logSystem, final WebReq uest webRequest, final String basePath) |
| 34 { | 34 { |
| 35 this(ctor(appInfo, logSystem, webRequest)); | 35 this(ctor(appInfo, logSystem, webRequest, basePath)); |
| 36 } | 36 } |
| 37 | 37 |
| 38 public JsEngine(final AppInfo appInfo, final WebRequest webRequest) | 38 public JsEngine(final AppInfo appInfo, final WebRequest webRequest, final Stri ng basePath) |
|
anton
2017/09/01 09:49:50
Since ctor becase too heavy i'd prefer to leave ju
sergei
2017/09/01 09:58:34
Done in https://codereview.adblockplus.org/2953358
| |
| 39 { | 39 { |
| 40 this(appInfo, null, webRequest); | 40 this(appInfo, null, webRequest, basePath); |
| 41 } | 41 } |
| 42 | 42 |
| 43 public JsEngine(final AppInfo appInfo) | 43 public JsEngine(final AppInfo appInfo) |
| 44 { | 44 { |
| 45 this(appInfo, null, null); | 45 this(appInfo, null, null, null); |
| 46 } | 46 } |
| 47 | 47 |
| 48 protected JsEngine(final long ptr) | 48 protected JsEngine(final long ptr) |
| 49 { | 49 { |
| 50 this.ptr = ptr; | 50 this.ptr = ptr; |
| 51 this.disposer = new Disposer(this, new DisposeWrapper(ptr)); | 51 this.disposer = new Disposer(this, new DisposeWrapper(ptr)); |
| 52 } | 52 } |
| 53 | 53 |
| 54 public void setEventCallback(final String eventName, final EventCallback callb ack) | 54 public void setEventCallback(final String eventName, final EventCallback callb ack) |
| 55 { | 55 { |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 81 } | 81 } |
| 82 | 82 |
| 83 triggerEvent(this.ptr, eventName, args); | 83 triggerEvent(this.ptr, eventName, args); |
| 84 } | 84 } |
| 85 | 85 |
| 86 public void triggerEvent(final String eventName) | 86 public void triggerEvent(final String eventName) |
| 87 { | 87 { |
| 88 triggerEvent(this.ptr, eventName, null); | 88 triggerEvent(this.ptr, eventName, null); |
| 89 } | 89 } |
| 90 | 90 |
| 91 public void setDefaultFileSystem(final String basePath) | |
| 92 { | |
| 93 setDefaultFileSystem(this.ptr, basePath); | |
| 94 } | |
| 95 | |
| 96 public JsValue newValue(final long value) | 91 public JsValue newValue(final long value) |
| 97 { | 92 { |
| 98 return newValue(this.ptr, value); | 93 return newValue(this.ptr, value); |
| 99 } | 94 } |
| 100 | 95 |
| 101 public JsValue newValue(final boolean value) | 96 public JsValue newValue(final boolean value) |
| 102 { | 97 { |
| 103 return newValue(this.ptr, value); | 98 return newValue(this.ptr, value); |
| 104 } | 99 } |
| 105 | 100 |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 125 | 120 |
| 126 @Override | 121 @Override |
| 127 public void dispose() | 122 public void dispose() |
| 128 { | 123 { |
| 129 dtor(this.ptr); | 124 dtor(this.ptr); |
| 130 } | 125 } |
| 131 } | 126 } |
| 132 | 127 |
| 133 private final static native void registerNatives(); | 128 private final static native void registerNatives(); |
| 134 | 129 |
| 135 private final static native long ctor(AppInfo appInfo, LogSystem logSystem, We bRequest webRequest); | 130 private final static native long ctor(AppInfo appInfo, LogSystem logSystem, We bRequest webRequest, |
| 131 String basePath); | |
| 136 | 132 |
| 137 private final static native void setEventCallback(long ptr, String eventName, long callback); | 133 private final static native void setEventCallback(long ptr, String eventName, long callback); |
| 138 | 134 |
| 139 private final static native void removeEventCallback(long ptr, String eventNam e); | 135 private final static native void removeEventCallback(long ptr, String eventNam e); |
| 140 | 136 |
| 141 private final static native JsValue evaluate(long ptr, String source, String f ilename); | 137 private final static native JsValue evaluate(long ptr, String source, String f ilename); |
| 142 | 138 |
| 143 private final static native void triggerEvent(long ptr, String eventName, long [] args); | 139 private final static native void triggerEvent(long ptr, String eventName, long [] args); |
| 144 | 140 |
| 145 private final static native void setDefaultFileSystem(long ptr, String basePat h); | |
| 146 | |
| 147 private final static native JsValue newValue(long ptr, long value); | 141 private final static native JsValue newValue(long ptr, long value); |
| 148 | 142 |
| 149 private final static native JsValue newValue(long ptr, boolean value); | 143 private final static native JsValue newValue(long ptr, boolean value); |
| 150 | 144 |
| 151 private final static native JsValue newValue(long ptr, String value); | 145 private final static native JsValue newValue(long ptr, String value); |
| 152 | 146 |
| 153 private final static native void dtor(long ptr); | 147 private final static native void dtor(long ptr); |
| 154 } | 148 } |
| OLD | NEW |