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-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&)> NotificationAvailab leCallback; | |
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 SetNotificationAvailableCallback(const NotificationAvailableCallback& v alue); | |
Felix Dahlke
2015/06/25 18:35:48
I'd prefer to call this SetNotificationShowCallbac
sergei
2015/06/26 14:21:17
I think the callback should be called `ShowNotific
Felix Dahlke
2015/06/30 19:45:31
Yeah, fair enough.
| |
258 | |
259 /** | |
260 * Removes the callback invoked when a notification should be shown. | |
261 * available. | |
262 */ | |
263 void RemoveNotificationAvailableCallback(); | |
247 | 264 |
248 /** | 265 /** |
249 * Checks if any active filter matches the supplied URL. | 266 * Checks if any active filter matches the supplied URL. |
250 * @param url URL to match. | 267 * @param url URL to match. |
251 * @param contentType Content type of the requested resource. | 268 * @param contentType Content type of the requested resource. |
252 * @param documentUrl URL of the document requesting the resource. | 269 * @param documentUrl URL of the document requesting the resource. |
253 * Note that there will be more than one document if frames are | 270 * Note that there will be more than one document if frames are |
254 * involved, see | 271 * involved, see |
255 * Matches(const std::string&, const std::string&, const std::vector< std::string>&) const. | 272 * Matches(const std::string&, const std::string&, const std::vector< std::string>&) const. |
256 * @return Matching filter, or `null` if there was no match. | 273 * @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; | 396 static const std::map<ContentType, std::string> contentTypes; |
380 | 397 |
381 void InitDone(JsValueList& params); | 398 void InitDone(JsValueList& params); |
382 FilterPtr CheckFilterMatch(const std::string& url, | 399 FilterPtr CheckFilterMatch(const std::string& url, |
383 ContentType contentType, | 400 ContentType contentType, |
384 const std::string& documentUrl) const; | 401 const std::string& documentUrl) const; |
385 void UpdateAvailable(UpdateAvailableCallback callback, JsValueList& params); | 402 void UpdateAvailable(UpdateAvailableCallback callback, JsValueList& params); |
386 void UpdateCheckDone(const std::string& eventName, | 403 void UpdateCheckDone(const std::string& eventName, |
387 UpdateCheckDoneCallback callback, JsValueList& params); | 404 UpdateCheckDoneCallback callback, JsValueList& params); |
388 void FilterChanged(FilterChangeCallback callback, JsValueList& params); | 405 void FilterChanged(FilterChangeCallback callback, JsValueList& params); |
406 void NotificationAvailable(const NotificationAvailableCallback& callback, | |
407 const JsValueList& params); | |
389 }; | 408 }; |
390 } | 409 } |
391 | 410 |
392 #endif | 411 #endif |
OLD | NEW |