|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2016 - 2019 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing an URL interceptor base class. |
|
8 """ |
|
9 |
|
10 from __future__ import unicode_literals |
|
11 |
|
12 from ..Network.UrlInterceptor import UrlInterceptor |
|
13 |
|
14 |
|
15 class AdBlockUrlInterceptor(UrlInterceptor): |
|
16 """ |
|
17 Class implementing an URL interceptor for AdBlock. |
|
18 """ |
|
19 def __init__(self, manager, parent=None): |
|
20 """ |
|
21 Constructor |
|
22 |
|
23 @param manager reference to the AdBlock manager |
|
24 @type AdBlockManager |
|
25 @param parent referemce to the parent object |
|
26 @type QObject |
|
27 """ |
|
28 super(AdBlockUrlInterceptor, self).__init__(parent) |
|
29 |
|
30 self.__manager = manager |
|
31 |
|
32 def interceptRequest(self, info): |
|
33 """ |
|
34 Public method to intercept a request. |
|
35 |
|
36 @param info request info object |
|
37 @type QWebEngineUrlRequestInfo |
|
38 """ |
|
39 if self.__manager.block(info): |
|
40 info.block(True) |