LEFT | RIGHT |
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-2014 Eyeo GmbH | 3 * Copyright (C) 2006-2014 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 27 matching lines...) Expand all Loading... |
38 class Isolate; | 38 class Isolate; |
39 class Value; | 39 class Value; |
40 class Context; | 40 class Context; |
41 template<class T> class Handle; | 41 template<class T> class Handle; |
42 typedef Handle<Value>(*InvocationCallback)(const Arguments &args); | 42 typedef Handle<Value>(*InvocationCallback)(const Arguments &args); |
43 } | 43 } |
44 | 44 |
45 namespace AdblockPlus | 45 namespace AdblockPlus |
46 { | 46 { |
47 class JsEngine; | 47 class JsEngine; |
| 48 |
| 49 /** |
| 50 * Shared smart pointer to a `JsEngine` instance. |
| 51 */ |
48 typedef std::tr1::shared_ptr<JsEngine> JsEnginePtr; | 52 typedef std::tr1::shared_ptr<JsEngine> JsEnginePtr; |
49 | 53 |
50 /** | 54 /** |
51 * JavaScript engine used by `FilterEngine`, wraps v8. | 55 * JavaScript engine used by `FilterEngine`, wraps v8. |
52 */ | 56 */ |
53 class JsEngine : public std::tr1::enable_shared_from_this<JsEngine> | 57 class JsEngine : public std::tr1::enable_shared_from_this<JsEngine> |
54 { | 58 { |
55 friend class JsValue; | 59 friend class JsValue; |
56 friend class JsContext; | 60 friend class JsContext; |
57 | 61 |
58 public: | 62 public: |
59 /** | 63 /** |
60 * Event callback function. | 64 * Event callback function. |
61 */ | 65 */ |
62 typedef std::tr1::function<void(JsValueList& params)> EventCallback; | 66 typedef std::tr1::function<void(JsValueList& params)> EventCallback; |
63 | 67 |
64 /** | 68 /** |
65 * Maps events to callback functions. | 69 * Maps events to callback functions. |
66 */ | 70 */ |
67 typedef std::map<std::string, EventCallback> EventMap; | 71 typedef std::map<std::string, EventCallback> EventMap; |
68 | 72 |
69 /** | 73 /** |
70 * Creates a new JavaScript engine instance. | 74 * Creates a new JavaScript engine instance. |
71 * @param appInfo Information about the app, used for update checks. | 75 * @param appInfo Information about the app. |
72 * @return New `JsEngine` instance. | 76 * @return New `JsEngine` instance. |
73 */ | 77 */ |
74 static JsEnginePtr New(const AppInfo& appInfo = AppInfo()); | 78 static JsEnginePtr New(const AppInfo& appInfo = AppInfo()); |
75 | 79 |
76 /** | 80 /** |
77 * Registers the callback function for an event. | 81 * Registers the callback function for an event. |
78 * @param eventName Event name. | 82 * @param eventName Event name. Note that this can be any string - it's a |
| 83 * general purpose event handling mechanism. |
79 * @param callback Event callback function. | 84 * @param callback Event callback function. |
80 */ | 85 */ |
81 void SetEventCallback(const std::string& eventName, EventCallback callback); | 86 void SetEventCallback(const std::string& eventName, EventCallback callback); |
82 | 87 |
83 /** | 88 /** |
84 * Removes the callback function for an event. | 89 * Removes the callback function for an event. |
85 * @param eventName Event name. | 90 * @param eventName Event name. |
86 */ | 91 */ |
87 void RemoveEventCallback(const std::string& eventName); | 92 void RemoveEventCallback(const std::string& eventName); |
88 | 93 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 FileSystemPtr fileSystem; | 217 FileSystemPtr fileSystem; |
213 WebRequestPtr webRequest; | 218 WebRequestPtr webRequest; |
214 LogSystemPtr logSystem; | 219 LogSystemPtr logSystem; |
215 v8::Isolate* isolate; | 220 v8::Isolate* isolate; |
216 V8ValueHolder<v8::Context> context; | 221 V8ValueHolder<v8::Context> context; |
217 EventMap eventCallbacks; | 222 EventMap eventCallbacks; |
218 }; | 223 }; |
219 } | 224 } |
220 | 225 |
221 #endif | 226 #endif |
LEFT | RIGHT |