| Index: include/AdblockPlus/JsEngine.h |
| diff --git a/include/AdblockPlus/JsEngine.h b/include/AdblockPlus/JsEngine.h |
| index 3f43388620da169d6b457b4e8ef35caaadea1605..02981488444a28021431447a13b3b79e6fa098c8 100644 |
| --- a/include/AdblockPlus/JsEngine.h |
| +++ b/include/AdblockPlus/JsEngine.h |
| @@ -23,6 +23,7 @@ |
| #include <stdexcept> |
| #include <stdint.h> |
| #include <string> |
| +#include <mutex> |
| #include <AdblockPlus/AppInfo.h> |
| #include <AdblockPlus/LogSystem.h> |
| #include <AdblockPlus/FileSystem.h> |
| @@ -88,6 +89,12 @@ namespace AdblockPlus |
| typedef std::function<void(JsValueList& params)> EventCallback; |
| /** |
| + * Callback function returning false when current connection is not allowed |
| + * e.g. because it is a metered connection. |
| + */ |
| + typedef std::function<bool()> IsConnectionAllowedCallback; |
| + |
| + /** |
| * Maps events to callback functions. |
| */ |
| typedef std::map<std::string, EventCallback> EventMap; |
| @@ -222,6 +229,19 @@ namespace AdblockPlus |
| void SetWebRequest(WebRequestPtr val); |
| /** |
| + * Registers the callback function to check whether current connection is |
| + * allowed for network requests. |
| + * @param callback callback function. |
| + */ |
| + void SetIsConnectionAllowedCallback(const IsConnectionAllowedCallback& callback); |
| + |
| + /** |
| + * Checks whether current connection is allowed. If |
| + * IsConnectionAllowedCallback is not set then then it returns true. |
| + */ |
| + bool IsConnectionAllowed(); |
| + |
| + /** |
| * @see `SetLogSystem()`. |
| */ |
| LogSystemPtr GetLogSystem(); |
| @@ -264,6 +284,8 @@ namespace AdblockPlus |
| LogSystemPtr logSystem; |
| std::unique_ptr<v8::Persistent<v8::Context>> context; |
| EventMap eventCallbacks; |
| + std::mutex isConnectionAllowedMutex; |
| + IsConnectionAllowedCallback isConnectionAllowed; |
| }; |
| } |