43 from .OpenSearch.OpenSearchEngineAction import OpenSearchEngineAction |
43 from .OpenSearch.OpenSearchEngineAction import OpenSearchEngineAction |
44 from .OpenSearch.OpenSearchEngine import OpenSearchEngine |
44 from .OpenSearch.OpenSearchEngine import OpenSearchEngine |
45 |
45 |
46 from .WebPlugins.WebPluginFactory import WebPluginFactory |
46 from .WebPlugins.WebPluginFactory import WebPluginFactory |
47 |
47 |
|
48 from .AdBlock.AdBlockPage import AdBlockedPageEntry |
|
49 |
48 ########################################################################################## |
50 ########################################################################################## |
49 |
51 |
50 |
52 |
51 class JavaScriptExternalObject(QObject): |
53 class JavaScriptExternalObject(QObject): |
52 """ |
54 """ |
179 Helpviewer.HelpWindow.HelpWindow.networkAccessManager()) |
181 Helpviewer.HelpWindow.HelpWindow.networkAccessManager()) |
180 self.setNetworkAccessManager(self.__proxy) |
182 self.setNetworkAccessManager(self.__proxy) |
181 |
183 |
182 self.__sslConfiguration = None |
184 self.__sslConfiguration = None |
183 self.__proxy.finished.connect(self.__managerFinished) |
185 self.__proxy.finished.connect(self.__managerFinished) |
|
186 |
|
187 self.__adBlockedEntries = [] |
|
188 self.loadStarted.connect(self.__loadStarted) |
184 |
189 |
185 def acceptNavigationRequest(self, frame, request, type_): |
190 def acceptNavigationRequest(self, frame, request, type_): |
186 """ |
191 """ |
187 Protected method to determine, if a request may be accepted. |
192 Protected method to determine, if a request may be accepted. |
188 |
193 |
359 errorPage.content = html |
364 errorPage.content = html |
360 return True |
365 return True |
361 |
366 |
362 return QWebPage.extension(self, extension, option, output) |
367 return QWebPage.extension(self, extension, option, output) |
363 |
368 |
|
369 def __loadStarted(self): |
|
370 """ |
|
371 Private method to handle the loadStarted signal. |
|
372 """ |
|
373 self.__adBlockedEntries = [] |
|
374 |
|
375 def addAdBlockRule(self, rule, url): |
|
376 """ |
|
377 Public slot to add an AdBlock rule to the page. |
|
378 |
|
379 @param rule AdBlock rule to add (AdBlockRule) |
|
380 @param url URL that matched the rule (QUrl) |
|
381 """ |
|
382 entry = AdBlockedPageEntry(rule, url) |
|
383 if entry not in self.__adBlockedEntries: |
|
384 self.__adBlockedEntries.append(entry) |
|
385 |
|
386 def getAdBlockedPageEntries(self): |
|
387 """ |
|
388 Public method to get the list of AdBlock page entries. |
|
389 |
|
390 @return list of AdBlock page entries (list of AdBlockedPageEntry) |
|
391 """ |
|
392 return self.__adBlockedEntries |
|
393 |
|
394 def url(self): |
|
395 """ |
|
396 Public method to get the URL of the page. |
|
397 |
|
398 @return URL of the page (QUrl) |
|
399 """ |
|
400 return self.mainFrame().url() |
|
401 |
364 def userAgent(self, resolveEmpty=False): |
402 def userAgent(self, resolveEmpty=False): |
365 """ |
403 """ |
366 Public method to get the global user agent setting. |
404 Public method to get the global user agent setting. |
367 |
405 |
368 @param resolveEmpty flag indicating to resolve an empty |
406 @param resolveEmpty flag indicating to resolve an empty |
1669 # this is a hack to make the ClickToFlash button appear |
1707 # this is a hack to make the ClickToFlash button appear |
1670 self.zoomIn() |
1708 self.zoomIn() |
1671 self.zoomOut() |
1709 self.zoomOut() |
1672 |
1710 |
1673 if ok: |
1711 if ok: |
1674 self.mw.adblockManager().page().applyRulesToPage(self.page()) |
1712 self.mw.adblockManager().page().hideBlockedPageEntries(self.page()) |
1675 self.mw.passwordManager().fill(self.page()) |
1713 self.mw.passwordManager().fill(self.page()) |
1676 |
1714 |
1677 def isLoading(self): |
1715 def isLoading(self): |
1678 """ |
1716 """ |
1679 Public method to get the loading state. |
1717 Public method to get the loading state. |