OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
3 * Copyright (C) 2006-2013 Eyeo GmbH | 3 * Copyright (C) 2006-2013 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 { | 46 { |
47 class JsEngine; | 47 class JsEngine; |
48 typedef std::tr1::shared_ptr<JsEngine> JsEnginePtr; | 48 typedef std::tr1::shared_ptr<JsEngine> JsEnginePtr; |
49 | 49 |
50 class JsEngine : public std::tr1::enable_shared_from_this<JsEngine> | 50 class JsEngine : public std::tr1::enable_shared_from_this<JsEngine> |
51 { | 51 { |
52 friend class JsValue; | 52 friend class JsValue; |
53 friend class JsContext; | 53 friend class JsContext; |
54 | 54 |
55 public: | 55 public: |
56 typedef std::tr1::function<void()> EventCallback; | 56 typedef std::tr1::function<void(JsValueList& params)> EventCallback; |
57 typedef std::map<std::string, EventCallback> EventMap; | 57 typedef std::map<std::string, EventCallback> EventMap; |
58 | 58 |
59 static JsEnginePtr New(const AppInfo& appInfo = AppInfo()); | 59 static JsEnginePtr New(const AppInfo& appInfo = AppInfo()); |
60 void SetEventCallback(const std::string& eventName, EventCallback callback); | 60 void SetEventCallback(const std::string& eventName, EventCallback callback); |
61 void RemoveEventCallback(const std::string& eventName); | 61 void RemoveEventCallback(const std::string& eventName); |
62 void TriggerEvent(const std::string& eventName); | 62 void TriggerEvent(const std::string& eventName, JsValueList& params); |
63 JsValuePtr Evaluate(const std::string& source, | 63 JsValuePtr Evaluate(const std::string& source, |
64 const std::string& filename = ""); | 64 const std::string& filename = ""); |
65 void Gc(); | 65 void Gc(); |
66 JsValuePtr NewValue(const std::string& val); | 66 JsValuePtr NewValue(const std::string& val); |
67 JsValuePtr NewValue(int64_t val); | 67 JsValuePtr NewValue(int64_t val); |
68 JsValuePtr NewValue(bool val); | 68 JsValuePtr NewValue(bool val); |
69 inline JsValuePtr NewValue(const char* val) | 69 inline JsValuePtr NewValue(const char* val) |
70 { | 70 { |
71 return NewValue(std::string(val)); | 71 return NewValue(std::string(val)); |
72 } | 72 } |
(...skipping 25 matching lines...) Expand all Loading... |
98 FileSystemPtr fileSystem; | 98 FileSystemPtr fileSystem; |
99 WebRequestPtr webRequest; | 99 WebRequestPtr webRequest; |
100 LogSystemPtr logSystem; | 100 LogSystemPtr logSystem; |
101 v8::Isolate* isolate; | 101 v8::Isolate* isolate; |
102 V8ValueHolder<v8::Context> context; | 102 V8ValueHolder<v8::Context> context; |
103 EventMap eventCallbacks; | 103 EventMap eventCallbacks; |
104 }; | 104 }; |
105 } | 105 } |
106 | 106 |
107 #endif | 107 #endif |
OLD | NEW |