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 /** |
96 * Copy constructor | |
97 */ | |
98 Subscription(const Subscription&); | |
99 | |
100 /** | |
101 * Move constructor | |
102 */ | |
103 Subscription(Subscription&&); | |
104 | |
105 /** | |
106 * Assignment operator | |
107 */ | |
108 Subscription& operator=(const Subscription&); | |
sergei
2017/04/24 18:19:36
The same comments as in https://codereview.adblock
hub
2017/04/24 19:16:51
Done.
| |
109 | |
110 /** | |
95 * Checks if this subscription has been added to the list of subscriptions. | 111 * Checks if this subscription has been added to the list of subscriptions. |
96 * @return `true` if this subscription has been added. | 112 * @return `true` if this subscription has been added. |
97 */ | 113 */ |
98 bool IsListed() const; | 114 bool IsListed() const; |
99 | 115 |
100 /** | 116 /** |
101 * Adds this subscription to the list of subscriptions. | 117 * Adds this subscription to the list of subscriptions. |
102 */ | 118 */ |
103 void AddToList(); | 119 void AddToList(); |
104 | 120 |
(...skipping 15 matching lines...) Expand all Loading... | |
120 bool IsUpdating() const; | 136 bool IsUpdating() const; |
121 | 137 |
122 /** | 138 /** |
123 * Indicates whether the subscription is the Acceptable Ads subscription. | 139 * Indicates whether the subscription is the Acceptable Ads subscription. |
124 * @return `true` if this subscription is the Acceptable Ads subscription. | 140 * @return `true` if this subscription is the Acceptable Ads subscription. |
125 */ | 141 */ |
126 bool IsAA() const; | 142 bool IsAA() const; |
127 | 143 |
128 bool operator==(const Subscription& subscription) const; | 144 bool operator==(const Subscription& subscription) const; |
129 | 145 |
146 protected: | |
130 /** | 147 /** |
131 * Creates a wrapper for an existing JavaScript subscription object. | 148 * Creates a wrapper for an existing JavaScript subscription object. |
132 * Normally you shouldn't call this directly, but use | 149 * Normally you shouldn't call this directly, but use |
133 * FilterEngine::GetSubscription() instead. | 150 * FilterEngine::GetSubscription() instead. |
134 * @param value JavaScript subscription object. | 151 * @param value JavaScript subscription object. |
135 */ | 152 */ |
136 Subscription(JsValue&& value); | 153 Subscription(JsValue&& value); |
137 }; | 154 }; |
138 | 155 |
139 /** | 156 /** |
140 * Shared smart pointer to a `Filter` instance. | 157 * Shared smart pointer to a `Filter` instance. |
141 */ | 158 */ |
142 typedef std::unique_ptr<Filter> FilterPtr; | 159 typedef std::unique_ptr<Filter> FilterPtr; |
143 | 160 |
144 /** | 161 /** |
145 * Shared smart pointer to a `Subscription` instance. | |
146 */ | |
147 typedef std::shared_ptr<Subscription> SubscriptionPtr; | |
148 | |
149 /** | |
150 * Main component of libadblockplus. | 162 * Main component of libadblockplus. |
151 * It handles: | 163 * It handles: |
152 * - Filter management and matching. | 164 * - Filter management and matching. |
153 * - Subscription management and synchronization. | 165 * - Subscription management and synchronization. |
154 * - Update checks for the application. | 166 * - Update checks for the application. |
155 */ | 167 */ |
156 class FilterEngine | 168 class FilterEngine |
157 { | 169 { |
158 public: | 170 public: |
159 // Make sure to keep ContentType in sync with FilterEngine::contentTypes | 171 // 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. | 297 * see https://adblockplus.org/en/filters. |
286 * @return New `Filter` instance. | 298 * @return New `Filter` instance. |
287 */ | 299 */ |
288 Filter GetFilter(const std::string& text) const; | 300 Filter GetFilter(const std::string& text) const; |
289 | 301 |
290 /** | 302 /** |
291 * Retrieves a subscription object for the supplied URL. | 303 * Retrieves a subscription object for the supplied URL. |
292 * @param url Subscription URL. | 304 * @param url Subscription URL. |
293 * @return New `Subscription` instance. | 305 * @return New `Subscription` instance. |
294 */ | 306 */ |
295 SubscriptionPtr GetSubscription(const std::string& url) const; | 307 Subscription GetSubscription(const std::string& url) const; |
296 | 308 |
297 /** | 309 /** |
298 * Retrieves the list of custom filters. | 310 * Retrieves the list of custom filters. |
299 * @return List of custom filters. | 311 * @return List of custom filters. |
300 */ | 312 */ |
301 std::vector<Filter> GetListedFilters() const; | 313 std::vector<Filter> GetListedFilters() const; |
302 | 314 |
303 /** | 315 /** |
304 * Retrieves all subscriptions. | 316 * Retrieves all subscriptions. |
305 * @return List of subscriptions. | 317 * @return List of subscriptions. |
306 */ | 318 */ |
307 std::vector<SubscriptionPtr> GetListedSubscriptions() const; | 319 std::vector<Subscription> GetListedSubscriptions() const; |
308 | 320 |
309 /** | 321 /** |
310 * Retrieves all recommended subscriptions. | 322 * Retrieves all recommended subscriptions. |
311 * @return List of recommended subscriptions. | 323 * @return List of recommended subscriptions. |
312 */ | 324 */ |
313 std::vector<SubscriptionPtr> FetchAvailableSubscriptions() const; | 325 std::vector<Subscription> FetchAvailableSubscriptions() const; |
314 | 326 |
315 /** | 327 /** |
316 * Ensures that the Acceptable Ads subscription is enabled or disabled. | 328 * Ensures that the Acceptable Ads subscription is enabled or disabled. |
317 * @param enabled | 329 * @param enabled |
318 * - if the value is `true` | 330 * - if the value is `true` |
319 * - ensure that the filter set includes an enabled AA subscription, | 331 * - ensure that the filter set includes an enabled AA subscription, |
320 * adding it if needed and enabling it if disabled. | 332 * adding it if needed and enabling it if disabled. |
321 * - if the value is `false` | 333 * - if the value is `false` |
322 * - if an AA subscription is present, disable it. | 334 * - if an AA subscription is present, disable it. |
323 * - if absent, do nothing. | 335 * - if absent, do nothing. |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
542 const JsValueList& param) const; | 554 const JsValueList& param) const; |
543 FilterPtr GetWhitelistingFilter(const std::string& url, | 555 FilterPtr GetWhitelistingFilter(const std::string& url, |
544 ContentTypeMask contentTypeMask, const std::string& documentUrl) const; | 556 ContentTypeMask contentTypeMask, const std::string& documentUrl) const; |
545 FilterPtr GetWhitelistingFilter(const std::string& url, | 557 FilterPtr GetWhitelistingFilter(const std::string& url, |
546 ContentTypeMask contentTypeMask, | 558 ContentTypeMask contentTypeMask, |
547 const std::vector<std::string>& documentUrls) const; | 559 const std::vector<std::string>& documentUrls) const; |
548 }; | 560 }; |
549 } | 561 } |
550 | 562 |
551 #endif | 563 #endif |
OLD | NEW |