Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: include/AdblockPlus/JsEngine.h

Issue 29377570: Issue 4931 - add possibility to not send data depending on connection properties (Closed)
Patch Set: Created Feb. 28, 2017, 2:22 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
};
}
« no previous file with comments | « include/AdblockPlus/FilterEngine.h ('k') | lib/prefs.js » ('j') | src/WebRequestJsObject.cpp » ('J')

Powered by Google App Engine
This is Rietveld