| OLD | NEW |
| 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-2017 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 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 | 83 |
| 84 /** | 84 /** |
| 85 * Wrapper for a subscription object. | 85 * Wrapper for a subscription object. |
| 86 * There are no accessors for most | 86 * There are no accessors for most |
| 87 * [subscription properties](https://adblockplus.org/jsdoc/adblockpluscore/Sub
scription.html), | 87 * [subscription properties](https://adblockplus.org/jsdoc/adblockpluscore/Sub
scription.html), |
| 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 friend class FilterEngine; |
| 93 public: | 94 public: |
| 94 /** | 95 /** |
| 95 * Checks if this subscription has been added to the list of subscriptions. | 96 * Checks if this subscription has been added to the list of subscriptions. |
| 96 * @return `true` if this subscription has been added. | 97 * @return `true` if this subscription has been added. |
| 97 */ | 98 */ |
| 98 bool IsListed() const; | 99 bool IsListed() const; |
| 99 | 100 |
| 100 /** | 101 /** |
| 101 * Adds this subscription to the list of subscriptions. | 102 * Adds this subscription to the list of subscriptions. |
| 102 */ | 103 */ |
| (...skipping 17 matching lines...) Expand all Loading... |
| 120 bool IsUpdating() const; | 121 bool IsUpdating() const; |
| 121 | 122 |
| 122 /** | 123 /** |
| 123 * Indicates whether the subscription is the Acceptable Ads subscription. | 124 * Indicates whether the subscription is the Acceptable Ads subscription. |
| 124 * @return `true` if this subscription is the Acceptable Ads subscription. | 125 * @return `true` if this subscription is the Acceptable Ads subscription. |
| 125 */ | 126 */ |
| 126 bool IsAA() const; | 127 bool IsAA() const; |
| 127 | 128 |
| 128 bool operator==(const Subscription& subscription) const; | 129 bool operator==(const Subscription& subscription) const; |
| 129 | 130 |
| 131 protected: |
| 130 /** | 132 /** |
| 131 * Creates a wrapper for an existing JavaScript subscription object. | 133 * Creates a wrapper for an existing JavaScript subscription object. |
| 132 * Normally you shouldn't call this directly, but use | 134 * Normally you shouldn't call this directly, but use |
| 133 * FilterEngine::GetSubscription() instead. | 135 * FilterEngine::GetSubscription() instead. |
| 134 * @param value JavaScript subscription object. | 136 * @param value JavaScript subscription object. |
| 135 */ | 137 */ |
| 136 Subscription(JsValue&& value); | 138 Subscription(JsValue&& value); |
| 137 }; | 139 }; |
| 138 | 140 |
| 139 /** | 141 /** |
| 140 * Shared smart pointer to a `Filter` instance. | 142 * Shared smart pointer to a `Filter` instance. |
| 141 */ | 143 */ |
| 142 typedef std::unique_ptr<Filter> FilterPtr; | 144 typedef std::unique_ptr<Filter> FilterPtr; |
| 143 | 145 |
| 144 /** | 146 /** |
| 145 * Shared smart pointer to a `Subscription` instance. | |
| 146 */ | |
| 147 typedef std::shared_ptr<Subscription> SubscriptionPtr; | |
| 148 | |
| 149 /** | |
| 150 * Main component of libadblockplus. | 147 * Main component of libadblockplus. |
| 151 * It handles: | 148 * It handles: |
| 152 * - Filter management and matching. | 149 * - Filter management and matching. |
| 153 * - Subscription management and synchronization. | 150 * - Subscription management and synchronization. |
| 154 * - Update checks for the application. | 151 * - Update checks for the application. |
| 155 */ | 152 */ |
| 156 class FilterEngine | 153 class FilterEngine |
| 157 { | 154 { |
| 158 public: | 155 public: |
| 159 // Make sure to keep ContentType in sync with FilterEngine::contentTypes | 156 // Make sure to keep ContentType in sync with FilterEngine::contentTypes |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 * see https://adblockplus.org/en/filters. | 282 * see https://adblockplus.org/en/filters. |
| 286 * @return New `Filter` instance. | 283 * @return New `Filter` instance. |
| 287 */ | 284 */ |
| 288 Filter GetFilter(const std::string& text) const; | 285 Filter GetFilter(const std::string& text) const; |
| 289 | 286 |
| 290 /** | 287 /** |
| 291 * Retrieves a subscription object for the supplied URL. | 288 * Retrieves a subscription object for the supplied URL. |
| 292 * @param url Subscription URL. | 289 * @param url Subscription URL. |
| 293 * @return New `Subscription` instance. | 290 * @return New `Subscription` instance. |
| 294 */ | 291 */ |
| 295 SubscriptionPtr GetSubscription(const std::string& url) const; | 292 Subscription GetSubscription(const std::string& url) const; |
| 296 | 293 |
| 297 /** | 294 /** |
| 298 * Retrieves the list of custom filters. | 295 * Retrieves the list of custom filters. |
| 299 * @return List of custom filters. | 296 * @return List of custom filters. |
| 300 */ | 297 */ |
| 301 std::vector<Filter> GetListedFilters() const; | 298 std::vector<Filter> GetListedFilters() const; |
| 302 | 299 |
| 303 /** | 300 /** |
| 304 * Retrieves all subscriptions. | 301 * Retrieves all subscriptions. |
| 305 * @return List of subscriptions. | 302 * @return List of subscriptions. |
| 306 */ | 303 */ |
| 307 std::vector<SubscriptionPtr> GetListedSubscriptions() const; | 304 std::vector<Subscription> GetListedSubscriptions() const; |
| 308 | 305 |
| 309 /** | 306 /** |
| 310 * Retrieves all recommended subscriptions. | 307 * Retrieves all recommended subscriptions. |
| 311 * @return List of recommended subscriptions. | 308 * @return List of recommended subscriptions. |
| 312 */ | 309 */ |
| 313 std::vector<SubscriptionPtr> FetchAvailableSubscriptions() const; | 310 std::vector<Subscription> FetchAvailableSubscriptions() const; |
| 314 | 311 |
| 315 /** | 312 /** |
| 316 * Ensures that the Acceptable Ads subscription is enabled or disabled. | 313 * Ensures that the Acceptable Ads subscription is enabled or disabled. |
| 317 * @param enabled | 314 * @param enabled |
| 318 * - if the value is `true` | 315 * - if the value is `true` |
| 319 * - ensure that the filter set includes an enabled AA subscription, | 316 * - ensure that the filter set includes an enabled AA subscription, |
| 320 * adding it if needed and enabling it if disabled. | 317 * adding it if needed and enabling it if disabled. |
| 321 * - if the value is `false` | 318 * - if the value is `false` |
| 322 * - if an AA subscription is present, disable it. | 319 * - if an AA subscription is present, disable it. |
| 323 * - if absent, do nothing. | 320 * - if absent, do nothing. |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 const JsValueList& param) const; | 539 const JsValueList& param) const; |
| 543 FilterPtr GetWhitelistingFilter(const std::string& url, | 540 FilterPtr GetWhitelistingFilter(const std::string& url, |
| 544 ContentTypeMask contentTypeMask, const std::string& documentUrl) const; | 541 ContentTypeMask contentTypeMask, const std::string& documentUrl) const; |
| 545 FilterPtr GetWhitelistingFilter(const std::string& url, | 542 FilterPtr GetWhitelistingFilter(const std::string& url, |
| 546 ContentTypeMask contentTypeMask, | 543 ContentTypeMask contentTypeMask, |
| 547 const std::vector<std::string>& documentUrls) const; | 544 const std::vector<std::string>& documentUrls) const; |
| 548 }; | 545 }; |
| 549 } | 546 } |
| 550 | 547 |
| 551 #endif | 548 #endif |
| OLD | NEW |