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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 * Container of name-value pairs representing a set of preferences. | 189 * Container of name-value pairs representing a set of preferences. |
190 */ | 190 */ |
191 typedef std::map<std::string, AdblockPlus::JsValuePtr> Prefs; | 191 typedef std::map<std::string, AdblockPlus::JsValuePtr> Prefs; |
192 | 192 |
193 /** | 193 /** |
| 194 * Callback type invoked when a new notification should be shown. |
| 195 * The parameter is the Notification object to be shown. |
| 196 */ |
| 197 typedef std::tr1::function<void(const NotificationPtr&)> ShowNotificationCal
lback; |
| 198 |
| 199 /** |
194 * Constructor. | 200 * Constructor. |
195 * @param jsEngine `JsEngine` instance used to run JavaScript code | 201 * @param jsEngine `JsEngine` instance used to run JavaScript code |
196 * internally. | 202 * internally. |
197 * @param preconfiguredPrefs `AdblockPlus::FilterEngine::Prefs` | 203 * @param preconfiguredPrefs `AdblockPlus::FilterEngine::Prefs` |
198 * name-value list of preconfigured prefs. | 204 * name-value list of preconfigured prefs. |
199 */ | 205 */ |
200 explicit FilterEngine(JsEnginePtr jsEngine, | 206 explicit FilterEngine(JsEnginePtr jsEngine, |
201 const Prefs& preconfiguredPrefs = Prefs() | 207 const Prefs& preconfiguredPrefs = Prefs() |
202 ); | 208 ); |
203 | 209 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 */ | 246 */ |
241 std::vector<SubscriptionPtr> GetListedSubscriptions() const; | 247 std::vector<SubscriptionPtr> GetListedSubscriptions() const; |
242 | 248 |
243 /** | 249 /** |
244 * Retrieves all recommended subscriptions. | 250 * Retrieves all recommended subscriptions. |
245 * @return List of recommended subscriptions. | 251 * @return List of recommended subscriptions. |
246 */ | 252 */ |
247 std::vector<SubscriptionPtr> FetchAvailableSubscriptions() const; | 253 std::vector<SubscriptionPtr> FetchAvailableSubscriptions() const; |
248 | 254 |
249 /** | 255 /** |
250 * Determines which notification is to be shown next. | 256 * Invokes the listener set via SetNotificationAvailableCallback() with the |
| 257 * next notification to be shown. |
251 * @param url URL to match notifications to (optional). | 258 * @param url URL to match notifications to (optional). |
252 * @return Notification to be shown, or `null` if there is no any. | |
253 */ | 259 */ |
254 NotificationPtr GetNextNotificationToShow( | 260 void ShowNextNotification(const std::string& url = std::string()); |
255 const std::string& url = std::string()); | 261 |
| 262 /** |
| 263 * Sets the callback invoked when a notification should be shown. |
| 264 * @param callback Callback to invoke. |
| 265 */ |
| 266 void SetShowNotificationCallback(const ShowNotificationCallback& value); |
| 267 |
| 268 /** |
| 269 * Removes the callback invoked when a notification should be shown. |
| 270 */ |
| 271 void RemoveShowNotificationCallback(); |
256 | 272 |
257 /** | 273 /** |
258 * Checks if any active filter matches the supplied URL. | 274 * Checks if any active filter matches the supplied URL. |
259 * @param url URL to match. | 275 * @param url URL to match. |
260 * @param contentType Content type of the requested resource. | 276 * @param contentType Content type of the requested resource. |
261 * @param documentUrl URL of the document requesting the resource. | 277 * @param documentUrl URL of the document requesting the resource. |
262 * Note that there will be more than one document if frames are | 278 * Note that there will be more than one document if frames are |
263 * involved, see | 279 * involved, see |
264 * Matches(const std::string&, const std::string&, const std::vector<
std::string>&) const. | 280 * Matches(const std::string&, const std::string&, const std::vector<
std::string>&) const. |
265 * @return Matching filter, or `null` if there was no match. | 281 * @return Matching filter, or `null` if there was no match. |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 static const std::map<ContentType, std::string> contentTypes; | 404 static const std::map<ContentType, std::string> contentTypes; |
389 | 405 |
390 void InitDone(JsValueList& params); | 406 void InitDone(JsValueList& params); |
391 FilterPtr CheckFilterMatch(const std::string& url, | 407 FilterPtr CheckFilterMatch(const std::string& url, |
392 ContentType contentType, | 408 ContentType contentType, |
393 const std::string& documentUrl) const; | 409 const std::string& documentUrl) const; |
394 void UpdateAvailable(UpdateAvailableCallback callback, JsValueList& params); | 410 void UpdateAvailable(UpdateAvailableCallback callback, JsValueList& params); |
395 void UpdateCheckDone(const std::string& eventName, | 411 void UpdateCheckDone(const std::string& eventName, |
396 UpdateCheckDoneCallback callback, JsValueList& params); | 412 UpdateCheckDoneCallback callback, JsValueList& params); |
397 void FilterChanged(FilterChangeCallback callback, JsValueList& params); | 413 void FilterChanged(FilterChangeCallback callback, JsValueList& params); |
| 414 void ShowNotification(const ShowNotificationCallback& callback, |
| 415 const JsValueList& params); |
398 }; | 416 }; |
399 } | 417 } |
400 | 418 |
401 #endif | 419 #endif |
OLD | NEW |