Index: include/AdblockPlus/JsEngine.h |
diff --git a/include/AdblockPlus/JsEngine.h b/include/AdblockPlus/JsEngine.h |
index 3f43388620da169d6b457b4e8ef35caaadea1605..002773a66e6826f8d01002b721ed16dc91422c93 100644 |
--- a/include/AdblockPlus/JsEngine.h |
+++ b/include/AdblockPlus/JsEngine.h |
@@ -88,6 +88,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 +228,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 +283,7 @@ namespace AdblockPlus |
LogSystemPtr logSystem; |
std::unique_ptr<v8::Persistent<v8::Context>> context; |
EventMap eventCallbacks; |
+ IsConnectionAllowedCallback isConnectionAllowed; |
}; |
} |