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

Delta Between Two Patch Sets: include/AdblockPlus/FilterEngine.h

Issue 29366747: Issue 4657 - Add Acceptable Ads API (Closed)
Left Patch Set: address comments and rebase Created March 17, 2017, 3:49 p.m.
Right Patch Set: fix typo Created April 5, 2017, 4:53 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | lib/api.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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-2017 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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 * Filter types, see https://adblockplus.org/en/filters. 45 * Filter types, see https://adblockplus.org/en/filters.
46 */ 46 */
47 enum Type {TYPE_BLOCKING, TYPE_EXCEPTION, 47 enum Type {TYPE_BLOCKING, TYPE_EXCEPTION,
48 TYPE_ELEMHIDE, TYPE_ELEMHIDE_EXCEPTION, 48 TYPE_ELEMHIDE, TYPE_ELEMHIDE_EXCEPTION,
49 TYPE_COMMENT, TYPE_INVALID}; 49 TYPE_COMMENT, TYPE_INVALID};
50 50
51 /** 51 /**
52 * Retrieves the type of this filter. 52 * Retrieves the type of this filter.
53 * @return Type of this filter. 53 * @return Type of this filter.
54 */ 54 */
55 Type GetType(); 55 Type GetType() const;
56 56
57 /** 57 /**
58 * Checks whether this filter has been added to the list of custom filters. 58 * Checks whether this filter has been added to the list of custom filters.
59 * @return `true` if this filter has been added. 59 * @return `true` if this filter has been added.
60 */ 60 */
61 bool IsListed(); 61 bool IsListed() const;
62 62
63 /** 63 /**
64 * Adds this filter to the list of custom filters. 64 * Adds this filter to the list of custom filters.
65 */ 65 */
66 void AddToList(); 66 void AddToList();
67 67
68 /** 68 /**
69 * Removes this filter from the list of custom filters. 69 * Removes this filter from the list of custom filters.
70 */ 70 */
71 void RemoveFromList(); 71 void RemoveFromList();
(...skipping 16 matching lines...) Expand all
88 * use `GetProperty()` to retrieve them by name. 88 * use `GetProperty()` to retrieve them by name.
89 */ 89 */
90 class Subscription : public JsValue, 90 class Subscription : public JsValue,
91 public std::enable_shared_from_this<Subscription> 91 public std::enable_shared_from_this<Subscription>
92 { 92 {
93 public: 93 public:
94 /** 94 /**
95 * Checks if this subscription has been added to the list of subscriptions. 95 * Checks if this subscription has been added to the list of subscriptions.
96 * @return `true` if this subscription has been added. 96 * @return `true` if this subscription has been added.
97 */ 97 */
98 bool IsListed(); 98 bool IsListed() const;
99 99
100 /** 100 /**
101 * Adds this subscription to the list of subscriptions. 101 * Adds this subscription to the list of subscriptions.
102 */ 102 */
103 void AddToList(); 103 void AddToList();
104 104
105 /** 105 /**
106 * Removes this subscription from the list of subscriptions. 106 * Removes this subscription from the list of subscriptions.
107 */ 107 */
108 void RemoveFromList(); 108 void RemoveFromList();
109 109
110 /** 110 /**
111 * Updates this subscription, i.e.\ retrieves the current filters from the 111 * Updates this subscription, i.e.\ retrieves the current filters from the
112 * subscription URL. 112 * subscription URL.
113 */ 113 */
114 void UpdateFilters(); 114 void UpdateFilters();
115 115
116 /** 116 /**
117 * Checks if the subscription is currently being updated. 117 * Checks if the subscription is currently being updated.
118 * @return `true` if the subscription is currently being updated. 118 * @return `true` if the subscription is currently being updated.
119 */ 119 */
120 bool IsUpdating(); 120 bool IsUpdating() const;
121 121
122 /** 122 /**
123 * Indicates whether the subscription is acceptable ads subscription. 123 * Indicates whether the subscription is acceptable ads subscription.
124 * @return `true` if this subscription is acceptable ads subscription. 124 * @return `true` if this subscription is acceptable ads subscription.
125 */ 125 */
126 bool IsAA(); 126 bool IsAA() const;
hub 2017/03/17 20:04:15 Shouldn't this be a const method?
sergei 2017/03/17 22:10:06 I do agree that it should be const because for the
hub 2017/04/05 13:35:02 As it is right now, IsUpdating() above is const, s
sergei 2017/04/05 14:43:29 fixed.
127 127
128 bool operator==(const Subscription& subscription) const; 128 bool operator==(const Subscription& subscription) const;
129 129
130 /** 130 /**
131 * Creates a wrapper for an existing JavaScript subscription object. 131 * Creates a wrapper for an existing JavaScript subscription object.
132 * Normally you shouldn't call this directly, but use 132 * Normally you shouldn't call this directly, but use
133 * FilterEngine::GetSubscription() instead. 133 * FilterEngine::GetSubscription() instead.
134 * @param value JavaScript subscription object. 134 * @param value JavaScript subscription object.
135 */ 135 */
136 Subscription(JsValue&& value); 136 Subscription(JsValue&& value);
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 * @return `true` if the application is running for the first time. 278 * @return `true` if the application is running for the first time.
279 */ 279 */
280 bool IsFirstRun() const; 280 bool IsFirstRun() const;
281 281
282 /** 282 /**
283 * Retrieves a filter object from its text representation. 283 * Retrieves a filter object from its text representation.
284 * @param text Text representation of the filter, 284 * @param text Text representation of the filter,
285 * see https://adblockplus.org/en/filters. 285 * see https://adblockplus.org/en/filters.
286 * @return New `Filter` instance. 286 * @return New `Filter` instance.
287 */ 287 */
288 FilterPtr GetFilter(const std::string& text); 288 FilterPtr GetFilter(const std::string& text) const;
289 289
290 /** 290 /**
291 * Retrieves a subscription object for the supplied URL. 291 * Retrieves a subscription object for the supplied URL.
292 * @param url Subscription URL. 292 * @param url Subscription URL.
293 * @return New `Subscription` instance. 293 * @return New `Subscription` instance.
294 */ 294 */
295 SubscriptionPtr GetSubscription(const std::string& url); 295 SubscriptionPtr GetSubscription(const std::string& url) const;
296 296
297 /** 297 /**
298 * Retrieves the list of custom filters. 298 * Retrieves the list of custom filters.
299 * @return List of custom filters. 299 * @return List of custom filters.
300 */ 300 */
301 std::vector<FilterPtr> GetListedFilters() const; 301 std::vector<FilterPtr> GetListedFilters() const;
302 302
303 /** 303 /**
304 * Retrieves all subscriptions. 304 * Retrieves all subscriptions.
305 * @return List of subscriptions. 305 * @return List of subscriptions.
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 * @param pref Preference name. 435 * @param pref Preference name.
436 * @param value New value of the preference. 436 * @param value New value of the preference.
437 */ 437 */
438 void SetPref(const std::string& pref, JsValuePtr value); 438 void SetPref(const std::string& pref, JsValuePtr value);
439 439
440 /** 440 /**
441 * Extracts the host from a URL. 441 * Extracts the host from a URL.
442 * @param url URL to extract the host from. 442 * @param url URL to extract the host from.
443 * @return Extracted host. 443 * @return Extracted host.
444 */ 444 */
445 std::string GetHostFromURL(const std::string& url); 445 std::string GetHostFromURL(const std::string& url) const;
446 446
447 /** 447 /**
448 * Sets the callback invoked when an application update becomes available. 448 * Sets the callback invoked when an application update becomes available.
449 * @param callback Callback to invoke. 449 * @param callback Callback to invoke.
450 */ 450 */
451 void SetUpdateAvailableCallback(UpdateAvailableCallback callback); 451 void SetUpdateAvailableCallback(UpdateAvailableCallback callback);
452 452
453 /** 453 /**
454 * Removes the callback invoked when an application update becomes 454 * Removes the callback invoked when an application update becomes
455 * available. 455 * available.
456 */ 456 */
457 void RemoveUpdateAvailableCallback(); 457 void RemoveUpdateAvailableCallback();
458 458
459 /** 459 /**
460 * Forces an immediate update check. 460 * Forces an immediate update check.
461 * `FilterEngine` will automatically check for updates in regular intervals, 461 * `FilterEngine` will automatically check for updates in regular intervals,
462 * so applications should only call this when the user triggers an update 462 * so applications should only call this when the user triggers an update
463 * check manually. 463 * check manually.
464 * @param callback Optional callback to invoke when the update check is 464 * @param callback Optional callback to invoke when the update check is
465 * finished. The string parameter will be empty when the update check 465 * finished. The string parameter will be empty when the update check
466 * succeeded, or contain an error message if it failed. 466 * succeeded, or contain an error message if it failed.
467 * Note that the callback will be invoked whether updates are 467 * Note that the callback will be invoked whether updates are
468 * available or not - to react to updates being available, use 468 * available or not - to react to updates being available, use
469 * `FilterEngine::SetUpdateAvailableCallback()`. 469 * `FilterEngine::SetUpdateAvailableCallback()`.
470 */ 470 */
471 void ForceUpdateCheck(UpdateCheckDoneCallback callback); 471 void ForceUpdateCheck(const UpdateCheckDoneCallback& callback = UpdateCheckD oneCallback());
472 472
473 /** 473 /**
474 * Sets the callback invoked when the filters change. 474 * Sets the callback invoked when the filters change.
475 * @param callback Callback to invoke. 475 * @param callback Callback to invoke.
476 */ 476 */
477 void SetFilterChangeCallback(FilterChangeCallback callback); 477 void SetFilterChangeCallback(FilterChangeCallback callback);
478 478
479 /** 479 /**
480 * Removes the callback invoked when the filters change. 480 * Removes the callback invoked when the filters change.
481 */ 481 */
482 void RemoveFilterChangeCallback(); 482 void RemoveFilterChangeCallback();
483 483
484 /** 484 /**
485 * Stores the value indicating what connection types are allowed, it is 485 * Stores the value indicating what connection types are allowed, it is
486 * passed to CreateParameters::isConnectionAllowed callback. 486 * passed to CreateParameters::isConnectionAllowed callback.
487 * @param value Stored value. nullptr means removing of any previously 487 * @param value Stored value. nullptr means removing of any previously
488 * stored value. 488 * stored value.
489 */ 489 */
490 void SetAllowedConnectionType(const std::string* value); 490 void SetAllowedConnectionType(const std::string* value);
491 491
492 /** 492 /**
493 * Retrieves previously stored allowed connection type. 493 * Retrieves previously stored allowed connection type.
494 * @return Preference value, or `nullptr` if it doesn't exist. 494 * @return Preference value, or `nullptr` if it doesn't exist.
495 */ 495 */
496 std::unique_ptr<std::string> GetAllowedConnectionType(); 496 std::unique_ptr<std::string> GetAllowedConnectionType() const;
497 497
498 /** 498 /**
499 * Compares two version strings in 499 * Compares two version strings in
500 * [Mozilla toolkit version format](https://developer.mozilla.org/en/docs/To olkit_version_format). 500 * [Mozilla toolkit version format](https://developer.mozilla.org/en/docs/To olkit_version_format).
501 * @param v1 First version string. 501 * @param v1 First version string.
502 * @param v2 Second version string. 502 * @param v2 Second version string.
503 * @return 503 * @return
504 * - `0` if `v1` and `v2` are identical. 504 * - `0` if `v1` and `v2` are identical.
505 * - A negative number if `v1` is less than `v2`. 505 * - A negative number if `v1` is less than `v2`.
506 * - A positive number if `v1` is greater than `v2`. 506 * - A positive number if `v1` is greater than `v2`.
507 */ 507 */
508 int CompareVersions(const std::string& v1, const std::string& v2); 508 int CompareVersions(const std::string& v1, const std::string& v2) const;
509 509
510 /** 510 /**
511 * Retrieves the `ContentType` for the supplied string. 511 * Retrieves the `ContentType` for the supplied string.
512 * @param contentType Content type string. 512 * @param contentType Content type string.
513 * @return The `ContentType` for the string. 513 * @return The `ContentType` for the string.
514 * @throw `std::invalid_argument`, if an invalid `contentType` was supplied. 514 * @throw `std::invalid_argument`, if an invalid `contentType` was supplied.
515 */ 515 */
516 static ContentType StringToContentType(const std::string& contentType); 516 static ContentType StringToContentType(const std::string& contentType);
517 517
518 /** 518 /**
(...skipping 23 matching lines...) Expand all
542 const JsValueList& params); 542 const JsValueList& params);
543 FilterPtr GetWhitelistingFilter(const std::string& url, 543 FilterPtr GetWhitelistingFilter(const std::string& url,
544 ContentTypeMask contentTypeMask, const std::string& documentUrl) const; 544 ContentTypeMask contentTypeMask, const std::string& documentUrl) const;
545 FilterPtr GetWhitelistingFilter(const std::string& url, 545 FilterPtr GetWhitelistingFilter(const std::string& url,
546 ContentTypeMask contentTypeMask, 546 ContentTypeMask contentTypeMask,
547 const std::vector<std::string>& documentUrls) const; 547 const std::vector<std::string>& documentUrls) const;
548 }; 548 };
549 } 549 }
550 550
551 #endif 551 #endif
LEFTRIGHT
« no previous file | lib/api.js » ('j') | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld