| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2014 Eyeo GmbH | 3 * Copyright (C) 2006-2015 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 * |
| 14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
| 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| 16 */ | 16 */ |
| 17 | 17 |
| 18 #ifndef ADBLOCK_PLUS_FILTER_ENGINE_H | 18 #ifndef ADBLOCK_PLUS_FILTER_ENGINE_H |
| 19 #define ADBLOCK_PLUS_FILTER_ENGINE_H | 19 #define ADBLOCK_PLUS_FILTER_ENGINE_H |
| 20 | 20 |
| 21 #include <functional> | 21 #include <functional> |
| 22 #include <map> | 22 #include <map> |
| 23 #include <string> | 23 #include <string> |
| 24 #include <vector> | 24 #include <vector> |
| 25 #include <AdblockPlus/JsEngine.h> | 25 #include <AdblockPlus/JsEngine.h> |
| 26 #include <AdblockPlus/JsValue.h> | 26 #include <AdblockPlus/JsValue.h> |
| 27 #include <AdblockPlus/Notification.h> |
| 27 | 28 |
| 28 #include "tr1_memory.h" | 29 #include "tr1_memory.h" |
| 29 | 30 |
| 30 namespace AdblockPlus | 31 namespace AdblockPlus |
| 31 { | 32 { |
| 32 class FilterEngine; | 33 class FilterEngine; |
| 33 | 34 |
| 34 /** | 35 /** |
| 35 * Wrapper for an Adblock Plus filter object. | 36 * Wrapper for an Adblock Plus filter object. |
| 37 * There are no accessors for most |
| 38 * [filter properties](https://adblockplus.org/jsdoc/adblockplus/symbols/Filte
r.html), |
| 39 * use `GetProperty()` to retrieve them by name. |
| 36 */ | 40 */ |
| 37 class Filter : public JsValue, | 41 class Filter : public JsValue, |
| 38 public std::tr1::enable_shared_from_this<Filter> | 42 public std::tr1::enable_shared_from_this<Filter> |
| 39 { | 43 { |
| 40 public: | 44 public: |
| 41 /** | 45 /** |
| 42 * Filter types, see https://adblockplus.org/en/filters. | 46 * Filter types, see https://adblockplus.org/en/filters. |
| 43 */ | 47 */ |
| 44 enum Type {TYPE_BLOCKING, TYPE_EXCEPTION, | 48 enum Type {TYPE_BLOCKING, TYPE_EXCEPTION, |
| 45 TYPE_ELEMHIDE, TYPE_ELEMHIDE_EXCEPTION, | 49 TYPE_ELEMHIDE, TYPE_ELEMHIDE_EXCEPTION, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 73 * Creates a wrapper for an existing JavaScript filter object. | 77 * Creates a wrapper for an existing JavaScript filter object. |
| 74 * Normally you shouldn't call this directly, but use | 78 * Normally you shouldn't call this directly, but use |
| 75 * FilterEngine::GetFilter() instead. | 79 * FilterEngine::GetFilter() instead. |
| 76 * @param value JavaScript filter object. | 80 * @param value JavaScript filter object. |
| 77 */ | 81 */ |
| 78 Filter(JsValuePtr value); | 82 Filter(JsValuePtr value); |
| 79 }; | 83 }; |
| 80 | 84 |
| 81 /** | 85 /** |
| 82 * Wrapper for a subscription object. | 86 * Wrapper for a subscription object. |
| 87 * There are no accessors for most |
| 88 * [subscription properties](https://adblockplus.org/jsdoc/adblockplus/symbols
/Subscription.html), |
| 89 * use `GetProperty()` to retrieve them by name. |
| 83 */ | 90 */ |
| 84 class Subscription : public JsValue, | 91 class Subscription : public JsValue, |
| 85 public std::tr1::enable_shared_from_this<Subscription> | 92 public std::tr1::enable_shared_from_this<Subscription> |
| 86 { | 93 { |
| 87 public: | 94 public: |
| 88 /** | 95 /** |
| 89 * 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. |
| 90 * @return `true` if this subscription has been added. | 97 * @return `true` if this subscription has been added. |
| 91 */ | 98 */ |
| 92 bool IsListed(); | 99 bool IsListed(); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 public: | 153 public: |
| 147 // Make sure to keep ContentType in sync with FilterEngine::contentTypes | 154 // Make sure to keep ContentType in sync with FilterEngine::contentTypes |
| 148 /** | 155 /** |
| 149 * Possible resource content types. | 156 * Possible resource content types. |
| 150 */ | 157 */ |
| 151 enum ContentType {CONTENT_TYPE_OTHER, CONTENT_TYPE_SCRIPT, | 158 enum ContentType {CONTENT_TYPE_OTHER, CONTENT_TYPE_SCRIPT, |
| 152 CONTENT_TYPE_IMAGE, CONTENT_TYPE_STYLESHEET, | 159 CONTENT_TYPE_IMAGE, CONTENT_TYPE_STYLESHEET, |
| 153 CONTENT_TYPE_OBJECT, CONTENT_TYPE_SUBDOCUMENT, | 160 CONTENT_TYPE_OBJECT, CONTENT_TYPE_SUBDOCUMENT, |
| 154 CONTENT_TYPE_DOCUMENT, CONTENT_TYPE_XMLHTTPREQUEST, | 161 CONTENT_TYPE_DOCUMENT, CONTENT_TYPE_XMLHTTPREQUEST, |
| 155 CONTENT_TYPE_OBJECT_SUBREQUEST, CONTENT_TYPE_FONT, | 162 CONTENT_TYPE_OBJECT_SUBREQUEST, CONTENT_TYPE_FONT, |
| 156 CONTENT_TYPE_MEDIA}; | 163 CONTENT_TYPE_MEDIA, CONTENT_TYPE_ELEMHIDE}; |
| 157 | 164 |
| 158 /** | 165 /** |
| 159 * Callback type invoked when an update becomes available. | 166 * Callback type invoked when an update becomes available. |
| 160 * The parameter is the download URL of the update. | 167 * The parameter is the download URL of the update. |
| 161 */ | 168 */ |
| 162 typedef std::tr1::function<void(const std::string&)> | 169 typedef std::tr1::function<void(const std::string&)> |
| 163 UpdateAvailableCallback; | 170 UpdateAvailableCallback; |
| 164 | 171 |
| 165 /** | 172 /** |
| 166 * Callback type invoked when a manually triggered update check finishes. | 173 * Callback type invoked when a manually triggered update check finishes. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 */ | 231 */ |
| 225 std::vector<SubscriptionPtr> GetListedSubscriptions() const; | 232 std::vector<SubscriptionPtr> GetListedSubscriptions() const; |
| 226 | 233 |
| 227 /** | 234 /** |
| 228 * Retrieves all recommended subscriptions. | 235 * Retrieves all recommended subscriptions. |
| 229 * @return List of recommended subscriptions. | 236 * @return List of recommended subscriptions. |
| 230 */ | 237 */ |
| 231 std::vector<SubscriptionPtr> FetchAvailableSubscriptions() const; | 238 std::vector<SubscriptionPtr> FetchAvailableSubscriptions() const; |
| 232 | 239 |
| 233 /** | 240 /** |
| 241 * Determines which notification is to be shown next. |
| 242 * @param url URL to match notifications to (optional). |
| 243 * @return Notification to be shown, or `null` if there is no any. |
| 244 */ |
| 245 NotificationPtr GetNextNotificationToShow( |
| 246 const std::string& url = std::string()); |
| 247 |
| 248 /** |
| 234 * Checks if any active filter matches the supplied URL. | 249 * Checks if any active filter matches the supplied URL. |
| 235 * @param url URL to match. | 250 * @param url URL to match. |
| 236 * @param contentType Content type of the requested resource. | 251 * @param contentType Content type of the requested resource. |
| 237 * @param documentUrl URL of the document requesting the resource. | 252 * @param documentUrl URL of the document requesting the resource. |
| 238 * Note that there will be more than one document if frames are | 253 * Note that there will be more than one document if frames are |
| 239 * involved, see | 254 * involved, see |
| 240 * Matches(const std::string&, const std::string&, const std::vector<
std::string>&) const. | 255 * Matches(const std::string&, const std::string&, const std::vector<
std::string>&) const. |
| 241 * @return Matching filter, or `null` if there was no match. | 256 * @return Matching filter, or `null` if there was no match. |
| 242 * @throw `std::invalid_argument`, if an invalid `contentType` was supplied. | 257 * @throw `std::invalid_argument`, if an invalid `contentType` was supplied. |
| 243 */ | 258 */ |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 ContentType contentType, | 383 ContentType contentType, |
| 369 const std::string& documentUrl) const; | 384 const std::string& documentUrl) const; |
| 370 void UpdateAvailable(UpdateAvailableCallback callback, JsValueList& params); | 385 void UpdateAvailable(UpdateAvailableCallback callback, JsValueList& params); |
| 371 void UpdateCheckDone(const std::string& eventName, | 386 void UpdateCheckDone(const std::string& eventName, |
| 372 UpdateCheckDoneCallback callback, JsValueList& params); | 387 UpdateCheckDoneCallback callback, JsValueList& params); |
| 373 void FilterChanged(FilterChangeCallback callback, JsValueList& params); | 388 void FilterChanged(FilterChangeCallback callback, JsValueList& params); |
| 374 }; | 389 }; |
| 375 } | 390 } |
| 376 | 391 |
| 377 #endif | 392 #endif |
| OLD | NEW |