| Left: | ||
| Right: |
| 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 16 matching lines...) Expand all Loading... | |
| 119 */ | 120 */ |
| 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; |
| 130 Subscription(Subscription&&) = default; | |
|
sergei
2017/04/24 14:12:36
It would be better to put the ctrs on the top of t
sergei
2017/04/24 14:12:36
On windows we are currently bound to MSVS2012 and
hub
2017/04/24 15:02:42
Done.
| |
| 129 | 131 |
| 132 protected: | |
| 130 /** | 133 /** |
| 131 * Creates a wrapper for an existing JavaScript subscription object. | 134 * Creates a wrapper for an existing JavaScript subscription object. |
| 132 * Normally you shouldn't call this directly, but use | 135 * Normally you shouldn't call this directly, but use |
| 133 * FilterEngine::GetSubscription() instead. | 136 * FilterEngine::GetSubscription() instead. |
| 134 * @param value JavaScript subscription object. | 137 * @param value JavaScript subscription object. |
| 135 */ | 138 */ |
| 136 Subscription(JsValue&& value); | 139 Subscription(JsValue&& value); |
| 137 }; | 140 }; |
| 138 | 141 |
| 139 /** | 142 /** |
| 140 * Shared smart pointer to a `Filter` instance. | 143 * Shared smart pointer to a `Filter` instance. |
| 141 */ | 144 */ |
| 142 typedef std::unique_ptr<Filter> FilterPtr; | 145 typedef std::unique_ptr<Filter> FilterPtr; |
| 143 | 146 |
| 144 /** | 147 /** |
| 145 * Shared smart pointer to a `Subscription` instance. | |
| 146 */ | |
| 147 typedef std::shared_ptr<Subscription> SubscriptionPtr; | |
| 148 | |
| 149 /** | |
| 150 * Main component of libadblockplus. | 148 * Main component of libadblockplus. |
| 151 * It handles: | 149 * It handles: |
| 152 * - Filter management and matching. | 150 * - Filter management and matching. |
| 153 * - Subscription management and synchronization. | 151 * - Subscription management and synchronization. |
| 154 * - Update checks for the application. | 152 * - Update checks for the application. |
| 155 */ | 153 */ |
| 156 class FilterEngine | 154 class FilterEngine |
| 157 { | 155 { |
| 158 public: | 156 public: |
| 159 // Make sure to keep ContentType in sync with FilterEngine::contentTypes | 157 // 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. | 283 * see https://adblockplus.org/en/filters. |
| 286 * @return New `Filter` instance. | 284 * @return New `Filter` instance. |
| 287 */ | 285 */ |
| 288 Filter GetFilter(const std::string& text) const; | 286 Filter GetFilter(const std::string& text) const; |
| 289 | 287 |
| 290 /** | 288 /** |
| 291 * Retrieves a subscription object for the supplied URL. | 289 * Retrieves a subscription object for the supplied URL. |
| 292 * @param url Subscription URL. | 290 * @param url Subscription URL. |
| 293 * @return New `Subscription` instance. | 291 * @return New `Subscription` instance. |
| 294 */ | 292 */ |
| 295 SubscriptionPtr GetSubscription(const std::string& url) const; | 293 Subscription GetSubscription(const std::string& url) const; |
| 296 | 294 |
| 297 /** | 295 /** |
| 298 * Retrieves the list of custom filters. | 296 * Retrieves the list of custom filters. |
| 299 * @return List of custom filters. | 297 * @return List of custom filters. |
| 300 */ | 298 */ |
| 301 std::vector<Filter> GetListedFilters() const; | 299 std::vector<Filter> GetListedFilters() const; |
| 302 | 300 |
| 303 /** | 301 /** |
| 304 * Retrieves all subscriptions. | 302 * Retrieves all subscriptions. |
| 305 * @return List of subscriptions. | 303 * @return List of subscriptions. |
| 306 */ | 304 */ |
| 307 std::vector<SubscriptionPtr> GetListedSubscriptions() const; | 305 std::vector<Subscription> GetListedSubscriptions() const; |
| 308 | 306 |
| 309 /** | 307 /** |
| 310 * Retrieves all recommended subscriptions. | 308 * Retrieves all recommended subscriptions. |
| 311 * @return List of recommended subscriptions. | 309 * @return List of recommended subscriptions. |
| 312 */ | 310 */ |
| 313 std::vector<SubscriptionPtr> FetchAvailableSubscriptions() const; | 311 std::vector<Subscription> FetchAvailableSubscriptions() const; |
| 314 | 312 |
| 315 /** | 313 /** |
| 316 * Ensures that the Acceptable Ads subscription is enabled or disabled. | 314 * Ensures that the Acceptable Ads subscription is enabled or disabled. |
| 317 * @param enabled | 315 * @param enabled |
| 318 * - if the value is `true` | 316 * - if the value is `true` |
| 319 * - ensure that the filter set includes an enabled AA subscription, | 317 * - ensure that the filter set includes an enabled AA subscription, |
| 320 * adding it if needed and enabling it if disabled. | 318 * adding it if needed and enabling it if disabled. |
| 321 * - if the value is `false` | 319 * - if the value is `false` |
| 322 * - if an AA subscription is present, disable it. | 320 * - if an AA subscription is present, disable it. |
| 323 * - if absent, do nothing. | 321 * - if absent, do nothing. |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 542 const JsValueList& param) const; | 540 const JsValueList& param) const; |
| 543 FilterPtr GetWhitelistingFilter(const std::string& url, | 541 FilterPtr GetWhitelistingFilter(const std::string& url, |
| 544 ContentTypeMask contentTypeMask, const std::string& documentUrl) const; | 542 ContentTypeMask contentTypeMask, const std::string& documentUrl) const; |
| 545 FilterPtr GetWhitelistingFilter(const std::string& url, | 543 FilterPtr GetWhitelistingFilter(const std::string& url, |
| 546 ContentTypeMask contentTypeMask, | 544 ContentTypeMask contentTypeMask, |
| 547 const std::vector<std::string>& documentUrls) const; | 545 const std::vector<std::string>& documentUrls) const; |
| 548 }; | 546 }; |
| 549 } | 547 } |
| 550 | 548 |
| 551 #endif | 549 #endif |
| OLD | NEW |