| 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-2015 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 |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 /** | 179 /** |
| 180 * Callback type invoked when the filters change. | 180 * Callback type invoked when the filters change. |
| 181 * The first parameter is the action event code (see | 181 * The first parameter is the action event code (see |
| 182 * [FilterNotifier.triggerListeners](https://adblockplus.org/jsdoc/adblockpl
us/symbols/FilterNotifier.html#.triggerListeners) | 182 * [FilterNotifier.triggerListeners](https://adblockplus.org/jsdoc/adblockpl
us/symbols/FilterNotifier.html#.triggerListeners) |
| 183 * for the full list). | 183 * for the full list). |
| 184 * The second parameter is the filter/subscription object affected, if any. | 184 * The second parameter is the filter/subscription object affected, if any. |
| 185 */ | 185 */ |
| 186 typedef std::tr1::function<void(const std::string&, const JsValuePtr)> Filte
rChangeCallback; | 186 typedef std::tr1::function<void(const std::string&, const JsValuePtr)> Filte
rChangeCallback; |
| 187 | 187 |
| 188 /** | 188 /** |
| 189 * Callback type invoked when a new notification should be shown. |
| 190 * The parameter is the Notification object to be shown. |
| 191 */ |
| 192 typedef std::tr1::function<void(const NotificationPtr&)> ShowNotificationCal
lback; |
| 193 |
| 194 /** |
| 189 * Constructor. | 195 * Constructor. |
| 190 * @param jsEngine `JsEngine` instance used to run JavaScript code | 196 * @param jsEngine `JsEngine` instance used to run JavaScript code |
| 191 * internally. | 197 * internally. |
| 192 */ | 198 */ |
| 193 explicit FilterEngine(JsEnginePtr jsEngine); | 199 explicit FilterEngine(JsEnginePtr jsEngine); |
| 194 | 200 |
| 195 /** | 201 /** |
| 196 * Retrieves the `JsEngine` instance associated with this `FilterEngine` | 202 * Retrieves the `JsEngine` instance associated with this `FilterEngine` |
| 197 * instance. | 203 * instance. |
| 198 */ | 204 */ |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 */ | 237 */ |
| 232 std::vector<SubscriptionPtr> GetListedSubscriptions() const; | 238 std::vector<SubscriptionPtr> GetListedSubscriptions() const; |
| 233 | 239 |
| 234 /** | 240 /** |
| 235 * Retrieves all recommended subscriptions. | 241 * Retrieves all recommended subscriptions. |
| 236 * @return List of recommended subscriptions. | 242 * @return List of recommended subscriptions. |
| 237 */ | 243 */ |
| 238 std::vector<SubscriptionPtr> FetchAvailableSubscriptions() const; | 244 std::vector<SubscriptionPtr> FetchAvailableSubscriptions() const; |
| 239 | 245 |
| 240 /** | 246 /** |
| 241 * Determines which notification is to be shown next. | 247 * Invokes the listener set via SetNotificationAvailableCallback() with the |
| 248 * next notification to be shown. |
| 242 * @param url URL to match notifications to (optional). | 249 * @param url URL to match notifications to (optional). |
| 243 * @return Notification to be shown, or `null` if there is no any. | |
| 244 */ | 250 */ |
| 245 NotificationPtr GetNextNotificationToShow( | 251 void ShowNextNotification(const std::string& url = std::string()); |
| 246 const std::string& url = std::string()); | 252 |
| 253 /** |
| 254 * Sets the callback invoked when a notification should be shown. |
| 255 * @param callback Callback to invoke. |
| 256 */ |
| 257 void SetShowNotificationCallback(const ShowNotificationCallback& value); |
| 258 |
| 259 /** |
| 260 * Removes the callback invoked when a notification should be shown. |
| 261 */ |
| 262 void RemoveShowNotificationCallback(); |
| 247 | 263 |
| 248 /** | 264 /** |
| 249 * Checks if any active filter matches the supplied URL. | 265 * Checks if any active filter matches the supplied URL. |
| 250 * @param url URL to match. | 266 * @param url URL to match. |
| 251 * @param contentType Content type of the requested resource. | 267 * @param contentType Content type of the requested resource. |
| 252 * @param documentUrl URL of the document requesting the resource. | 268 * @param documentUrl URL of the document requesting the resource. |
| 253 * Note that there will be more than one document if frames are | 269 * Note that there will be more than one document if frames are |
| 254 * involved, see | 270 * involved, see |
| 255 * Matches(const std::string&, const std::string&, const std::vector<
std::string>&) const. | 271 * Matches(const std::string&, const std::string&, const std::vector<
std::string>&) const. |
| 256 * @return Matching filter, or `null` if there was no match. | 272 * @return Matching filter, or `null` if there was no match. |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 static const std::map<ContentType, std::string> contentTypes; | 395 static const std::map<ContentType, std::string> contentTypes; |
| 380 | 396 |
| 381 void InitDone(JsValueList& params); | 397 void InitDone(JsValueList& params); |
| 382 FilterPtr CheckFilterMatch(const std::string& url, | 398 FilterPtr CheckFilterMatch(const std::string& url, |
| 383 ContentType contentType, | 399 ContentType contentType, |
| 384 const std::string& documentUrl) const; | 400 const std::string& documentUrl) const; |
| 385 void UpdateAvailable(UpdateAvailableCallback callback, JsValueList& params); | 401 void UpdateAvailable(UpdateAvailableCallback callback, JsValueList& params); |
| 386 void UpdateCheckDone(const std::string& eventName, | 402 void UpdateCheckDone(const std::string& eventName, |
| 387 UpdateCheckDoneCallback callback, JsValueList& params); | 403 UpdateCheckDoneCallback callback, JsValueList& params); |
| 388 void FilterChanged(FilterChangeCallback callback, JsValueList& params); | 404 void FilterChanged(FilterChangeCallback callback, JsValueList& params); |
| 405 void ShowNotification(const ShowNotificationCallback& callback, |
| 406 const JsValueList& params); |
| 389 }; | 407 }; |
| 390 } | 408 } |
| 391 | 409 |
| 392 #endif | 410 #endif |
| OLD | NEW |