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

Side by Side Diff: include/AdblockPlus/FilterEngine.h

Issue 29377570: Issue 4931 - add possibility to not send data depending on connection properties (Closed)
Patch Set: rebase Created March 16, 2017, 4:02 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « README.md ('k') | include/AdblockPlus/JsEngine.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 */ 207 */
208 typedef std::map<std::string, AdblockPlus::JsValuePtr> Prefs; 208 typedef std::map<std::string, AdblockPlus::JsValuePtr> Prefs;
209 209
210 /** 210 /**
211 * Callback type invoked when a new notification should be shown. 211 * Callback type invoked when a new notification should be shown.
212 * The parameter is the Notification object to be shown. 212 * The parameter is the Notification object to be shown.
213 */ 213 */
214 typedef std::function<void(const NotificationPtr&)> ShowNotificationCallback ; 214 typedef std::function<void(const NotificationPtr&)> ShowNotificationCallback ;
215 215
216 /** 216 /**
217 * Callback function returning false when current connection is not
218 * allowedConnectionType, e.g. because it is a metered connection.
219 */
220 typedef std::function<bool(const std::string* allowedConnectionType)> IsConn ectionAllowedCallback;
221
222 /**
217 * FilterEngine creation parameters. 223 * FilterEngine creation parameters.
218 */ 224 */
219 struct CreationParameters 225 struct CreationParameters
220 { 226 {
221 /** 227 /**
222 * `AdblockPlus::FilterEngine::Prefs` name - value list of preconfigured 228 * `AdblockPlus::FilterEngine::Prefs` name - value list of preconfigured
223 * prefs. 229 * prefs.
224 */ 230 */
225 Prefs preconfiguredPrefs; 231 Prefs preconfiguredPrefs;
232 /**
233 * `AdblockPlus::FilterEngine::IsConnectionAllowedCallback` a callback
234 * checking whether the request from Adblock Plus should be blocked on
235 * the current connection.
236 */
237 IsConnectionAllowedCallback isConnectionAllowedCallback;
226 }; 238 };
227 239
228 /** 240 /**
229 * Callback type invoked when FilterEngine is created. 241 * Callback type invoked when FilterEngine is created.
230 */ 242 */
231 typedef std::function<void(const FilterEnginePtr&)> OnCreatedCallback; 243 typedef std::function<void(const FilterEnginePtr&)> OnCreatedCallback;
232 244
233 /** 245 /**
234 * Asynchronously constructs FilterEngine. 246 * Asynchronously constructs FilterEngine.
235 * @param jsEngine `JsEngine` instance used to run JavaScript code 247 * @param jsEngine `JsEngine` instance used to run JavaScript code
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 * @param callback Callback to invoke. 444 * @param callback Callback to invoke.
433 */ 445 */
434 void SetFilterChangeCallback(FilterChangeCallback callback); 446 void SetFilterChangeCallback(FilterChangeCallback callback);
435 447
436 /** 448 /**
437 * Removes the callback invoked when the filters change. 449 * Removes the callback invoked when the filters change.
438 */ 450 */
439 void RemoveFilterChangeCallback(); 451 void RemoveFilterChangeCallback();
440 452
441 /** 453 /**
454 * Stores the value indicating what connection types are allowed, it is
455 * passed to CreateParameters::isConnectionAllowed callback.
456 * @param value Stored value. nullptr means removing of any previously
457 * stored value.
458 */
459 void SetAllowedConnectionType(const std::string* value);
460
461 /**
462 * Retrieves previously stored allowed connection type.
463 * @return Preference value, or `nullptr` if it doesn't exist.
464 */
465 std::unique_ptr<std::string> GetAllowedConnectionType();
466
467 /**
442 * Compares two version strings in 468 * Compares two version strings in
443 * [Mozilla toolkit version format](https://developer.mozilla.org/en/docs/To olkit_version_format). 469 * [Mozilla toolkit version format](https://developer.mozilla.org/en/docs/To olkit_version_format).
444 * @param v1 First version string. 470 * @param v1 First version string.
445 * @param v2 Second version string. 471 * @param v2 Second version string.
446 * @return 472 * @return
447 * - `0` if `v1` and `v2` are identical. 473 * - `0` if `v1` and `v2` are identical.
448 * - A negative number if `v1` is less than `v2`. 474 * - A negative number if `v1` is less than `v2`.
449 * - A positive number if `v1` is greater than `v2`. 475 * - A positive number if `v1` is greater than `v2`.
450 */ 476 */
451 int CompareVersions(const std::string& v1, const std::string& v2); 477 int CompareVersions(const std::string& v1, const std::string& v2);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 const JsValueList& params); 511 const JsValueList& params);
486 FilterPtr GetWhitelistingFilter(const std::string& url, 512 FilterPtr GetWhitelistingFilter(const std::string& url,
487 ContentTypeMask contentTypeMask, const std::string& documentUrl) const; 513 ContentTypeMask contentTypeMask, const std::string& documentUrl) const;
488 FilterPtr GetWhitelistingFilter(const std::string& url, 514 FilterPtr GetWhitelistingFilter(const std::string& url,
489 ContentTypeMask contentTypeMask, 515 ContentTypeMask contentTypeMask,
490 const std::vector<std::string>& documentUrls) const; 516 const std::vector<std::string>& documentUrls) const;
491 }; 517 };
492 } 518 }
493 519
494 #endif 520 #endif
OLDNEW
« no previous file with comments | « README.md ('k') | include/AdblockPlus/JsEngine.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld