| 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-2017 eyeo GmbH | 3 * Copyright (C) 2006-2017 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 AdblockPlus::FileSystemPtr fileSystem(new AdblockPlus::DefaultFileSystem()); | 132 AdblockPlus::FileSystemPtr fileSystem(new AdblockPlus::DefaultFileSystem()); |
| 133 | 133 |
| 134 std::string basePath = JniJavaToStdString(env, jBasePath); | 134 std::string basePath = JniJavaToStdString(env, jBasePath); |
| 135 reinterpret_cast<AdblockPlus::DefaultFileSystem*>(fileSystem.get())->SetBase
Path(basePath); | 135 reinterpret_cast<AdblockPlus::DefaultFileSystem*>(fileSystem.get())->SetBase
Path(basePath); |
| 136 | 136 |
| 137 engine->SetFileSystem(fileSystem); | 137 engine->SetFileSystem(fileSystem); |
| 138 } | 138 } |
| 139 CATCH_AND_THROW(env) | 139 CATCH_AND_THROW(env) |
| 140 } | 140 } |
| 141 | 141 |
| 142 static void JNICALL JniSetDefaultWebRequest(JNIEnv* env, jclass clazz, jlong ptr
) | |
| 143 { | |
| 144 AdblockPlus::JsEnginePtr& engine = *JniLongToTypePtr<AdblockPlus::JsEnginePtr>
(ptr); | |
| 145 | |
| 146 try | |
| 147 { | |
| 148 AdblockPlus::WebRequestPtr webRequest(new AdblockPlus::DefaultWebRequest()); | |
| 149 engine->SetWebRequest(webRequest); | |
| 150 } | |
| 151 CATCH_AND_THROW(env) | |
| 152 } | |
| 153 | |
| 154 static void JNICALL JniSetDefaultLogSystem(JNIEnv* env, jclass clazz, jlong ptr) | 142 static void JNICALL JniSetDefaultLogSystem(JNIEnv* env, jclass clazz, jlong ptr) |
| 155 { | 143 { |
| 156 AdblockPlus::JsEnginePtr& engine = *JniLongToTypePtr<AdblockPlus::JsEnginePtr>
(ptr); | 144 AdblockPlus::JsEnginePtr& engine = *JniLongToTypePtr<AdblockPlus::JsEnginePtr>
(ptr); |
| 157 | 145 |
| 158 try | 146 try |
| 159 { | 147 { |
| 160 AdblockPlus::LogSystemPtr logSystem(new AdblockPlus::DefaultLogSystem()); | 148 AdblockPlus::LogSystemPtr logSystem(new AdblockPlus::DefaultLogSystem()); |
| 161 | 149 |
| 162 engine->SetLogSystem(logSystem); | 150 engine->SetLogSystem(logSystem); |
| 163 } | 151 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 176 } | 164 } |
| 177 CATCH_AND_THROW(env) | 165 CATCH_AND_THROW(env) |
| 178 } | 166 } |
| 179 | 167 |
| 180 static void JNICALL JniSetWebRequest(JNIEnv* env, jclass clazz, jlong ptr, jlong
webRequestPtr) | 168 static void JNICALL JniSetWebRequest(JNIEnv* env, jclass clazz, jlong ptr, jlong
webRequestPtr) |
| 181 { | 169 { |
| 182 AdblockPlus::JsEnginePtr& engine = *JniLongToTypePtr<AdblockPlus::JsEnginePtr>
(ptr); | 170 AdblockPlus::JsEnginePtr& engine = *JniLongToTypePtr<AdblockPlus::JsEnginePtr>
(ptr); |
| 183 | 171 |
| 184 try | 172 try |
| 185 { | 173 { |
| 186 AdblockPlus::WebRequestPtr& webRequest = *JniLongToTypePtr<AdblockPlus::WebR
equestPtr>(webRequestPtr); | 174 auto& webRequest = *JniLongToTypePtr<AdblockPlus::WebRequestSharedPtr>(webRe
questPtr); |
| 187 | 175 |
| 188 engine->SetWebRequest(webRequest); | 176 engine->SetWebRequest(webRequest); |
| 189 } | 177 } |
| 190 CATCH_AND_THROW(env) | 178 CATCH_AND_THROW(env) |
| 191 } | 179 } |
| 192 | 180 |
| 193 static jobject JNICALL JniNewLongValue(JNIEnv* env, jclass clazz, jlong ptr, jlo
ng value) | 181 static jobject JNICALL JniNewLongValue(JNIEnv* env, jclass clazz, jlong ptr, jlo
ng value) |
| 194 { | 182 { |
| 195 AdblockPlus::JsEnginePtr& engine = *JniLongToTypePtr<AdblockPlus::JsEnginePtr>
(ptr); | 183 AdblockPlus::JsEnginePtr& engine = *JniLongToTypePtr<AdblockPlus::JsEnginePtr>
(ptr); |
| 196 | 184 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 { (char*)"setEventCallback", (char*)"(JLjava/lang/String;J)V", (void*)JniSetEv
entCallback }, | 226 { (char*)"setEventCallback", (char*)"(JLjava/lang/String;J)V", (void*)JniSetEv
entCallback }, |
| 239 { (char*)"removeEventCallback", (char*)"(JLjava/lang/String;)V", (void*)JniRem
oveEventCallback }, | 227 { (char*)"removeEventCallback", (char*)"(JLjava/lang/String;)V", (void*)JniRem
oveEventCallback }, |
| 240 { (char*)"triggerEvent", (char*)"(JLjava/lang/String;[J)V", (void*)JniTriggerE
vent }, | 228 { (char*)"triggerEvent", (char*)"(JLjava/lang/String;[J)V", (void*)JniTriggerE
vent }, |
| 241 | 229 |
| 242 { (char*)"evaluate", (char*)"(JLjava/lang/String;Ljava/lang/String;)" TYP("JsV
alue"), (void*)JniEvaluate }, | 230 { (char*)"evaluate", (char*)"(JLjava/lang/String;Ljava/lang/String;)" TYP("JsV
alue"), (void*)JniEvaluate }, |
| 243 | 231 |
| 244 { (char*)"setDefaultFileSystem", (char*)"(JLjava/lang/String;)V", (void*)JniSe
tDefaultFileSystem }, | 232 { (char*)"setDefaultFileSystem", (char*)"(JLjava/lang/String;)V", (void*)JniSe
tDefaultFileSystem }, |
| 245 { (char*)"setLogSystem", (char*)"(JJ)V", (void*)JniSetLogSystem }, | 233 { (char*)"setLogSystem", (char*)"(JJ)V", (void*)JniSetLogSystem }, |
| 246 { (char*)"setDefaultLogSystem", (char*)"(J)V", (void*)JniSetDefaultLogSystem }
, | 234 { (char*)"setDefaultLogSystem", (char*)"(J)V", (void*)JniSetDefaultLogSystem }
, |
| 247 { (char*)"setWebRequest", (char*)"(JJ)V", (void*)JniSetWebRequest }, | 235 { (char*)"setWebRequest", (char*)"(JJ)V", (void*)JniSetWebRequest }, |
| 248 { (char*)"setDefaultWebRequest", (char*)"(J)V", (void*)JniSetDefaultWebRequest
}, | |
| 249 | 236 |
| 250 { (char*)"newValue", (char*)"(JJ)" TYP("JsValue"), (void*)JniNewLongValue }, | 237 { (char*)"newValue", (char*)"(JJ)" TYP("JsValue"), (void*)JniNewLongValue }, |
| 251 { (char*)"newValue", (char*)"(JZ)" TYP("JsValue"), (void*)JniNewBooleanValue }
, | 238 { (char*)"newValue", (char*)"(JZ)" TYP("JsValue"), (void*)JniNewBooleanValue }
, |
| 252 { (char*)"newValue", (char*)"(JLjava/lang/String;)" TYP("JsValue"), (void*)Jni
NewStringValue } | 239 { (char*)"newValue", (char*)"(JLjava/lang/String;)" TYP("JsValue"), (void*)Jni
NewStringValue } |
| 253 }; | 240 }; |
| 254 | 241 |
| 255 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_JsEngine_r
egisterNatives(JNIEnv *env, jclass clazz) | 242 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_JsEngine_r
egisterNatives(JNIEnv *env, jclass clazz) |
| 256 { | 243 { |
| 257 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])); | 244 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])); |
| 258 } | 245 } |
| OLD | NEW |