Index: include/AdblockPlus/JsEngine.h |
=================================================================== |
--- a/include/AdblockPlus/JsEngine.h |
+++ b/include/AdblockPlus/JsEngine.h |
@@ -13,21 +13,23 @@ |
* |
* You should have received a copy of the GNU General Public License |
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
*/ |
#ifndef ADBLOCK_PLUS_JS_ENGINE_H |
#define ADBLOCK_PLUS_JS_ENGINE_H |
+#include <map> |
#include <stdexcept> |
#include <stdint.h> |
#include <string> |
#include <v8.h> |
#include <AdblockPlus/AppInfo.h> |
+#include <AdblockPlus/tr1_functional.h> |
#include <AdblockPlus/LogSystem.h> |
#include <AdblockPlus/FileSystem.h> |
#include <AdblockPlus/JsValue.h> |
#include <AdblockPlus/WebRequest.h> |
#include "tr1_memory.h" |
namespace AdblockPlus |
@@ -42,17 +44,23 @@ namespace AdblockPlus |
class JsEngine; |
typedef std::tr1::shared_ptr<JsEngine> JsEnginePtr; |
class JsEngine : public std::tr1::enable_shared_from_this<JsEngine> |
{ |
friend class JsValue; |
public: |
+ typedef std::tr1::function<void()> EventCallback; |
+ typedef std::map<std::string, EventCallback> EventMap; |
+ |
static JsEnginePtr New(const AppInfo& appInfo = AppInfo()); |
+ void SetEventCallback(const std::string& eventName, EventCallback callback); |
+ void RemoveEventCallback(const std::string& eventName); |
+ void TriggerEvent(const std::string& eventName); |
JsValuePtr Evaluate(const std::string& source, |
const std::string& filename = ""); |
void Gc(); |
JsValuePtr NewValue(const std::string& val); |
JsValuePtr NewValue(int64_t val); |
JsValuePtr NewValue(bool val); |
inline JsValuePtr NewValue(const char* val) |
{ |
@@ -95,12 +103,13 @@ namespace AdblockPlus |
private: |
JsEngine(); |
FileSystemPtr fileSystem; |
WebRequestPtr webRequest; |
LogSystemPtr logSystem; |
v8::Isolate* isolate; |
v8::Persistent<v8::Context> context; |
+ EventMap eventCallbacks; |
}; |
} |
#endif |