Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: include/AdblockPlus/FilterEngine.h

Issue 29335462: Issue 3337 - Update adblockplus reference in libadblockplus to revision hg:813682c7161e (Closed)
Patch Set: Created Feb. 3, 2016, 1:26 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
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-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 * Main component of libadblockplus. 143 * Main component of libadblockplus.
144 * It handles: 144 * It handles:
145 * - Filter management and matching. 145 * - Filter management and matching.
146 * - Subscription management and synchronization. 146 * - Subscription management and synchronization.
147 * - Update checks for the application. 147 * - Update checks for the application.
148 */ 148 */
149 class FilterEngine 149 class FilterEngine
150 { 150 {
151 public: 151 public:
152 // Make sure to keep ContentType in sync with FilterEngine::contentTypes 152 // Make sure to keep ContentType in sync with FilterEngine::contentTypes
153 // and with RegExpFilter.typeMap from filterClasses.js.
153 /** 154 /**
154 * Possible resource content types. 155 * Possible resource content types.
155 */ 156 */
156 enum ContentType {CONTENT_TYPE_OTHER, CONTENT_TYPE_SCRIPT, 157 enum ContentType
157 CONTENT_TYPE_IMAGE, CONTENT_TYPE_STYLESHEET, 158 {
158 CONTENT_TYPE_OBJECT, CONTENT_TYPE_SUBDOCUMENT, 159 CONTENT_TYPE_OTHER = 1,
159 CONTENT_TYPE_DOCUMENT, CONTENT_TYPE_XMLHTTPREQUEST, 160 CONTENT_TYPE_SCRIPT = 2,
160 CONTENT_TYPE_OBJECT_SUBREQUEST, CONTENT_TYPE_FONT, 161 CONTENT_TYPE_IMAGE = 4,
161 CONTENT_TYPE_MEDIA, CONTENT_TYPE_ELEMHIDE}; 162 CONTENT_TYPE_STYLESHEET = 8,
163 CONTENT_TYPE_OBJECT = 16,
164 CONTENT_TYPE_SUBDOCUMENT = 32,
165 CONTENT_TYPE_DOCUMENT = 64,
166 CONTENT_TYPE_PING = 1024,
167 CONTENT_TYPE_XMLHTTPREQUEST = 2048,
168 CONTENT_TYPE_OBJECT_SUBREQUEST = 4096,
169 CONTENT_TYPE_MEDIA = 16384,
170 CONTENT_TYPE_FONT = 32768,
171 CONTENT_TYPE_GENERICBLOCK = 0x20000000,
172 CONTENT_TYPE_ELEMHIDE = 0x40000000,
173 CONTENT_TYPE_GENERICHIDE = 0x80000000
174 };
162 175
163 /** 176 /**
164 * Callback type invoked when an update becomes available. 177 * Callback type invoked when an update becomes available.
165 * The parameter is the download URL of the update. 178 * The parameter is the download URL of the update.
166 */ 179 */
167 typedef std::function<void(const std::string&)> UpdateAvailableCallback; 180 typedef std::function<void(const std::string&)> UpdateAvailableCallback;
168 181
169 /** 182 /**
170 * Callback type invoked when a manually triggered update check finishes. 183 * Callback type invoked when a manually triggered update check finishes.
171 * The parameter is an optional error message. 184 * The parameter is an optional error message.
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 void SetShowNotificationCallback(const ShowNotificationCallback& value); 275 void SetShowNotificationCallback(const ShowNotificationCallback& value);
263 276
264 /** 277 /**
265 * Removes the callback invoked when a notification should be shown. 278 * Removes the callback invoked when a notification should be shown.
266 */ 279 */
267 void RemoveShowNotificationCallback(); 280 void RemoveShowNotificationCallback();
268 281
269 /** 282 /**
270 * Checks if any active filter matches the supplied URL. 283 * Checks if any active filter matches the supplied URL.
271 * @param url URL to match. 284 * @param url URL to match.
272 * @param contentType Content type of the requested resource. 285 * @param contentTypeMask Content type mask of the requested resource.
273 * @param documentUrl URL of the document requesting the resource. 286 * @param documentUrl URL of the document requesting the resource.
274 * Note that there will be more than one document if frames are 287 * Note that there will be more than one document if frames are
275 * involved, see 288 * involved, see
276 * Matches(const std::string&, const std::string&, const std::vector< std::string>&) const. 289 * Matches(const std::string&, const std::string&, const std::vector< std::string>&) const.
277 * @return Matching filter, or `null` if there was no match. 290 * @return Matching filter, or `null` if there was no match.
278 * @throw `std::invalid_argument`, if an invalid `contentType` was supplied. 291 * @throw `std::invalid_argument`, if an invalid `contentType` was supplied.
279 */ 292 */
280 FilterPtr Matches(const std::string& url, 293 FilterPtr Matches(const std::string& url,
281 ContentType contentType, 294 int32_t contentTypeMask,
Eric 2016/02/09 15:43:03 It would seem better to use uint32_t here, given t
sergei 2016/02/09 17:15:47 Yes, however it will be converted into signed inte
282 const std::string& documentUrl) const; 295 const std::string& documentUrl) const;
283 296
284 /** 297 /**
285 * Checks if any active filter matches the supplied URL. 298 * Checks if any active filter matches the supplied URL.
286 * @param url URL to match. 299 * @param url URL to match.
287 * @param contentType Content type of the requested resource. 300 * @param contentTypeMask Content type mask of the requested resource.
288 * @param documentUrls Chain of documents requesting the resource, starting 301 * @param documentUrls Chain of documents requesting the resource, starting
289 * with the current resource's parent frame, ending with the 302 * with the current resource's parent frame, ending with the
290 * top-level frame. 303 * top-level frame.
291 * If the application is not capable of identifying the frame 304 * If the application is not capable of identifying the frame
292 * structure, e.g. because it is a proxy, it can be approximated 305 * structure, e.g. because it is a proxy, it can be approximated
293 * using `ReferrerMapping`. 306 * using `ReferrerMapping`.
294 * @return Matching filter, or a `null` if there was no match. 307 * @return Matching filter, or a `null` if there was no match.
295 * @throw `std::invalid_argument`, if an invalid `contentType` was supplied. 308 * @throw `std::invalid_argument`, if an invalid `contentType` was supplied.
296 */ 309 */
297 FilterPtr Matches(const std::string& url, 310 FilterPtr Matches(const std::string& url,
298 ContentType contentType, 311 int32_t contentTypeMask,
299 const std::vector<std::string>& documentUrls) const; 312 const std::vector<std::string>& documentUrls) const;
300 313
301 /** 314 /**
302 * Checks whether the document at the supplied URL is whitelisted. 315 * Checks whether the document at the supplied URL is whitelisted.
303 * @param url URL of the document. 316 * @param url URL of the document.
304 * @param documentUrls Chain of document URLs requesting the document, 317 * @param documentUrls Chain of document URLs requesting the document,
305 * starting with the current document's parent frame, ending with 318 * starting with the current document's parent frame, ending with
306 * the top-level frame. 319 * the top-level frame.
307 * If the application is not capable of identifying the frame 320 * If the application is not capable of identifying the frame
308 * structure, e.g. because it is a proxy, it can be approximated 321 * structure, e.g. because it is a proxy, it can be approximated
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 435
423 private: 436 private:
424 JsEnginePtr jsEngine; 437 JsEnginePtr jsEngine;
425 bool initialized; 438 bool initialized;
426 bool firstRun; 439 bool firstRun;
427 int updateCheckId; 440 int updateCheckId;
428 static const std::map<ContentType, std::string> contentTypes; 441 static const std::map<ContentType, std::string> contentTypes;
429 442
430 void InitDone(JsValueList& params); 443 void InitDone(JsValueList& params);
431 FilterPtr CheckFilterMatch(const std::string& url, 444 FilterPtr CheckFilterMatch(const std::string& url,
432 ContentType contentType, 445 int32_t contentTypeMask,
433 const std::string& documentUrl) const; 446 const std::string& documentUrl) const;
434 void UpdateAvailable(UpdateAvailableCallback callback, JsValueList& params); 447 void UpdateAvailable(UpdateAvailableCallback callback, JsValueList& params);
435 void UpdateCheckDone(const std::string& eventName, 448 void UpdateCheckDone(const std::string& eventName,
436 UpdateCheckDoneCallback callback, JsValueList& params); 449 UpdateCheckDoneCallback callback, JsValueList& params);
437 void FilterChanged(FilterChangeCallback callback, JsValueList& params); 450 void FilterChanged(FilterChangeCallback callback, JsValueList& params);
438 void ShowNotification(const ShowNotificationCallback& callback, 451 void ShowNotification(const ShowNotificationCallback& callback,
439 const JsValueList& params); 452 const JsValueList& params);
440 FilterPtr GetWhitelistingFilter(const std::string& url, 453 FilterPtr GetWhitelistingFilter(const std::string& url,
441 ContentType contentType, const std::string& documentUrl) const; 454 int32_t contentTypeMask, const std::string& documentUrl) const;
442 FilterPtr GetWhitelistingFilter(const std::string& url, 455 FilterPtr GetWhitelistingFilter(const std::string& url,
443 ContentType contentType, 456 int32_t contentTypeMask,
444 const std::vector<std::string>& documentUrls) const; 457 const std::vector<std::string>& documentUrls) const;
445 }; 458 };
446 } 459 }
447 460
448 #endif 461 #endif
OLDNEW
« no previous file with comments | « ensure_dependencies.py ('k') | lib/api.js » ('j') | test/FilterEngine.cpp » ('J')

Powered by Google App Engine
This is Rietveld