OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
3 * Copyright (C) 2006-2014 Eyeo GmbH | 3 * Copyright (C) 2006-2014 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 * Possible resource content types. | 149 * Possible resource content types. |
150 */ | 150 */ |
151 enum ContentType {CONTENT_TYPE_OTHER, CONTENT_TYPE_SCRIPT, | 151 enum ContentType {CONTENT_TYPE_OTHER, CONTENT_TYPE_SCRIPT, |
152 CONTENT_TYPE_IMAGE, CONTENT_TYPE_STYLESHEET, | 152 CONTENT_TYPE_IMAGE, CONTENT_TYPE_STYLESHEET, |
153 CONTENT_TYPE_OBJECT, CONTENT_TYPE_SUBDOCUMENT, | 153 CONTENT_TYPE_OBJECT, CONTENT_TYPE_SUBDOCUMENT, |
154 CONTENT_TYPE_DOCUMENT, CONTENT_TYPE_XMLHTTPREQUEST, | 154 CONTENT_TYPE_DOCUMENT, CONTENT_TYPE_XMLHTTPREQUEST, |
155 CONTENT_TYPE_OBJECT_SUBREQUEST, CONTENT_TYPE_FONT, | 155 CONTENT_TYPE_OBJECT_SUBREQUEST, CONTENT_TYPE_FONT, |
156 CONTENT_TYPE_MEDIA}; | 156 CONTENT_TYPE_MEDIA}; |
157 | 157 |
158 /** | 158 /** |
159 * Callback type invoked when an update is available. | 159 * Callback type invoked when an update becomes available. |
160 * The parameter is optional error message. | 160 * The parameter is the download URL of the update. |
161 */ | 161 */ |
162 typedef std::tr1::function<void(const std::string&)> UpdaterCallback; | 162 typedef std::tr1::function<void(const std::string&)> |
| 163 UpdateAvailableCallback; |
| 164 |
| 165 /** |
| 166 * Callback type invoked when a manually triggered update check finishes. |
| 167 * The parameter is an optional error message. |
| 168 */ |
| 169 typedef std::tr1::function<void(const std::string&)> |
| 170 UpdateCheckDoneCallback; |
163 | 171 |
164 /** | 172 /** |
165 * Callback type invoked when the filters change. | 173 * Callback type invoked when the filters change. |
166 * The first parameter is the action event code (see | 174 * The first parameter is the action event code (see |
167 * [FilterNotifier.triggerListeners](https://adblockplus.org/jsdoc/adblockpl
us/symbols/FilterNotifier.html#.triggerListeners) | 175 * [FilterNotifier.triggerListeners](https://adblockplus.org/jsdoc/adblockpl
us/symbols/FilterNotifier.html#.triggerListeners) |
168 * for the full list). | 176 * for the full list). |
169 * The second parameter is the filter/subscription object affected, if any. | 177 * The second parameter is the filter/subscription object affected, if any. |
170 */ | 178 */ |
171 typedef std::tr1::function<void(const std::string&, const JsValuePtr)> Filte
rChangeCallback; | 179 typedef std::tr1::function<void(const std::string&, const JsValuePtr)> Filte
rChangeCallback; |
172 | 180 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 void SetPref(const std::string& pref, JsValuePtr value); | 285 void SetPref(const std::string& pref, JsValuePtr value); |
278 | 286 |
279 /** | 287 /** |
280 * Extracts the host from a URL. | 288 * Extracts the host from a URL. |
281 * @param url URL to extract the host from. | 289 * @param url URL to extract the host from. |
282 * @return Extracted host. | 290 * @return Extracted host. |
283 */ | 291 */ |
284 std::string GetHostFromURL(const std::string& url); | 292 std::string GetHostFromURL(const std::string& url); |
285 | 293 |
286 /** | 294 /** |
| 295 * Sets the callback invoked when an application update becomes available. |
| 296 * @param callback Callback to invoke. |
| 297 */ |
| 298 void SetUpdateAvailableCallback(UpdateAvailableCallback callback); |
| 299 |
| 300 /** |
| 301 * Removes the callback invoked when an application update becomes |
| 302 * available. |
| 303 */ |
| 304 void RemoveUpdateAvailableCallback(); |
| 305 |
| 306 /** |
287 * Forces an immediate update check. | 307 * Forces an immediate update check. |
288 * `FilterEngine` will automatically check for updates in regular intervals, | 308 * `FilterEngine` will automatically check for updates in regular intervals, |
289 * so applications should only call this when the user triggers an update | 309 * so applications should only call this when the user triggers an update |
290 * check manually. | 310 * check manually. |
291 * @param callback Optional callback to invoke when the update check is | 311 * @param callback Optional callback to invoke when the update check is |
292 * finished. The string parameter will be empty when the update check | 312 * finished. The string parameter will be empty when the update check |
293 * succeeded, or contain an error message if it failed. | 313 * succeeded, or contain an error message if it failed. |
294 * Note that the callback will be invoked after every update check - | 314 * Note that the callback will be invoked whether updates are |
295 * to react to updates being available, register a callback for the | 315 * available or not - to react to updates being available, use |
296 * "updateAvailable" event (see JsEngine::SetEventCallback()). | 316 * `FilterEngine::SetUpdateAvailableCallback()`. |
297 */ | 317 */ |
298 void ForceUpdateCheck(UpdaterCallback callback = 0); | 318 void ForceUpdateCheck(UpdateCheckDoneCallback callback = 0); |
299 | 319 |
300 /** | 320 /** |
301 * Sets the callback invoked when the filters change. | 321 * Sets the callback invoked when the filters change. |
302 * @param callback Callback to invoke. | 322 * @param callback Callback to invoke. |
303 */ | 323 */ |
304 void SetFilterChangeCallback(FilterChangeCallback callback); | 324 void SetFilterChangeCallback(FilterChangeCallback callback); |
305 | 325 |
306 /** | 326 /** |
307 * Removes the callback invoked when the filters change. | 327 * Removes the callback invoked when the filters change. |
308 */ | 328 */ |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 JsEnginePtr jsEngine; | 360 JsEnginePtr jsEngine; |
341 bool initialized; | 361 bool initialized; |
342 bool firstRun; | 362 bool firstRun; |
343 int updateCheckId; | 363 int updateCheckId; |
344 static const std::map<ContentType, std::string> contentTypes; | 364 static const std::map<ContentType, std::string> contentTypes; |
345 | 365 |
346 void InitDone(JsValueList& params); | 366 void InitDone(JsValueList& params); |
347 FilterPtr CheckFilterMatch(const std::string& url, | 367 FilterPtr CheckFilterMatch(const std::string& url, |
348 ContentType contentType, | 368 ContentType contentType, |
349 const std::string& documentUrl) const; | 369 const std::string& documentUrl) const; |
350 void UpdateCheckDone(const std::string& eventName, UpdaterCallback callback,
JsValueList& params); | 370 void UpdateAvailable(UpdateAvailableCallback callback, JsValueList& params); |
| 371 void UpdateCheckDone(const std::string& eventName, |
| 372 UpdateCheckDoneCallback callback, JsValueList& params); |
351 void FilterChanged(FilterChangeCallback callback, JsValueList& params); | 373 void FilterChanged(FilterChangeCallback callback, JsValueList& params); |
352 }; | 374 }; |
353 } | 375 } |
354 | 376 |
355 #endif | 377 #endif |
OLD | NEW |