Wed, 17 Feb 2016 19:49:51 +0100
Continued porting the web browser.
- continued the passwords stuff
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
4631
5c1a96925da4
Updated copyright for 2016.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4612
diff
changeset
|
3 | # Copyright (c) 2008 - 2016 Detlev Offenbach <detlev@die-offenbachs.de> |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | Module implementing the helpbrowser using QWebView. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
10 | |
3145
a9de05d4a22f
# __IGNORE_WARNING__ added/ removed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3080
diff
changeset
|
11 | from __future__ import unicode_literals |
2525
8b507a9a2d40
Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
2432
diff
changeset
|
12 | try: |
4717
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
13 | str = unicode # __IGNORE_EXCEPTION__ |
3484 | 14 | except NameError: |
2525
8b507a9a2d40
Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
2432
diff
changeset
|
15 | pass |
8b507a9a2d40
Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
2432
diff
changeset
|
16 | |
3656
441956d8fce5
Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3636
diff
changeset
|
17 | from PyQt5.QtCore import pyqtSlot, pyqtSignal, QObject, QT_TRANSLATE_NOOP, \ |
3776
ccb6eacb50e5
Started adding code to make eric6 usable with PyQt5 and PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3747
diff
changeset
|
18 | QUrl, QBuffer, QIODevice, QFileInfo, Qt, QTimer, QEvent, \ |
4717
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
19 | QRect, QFile, QPoint, QByteArray, QEventLoop, qVersion |
3656
441956d8fce5
Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3636
diff
changeset
|
20 | from PyQt5.QtGui import QDesktopServices, QClipboard, QMouseEvent, QColor, \ |
441956d8fce5
Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3636
diff
changeset
|
21 | QPalette |
441956d8fce5
Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3636
diff
changeset
|
22 | from PyQt5.QtWidgets import qApp, QStyle, QMenu, QApplication, QInputDialog, \ |
441956d8fce5
Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3636
diff
changeset
|
23 | QLineEdit, QLabel, QToolTip, QFrame, QDialog |
441956d8fce5
Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3636
diff
changeset
|
24 | from PyQt5.QtPrintSupport import QPrinter, QPrintDialog |
4710
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
25 | from PyQt5.QtWebEngineWidgets import QWebEnginePage |
4717
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
26 | from PyQt5.QtWebChannel import QWebChannel |
3656
441956d8fce5
Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3636
diff
changeset
|
27 | from PyQt5.QtNetwork import QNetworkReply, QNetworkRequest |
260
21f7999b7abe
Fixed an issue causing the web browser not to show an error page due to a changed Qt API (>= 4.6; needs a patch to PyQt4).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
256
diff
changeset
|
28 | import sip |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
29 | |
1934
ad6b7c30fb9f
Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1823
diff
changeset
|
30 | from E5Gui import E5MessageBox, E5FileDialog |
537
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
535
diff
changeset
|
31 | |
4710
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
32 | import WebBrowser |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
33 | import WebBrowser.WebBrowserWindow |
4355
40ec6bef4c22
Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4353
diff
changeset
|
34 | |
4717
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
35 | from .JavaScript.ExternalJsObject import ExternalJsObject |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
36 | |
4728
0367675d783d
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4726
diff
changeset
|
37 | from .Tools.WebHitTestResult import WebHitTestResult |
4741
f9e1adc69076
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4728
diff
changeset
|
38 | from .Tools import Scripts |
4728
0367675d783d
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4726
diff
changeset
|
39 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
40 | import Preferences |
978
11f8adbcac97
Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
952
diff
changeset
|
41 | import UI.PixmapCache |
4241
545629046c45
Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4021
diff
changeset
|
42 | import Globals |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
43 | |
923
e224bdbf88ad
Fixed an issue related to the non-availability of SSL.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
826
diff
changeset
|
44 | try: |
3656
441956d8fce5
Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3636
diff
changeset
|
45 | from PyQt5.QtNetwork import QSslCertificate |
923
e224bdbf88ad
Fixed an issue related to the non-availability of SSL.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
826
diff
changeset
|
46 | SSL_AVAILABLE = True |
e224bdbf88ad
Fixed an issue related to the non-availability of SSL.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
826
diff
changeset
|
47 | except ImportError: |
e224bdbf88ad
Fixed an issue related to the non-availability of SSL.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
826
diff
changeset
|
48 | SSL_AVAILABLE = False |
1960
d8c45fe8a1b9
Reworked some of the AdBlock code to achieve some speed improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1953
diff
changeset
|
49 | |
2999
28c75409a78f
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2954
diff
changeset
|
50 | ############################################################################### |
4710
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
51 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
52 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
53 | ##class JavaScriptExternalObject(QObject): |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
54 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
55 | ## Class implementing an external javascript object to add search providers. |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
56 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
57 | ## def __init__(self, mw, parent=None): |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
58 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
59 | ## Constructor |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
60 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
61 | ## @param mw reference to the main window 8HelpWindow) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
62 | ## @param parent reference to the parent object (QObject) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
63 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
64 | ## super(JavaScriptExternalObject, self).__init__(parent) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
65 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
66 | ## self.__mw = mw |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
67 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
68 | ## @pyqtSlot(str) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
69 | ## def AddSearchProvider(self, url): |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
70 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
71 | ## Public slot to add a search provider. |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
72 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
73 | ## @param url url of the XML file defining the search provider (string) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
74 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
75 | ## self.__mw.openSearchManager().addEngine(QUrl(url)) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
76 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
77 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
78 | ##class LinkedResource(object): |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
79 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
80 | ## Class defining a data structure for linked resources. |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
81 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
82 | ## def __init__(self): |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
83 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
84 | ## Constructor |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
85 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
86 | ## self.rel = "" |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
87 | ## self.type_ = "" |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
88 | ## self.href = "" |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
89 | ## self.title = "" |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
90 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
91 | ############################################################################### |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
92 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
93 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
94 | ##class JavaScriptEricObject(QObject): |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
95 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
96 | ## Class implementing an external javascript object to search via the |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
97 | ## startpage. |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
98 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
99 | ## # these must be in line with the strings used by the javascript part of |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
100 | ## # the start page |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
101 | ## translations = [ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
102 | ## QT_TRANSLATE_NOOP("JavaScriptEricObject", |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
103 | ## "Welcome to eric6 Web Browser!"), |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
104 | ## QT_TRANSLATE_NOOP("JavaScriptEricObject", "eric6 Web Browser"), |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
105 | ## QT_TRANSLATE_NOOP("JavaScriptEricObject", "Search!"), |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
106 | ## QT_TRANSLATE_NOOP("JavaScriptEricObject", "About eric6"), |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
107 | ## ] |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
108 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
109 | ## def __init__(self, mw, parent=None): |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
110 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
111 | ## Constructor |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
112 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
113 | ## @param mw reference to the main window 8HelpWindow) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
114 | ## @param parent reference to the parent object (QObject) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
115 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
116 | ## super(JavaScriptEricObject, self).__init__(parent) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
117 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
118 | ## self.__mw = mw |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
119 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
120 | ## @pyqtSlot(str, result=str) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
121 | ## def translate(self, trans): |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
122 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
123 | ## Public method to translate the given string. |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
124 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
125 | ## @param trans string to be translated (string) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
126 | ## @return translation (string) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
127 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
128 | ## if trans == "QT_LAYOUT_DIRECTION": |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
129 | ## # special handling to detect layout direction |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
130 | ## if qApp.isLeftToRight(): |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
131 | ## return "LTR" |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
132 | ## else: |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
133 | ## return "RTL" |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
134 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
135 | ## return self.tr(trans) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
136 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
137 | ## @pyqtSlot(result=str) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
138 | ## def providerString(self): |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
139 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
140 | ## Public method to get a string for the search provider. |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
141 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
142 | ## @return string for the search provider (string) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
143 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
144 | ## return self.tr("Search results provided by {0}")\ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
145 | ## .format(self.__mw.openSearchManager().currentEngineName()) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
146 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
147 | ## @pyqtSlot(str, result=str) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
148 | ## def searchUrl(self, searchStr): |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
149 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
150 | ## Public method to get the search URL for the given search term. |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
151 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
152 | ## @param searchStr search term (string) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
153 | ## @return search URL (string) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
154 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
155 | ## return bytes( |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
156 | ## self.__mw.openSearchManager().currentEngine() |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
157 | ## .searchUrl(searchStr).toEncoded()).decode() |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
158 | ## |
2999
28c75409a78f
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2954
diff
changeset
|
159 | ############################################################################### |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
160 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
923
diff
changeset
|
161 | |
4710
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
162 | class WebBrowserPage(QWebEnginePage): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
163 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
164 | Class implementing an enhanced web page. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
165 | """ |
4710
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
166 | ## _webPluginFactory = None |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
167 | ## |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
923
diff
changeset
|
168 | def __init__(self, parent=None): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
169 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
170 | Constructor |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
171 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
172 | @param parent parent widget of this window (QWidget) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
173 | """ |
4710
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
174 | super(WebBrowserPage, self).__init__(parent) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
175 | |
4717
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
176 | self.setupWebChannel() |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
177 | |
4710
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
178 | ## self.setPluginFactory(self.webPluginFactory()) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
179 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
180 | ## self.__lastRequest = None |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
181 | ## self.__lastRequestType = QWebPage.NavigationTypeOther |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
182 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
183 | ## import Helpviewer.HelpWindow |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
184 | ## from .Network.NetworkAccessManagerProxy import \ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
185 | ## NetworkAccessManagerProxy |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
186 | ## self.__proxy = NetworkAccessManagerProxy(self) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
187 | ## self.__proxy.setWebPage(self) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
188 | ## self.__proxy.setPrimaryNetworkAccessManager( |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
189 | ## Helpviewer.HelpWindow.HelpWindow.networkAccessManager()) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
190 | ## self.setNetworkAccessManager(self.__proxy) |
4717
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
191 | |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
192 | self.__sslConfiguration = None |
4710
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
193 | ## self.__proxy.finished.connect(self.__managerFinished) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
194 | ## |
1960
d8c45fe8a1b9
Reworked some of the AdBlock code to achieve some speed improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1953
diff
changeset
|
195 | self.__adBlockedEntries = [] |
d8c45fe8a1b9
Reworked some of the AdBlock code to achieve some speed improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1953
diff
changeset
|
196 | self.loadStarted.connect(self.__loadStarted) |
4710
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
197 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
198 | ## self.saveFrameStateRequested.connect( |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
199 | ## self.__saveFrameStateRequested) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
200 | ## self.restoreFrameStateRequested.connect( |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
201 | ## self.__restoreFrameStateRequested) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
202 | self.featurePermissionRequested.connect( |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
203 | self.__featurePermissionRequested) |
4743
f9e2e536d130
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4742
diff
changeset
|
204 | |
f9e2e536d130
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4742
diff
changeset
|
205 | self.authenticationRequired.connect( |
f9e2e536d130
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4742
diff
changeset
|
206 | WebBrowser.WebBrowserWindow.WebBrowserWindow.networkManager() |
f9e2e536d130
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4742
diff
changeset
|
207 | .authentication) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
208 | |
4710
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
209 | def acceptNavigationRequest(self, url, type_, isMainFrame): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
210 | """ |
4726
c26e2a2dc0cb
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4725
diff
changeset
|
211 | Public method to determine, if a request may be accepted. |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
212 | |
4710
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
213 | @param url URL to navigate to |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
214 | @type QUrl |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
215 | @param type_ type of the navigation request |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
216 | @type QWebEnginePage.NavigationType |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
217 | @param isMainFrame flag indicating, that the request originated from |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
218 | the main frame |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
219 | @type bool |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
220 | @return flag indicating acceptance |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
221 | @rtype bool |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
222 | """ |
4710
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
223 | ## self.__lastRequest = request |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
224 | ## if self.__lastRequest.url() != request.url() or \ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
225 | ## type_ != QWebPage.NavigationTypeOther: |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
226 | ## self.__lastRequestType = type_ |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
227 | |
4710
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
228 | # TODO: Qt 5.6: move to handleUnknownProtocol |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
229 | scheme = url.scheme() |
757
d3daf1d8f058
Fixed the handling of 'javascript' schemes in the web browser and enhanced the download manager a bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
748
diff
changeset
|
230 | if scheme == "mailto": |
4710
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
231 | QDesktopServices.openUrl(url) |
757
d3daf1d8f058
Fixed the handling of 'javascript' schemes in the web browser and enhanced the download manager a bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
748
diff
changeset
|
232 | return False |
d3daf1d8f058
Fixed the handling of 'javascript' schemes in the web browser and enhanced the download manager a bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
748
diff
changeset
|
233 | |
4710
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
234 | # AdBlock |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
235 | if url.scheme() == "abp": |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
236 | if WebBrowser.WebBrowserWindow.WebBrowserWindow.adBlockManager()\ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
237 | .addSubscriptionFromUrl(url): |
675
2f626dcab902
Added check for a form resubmission to the web page class of the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
668
diff
changeset
|
238 | return False |
4710
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
239 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
240 | ## if type_ == QWebPage.NavigationTypeFormResubmitted: |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
241 | ## res = E5MessageBox.yesNo( |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
242 | ## self.view(), |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
243 | ## self.tr("Resending POST request"), |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
244 | ## self.tr( |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
245 | ## """In order to display the site, the request along with""" |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
246 | ## """ all the data must be sent once again, which may lead""" |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
247 | ## """ to some unexpected behaviour of the site e.g. the""" |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
248 | ## """ same action might be performed once again. Do you""" |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
249 | ## """ want to continue anyway?"""), |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
250 | ## icon=E5MessageBox.Warning) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
251 | ## if not res: |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
252 | ## return False |
1934
ad6b7c30fb9f
Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1823
diff
changeset
|
253 | |
4710
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
254 | return QWebEnginePage.acceptNavigationRequest(self, url, type_, |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
255 | isMainFrame) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
256 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
257 | ## def populateNetworkRequest(self, request): |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
258 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
259 | ## Public method to add data to a network request. |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
260 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
261 | ## @param request reference to the network request object |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
262 | ## (QNetworkRequest) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
263 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
264 | ## try: |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
265 | ## request.setAttribute(QNetworkRequest.User + 100, self) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
266 | ## if self.__lastRequest.url() == request.url(): |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
267 | ## request.setAttribute(QNetworkRequest.User + 101, |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
268 | ## self.__lastRequestType) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
269 | ## if self.__lastRequestType == \ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
270 | ## QWebPage.NavigationTypeLinkClicked: |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
271 | ## request.setRawHeader(b"X-Eric6-UserLoadAction", |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
272 | ## QByteArray(b"1")) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
273 | ## except TypeError: |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
274 | ## pass |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
275 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
276 | ## def pageAttributeId(self): |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
277 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
278 | ## Public method to get the attribute id of the page attribute. |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
279 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
280 | ## @return attribute id of the page attribute (integer) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
281 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
282 | ## return QNetworkRequest.User + 100 |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
283 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
284 | ## def supportsExtension(self, extension): |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
285 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
286 | ## Public method to check the support for an extension. |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
287 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
288 | ## @param extension extension to test for (QWebPage.Extension) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
289 | ## @return flag indicating the support of extension (boolean) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
290 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
291 | ## try: |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
292 | ## if extension in [QWebPage.ErrorPageExtension, |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
293 | ## QWebPage.ChooseMultipleFilesExtension]: |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
294 | ## return True |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
295 | ## except AttributeError: |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
296 | ## pass |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
297 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
298 | ## return QWebPage.supportsExtension(self, extension) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
299 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
300 | ## def extension(self, extension, option, output): |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
301 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
302 | ## Public method to implement a specific extension. |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
303 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
304 | ## @param extension extension to be executed (QWebPage.Extension) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
305 | ## @param option provides input to the extension |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
306 | ## (QWebPage.ExtensionOption) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
307 | ## @param output stores the output results (QWebPage.ExtensionReturn) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
308 | ## @return flag indicating a successful call of the extension (boolean) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
309 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
310 | ## if extension == QWebPage.ChooseMultipleFilesExtension: |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
311 | ## info = sip.cast(option, |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
312 | ## QWebPage.ChooseMultipleFilesExtensionOption) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
313 | ## files = sip.cast(output, |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
314 | ## QWebPage.ChooseMultipleFilesExtensionReturn) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
315 | ## if info is None or files is None: |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
316 | ## return super(HelpWebPage, self).extension( |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
317 | ## extension, option, output) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
318 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
319 | ## suggestedFileName = "" |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
320 | ## if info.suggestedFileNames: |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
321 | ## suggestedFileName = info.suggestedFileNames[0] |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
322 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
323 | ## files.fileNames = E5FileDialog.getOpenFileNames( |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
324 | ## None, |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
325 | ## self.tr("Select files to upload..."), |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
326 | ## suggestedFileName) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
327 | ## return True |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
328 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
329 | ## if extension == QWebPage.ErrorPageExtension: |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
330 | ## info = sip.cast(option, QWebPage.ErrorPageExtensionOption) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
331 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
332 | ## errorPage = sip.cast(output, QWebPage.ErrorPageExtensionReturn) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
333 | ## urlString = bytes(info.url.toEncoded()).decode() |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
334 | ## errorPage.baseUrl = info.url |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
335 | ## if info.domain == QWebPage.QtNetwork and \ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
336 | ## info.error == QNetworkReply.ProtocolUnknownError: |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
337 | ## url = QUrl(info.url) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
338 | ## res = E5MessageBox.yesNo( |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
339 | ## None, |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
340 | ## self.tr("Protocol Error"), |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
341 | ## self.tr("""Open external application for {0}-link?\n""" |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
342 | ## """URL: {1}""").format( |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
343 | ## url.scheme(), url.toString( |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
344 | ## QUrl.PrettyDecoded | QUrl.RemovePassword)), |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
345 | ## yesDefault=True) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
346 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
347 | ## if res: |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
348 | ## QDesktopServices.openUrl(url) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
349 | ## return True |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
350 | ## elif info.domain == QWebPage.QtNetwork and \ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
351 | ## info.error == QNetworkReply.ContentAccessDenied and \ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
352 | ## info.errorString.startswith("AdBlockRule:"): |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
353 | ## if info.frame != info.frame.page().mainFrame(): |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
354 | ## # content in <iframe> |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
355 | ## docElement = info.frame.page().mainFrame()\ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
356 | ## .documentElement() |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
357 | ## for element in docElement.findAll("iframe"): |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
358 | ## src = element.attribute("src") |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
359 | ## if src in info.url.toString(): |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
360 | ## element.setAttribute("style", "display:none;") |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
361 | ## return False |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
362 | ## else: |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
363 | ## # the whole page is blocked |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
364 | ## rule = info.errorString.replace("AdBlockRule:", "") |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
365 | ## title = self.tr("Content blocked by AdBlock Plus") |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
366 | ## message = self.tr( |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
367 | ## "Blocked by rule: <i>{0}</i>").format(rule) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
368 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
369 | ## htmlFile = QFile(":/html/adblockPage.html") |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
370 | ## htmlFile.open(QFile.ReadOnly) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
371 | ## html = htmlFile.readAll() |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
372 | ## html = html.replace( |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
373 | ## "@FAVICON@", "qrc:icons/adBlockPlus16.png") |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
374 | ## html = html.replace( |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
375 | ## "@IMAGE@", "qrc:icons/adBlockPlus64.png") |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
376 | ## html = html.replace("@TITLE@", title.encode("utf8")) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
377 | ## html = html.replace("@MESSAGE@", message.encode("utf8")) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
378 | ## errorPage.content = html |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
379 | ## return True |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
380 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
381 | ## if info.domain == QWebPage.QtNetwork and \ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
382 | ## info.error == QNetworkReply.OperationCanceledError and \ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
383 | ## info.errorString == "eric6:No Error": |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
384 | ## return False |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
385 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
386 | ## if info.domain == QWebPage.WebKit and info.error == 203: |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
387 | ## # "Loading is handled by the media engine" |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
388 | ## return False |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
389 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
390 | ## title = self.tr("Error loading page: {0}").format(urlString) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
391 | ## htmlFile = QFile(":/html/notFoundPage.html") |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
392 | ## htmlFile.open(QFile.ReadOnly) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
393 | ## html = htmlFile.readAll() |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
394 | ## pixmap = qApp.style()\ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
395 | ## .standardIcon(QStyle.SP_MessageBoxWarning).pixmap(48, 48) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
396 | ## imageBuffer = QBuffer() |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
397 | ## imageBuffer.open(QIODevice.ReadWrite) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
398 | ## if pixmap.save(imageBuffer, "PNG"): |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
399 | ## html = html.replace("@IMAGE@", imageBuffer.buffer().toBase64()) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
400 | ## pixmap = qApp.style()\ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
401 | ## .standardIcon(QStyle.SP_MessageBoxWarning).pixmap(16, 16) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
402 | ## imageBuffer = QBuffer() |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
403 | ## imageBuffer.open(QIODevice.ReadWrite) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
404 | ## if pixmap.save(imageBuffer, "PNG"): |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
405 | ## html = html.replace( |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
406 | ## "@FAVICON@", imageBuffer.buffer().toBase64()) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
407 | ## html = html.replace("@TITLE@", title.encode("utf8")) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
408 | ## html = html.replace("@H1@", info.errorString.encode("utf8")) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
409 | ## html = html.replace( |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
410 | ## "@H2@", self.tr("When connecting to: {0}.") |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
411 | ## .format(urlString).encode("utf8")) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
412 | ## html = html.replace( |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
413 | ## "@LI-1@", |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
414 | ## self.tr("Check the address for errors such as " |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
415 | ## "<b>ww</b>.example.org instead of " |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
416 | ## "<b>www</b>.example.org").encode("utf8")) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
417 | ## html = html.replace( |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
418 | ## "@LI-2@", |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
419 | ## self.tr( |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
420 | ## "If the address is correct, try checking the network " |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
421 | ## "connection.").encode("utf8")) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
422 | ## html = html.replace( |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
423 | ## "@LI-3@", |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
424 | ## self.tr( |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
425 | ## "If your computer or network is protected by a firewall " |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
426 | ## "or proxy, make sure that the browser is permitted to " |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
427 | ## "access the network.").encode("utf8")) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
428 | ## html = html.replace( |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
429 | ## "@LI-4@", |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
430 | ## self.tr("If your cache policy is set to offline browsing," |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
431 | ## "only pages in the local cache are available.") |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
432 | ## .encode("utf8")) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
433 | ## html = html.replace( |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
434 | ## "@BUTTON@", self.tr("Try Again").encode("utf8")) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
435 | ## errorPage.content = html |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
436 | ## return True |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
437 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
438 | ## return QWebPage.extension(self, extension, option, output) |
383
286de4e5179c
Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
381
diff
changeset
|
439 | |
1960
d8c45fe8a1b9
Reworked some of the AdBlock code to achieve some speed improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1953
diff
changeset
|
440 | def __loadStarted(self): |
d8c45fe8a1b9
Reworked some of the AdBlock code to achieve some speed improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1953
diff
changeset
|
441 | """ |
4741
f9e1adc69076
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4728
diff
changeset
|
442 | Private slot to handle the loadStarted signal. |
1960
d8c45fe8a1b9
Reworked some of the AdBlock code to achieve some speed improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1953
diff
changeset
|
443 | """ |
d8c45fe8a1b9
Reworked some of the AdBlock code to achieve some speed improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1953
diff
changeset
|
444 | self.__adBlockedEntries = [] |
4710
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
445 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
446 | ## def addAdBlockRule(self, rule, url): |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
447 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
448 | ## Public slot to add an AdBlock rule to the page. |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
449 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
450 | ## @param rule AdBlock rule to add (AdBlockRule) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
451 | ## @param url URL that matched the rule (QUrl) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
452 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
453 | ## from .AdBlock.AdBlockPage import AdBlockedPageEntry |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
454 | ## entry = AdBlockedPageEntry(rule, url) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
455 | ## if entry not in self.__adBlockedEntries: |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
456 | ## self.__adBlockedEntries.append(entry) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
457 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
458 | ## def getAdBlockedPageEntries(self): |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
459 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
460 | ## Public method to get the list of AdBlock page entries. |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
461 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
462 | ## @return list of AdBlock page entries (list of AdBlockedPageEntry) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
463 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
464 | ## return self.__adBlockedEntries |
487
4d41d03d3d00
Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
383
diff
changeset
|
465 | |
4715
79009bc4acd5
Continued getting the basic web browser functions going.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4710
diff
changeset
|
466 | # TODO: User Agent Manager |
4710
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
467 | ## def userAgent(self, resolveEmpty=False): |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
468 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
469 | ## Public method to get the global user agent setting. |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
470 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
471 | ## @param resolveEmpty flag indicating to resolve an empty |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
472 | ## user agent (boolean) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
473 | ## @return user agent string (string) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
474 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
475 | ## agent = Preferences.getWebBrowser("UserAgent") |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
476 | ## if agent == "" and resolveEmpty: |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
477 | ## agent = self.userAgentForUrl(QUrl()) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
478 | ## return agent |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
479 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
480 | ## def setUserAgent(self, agent): |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
481 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
482 | ## Public method to set the global user agent string. |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
483 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
484 | ## @param agent new current user agent string (string) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
485 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
486 | ## Preferences.setHelp("UserAgent", agent) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
487 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
488 | ## def userAgentForUrl(self, url): |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
489 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
490 | ## Public method to determine the user agent for the given URL. |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
491 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
492 | ## @param url URL to determine user agent for (QUrl) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
493 | ## @return user agent string (string) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
494 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
495 | ## import Helpviewer.HelpWindow |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
496 | ## agent = Helpviewer.HelpWindow.HelpWindow.userAgentsManager()\ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
497 | ## .userAgentForUrl(url) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
498 | ## if agent == "": |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
499 | ## # no agent string specified for the given host -> use global one |
4726
c26e2a2dc0cb
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4725
diff
changeset
|
500 | ## agent = Preferences.getWebBrowser("UserAgent") |
4710
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
501 | ## if agent == "": |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
502 | ## # no global agent string specified -> use default one |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
503 | ## agent = QWebPage.userAgentForUrl(self, url) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
504 | ## return agent |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
505 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
506 | ## def __managerFinished(self, reply): |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
507 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
508 | ## Private slot to handle a finished reply. |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
509 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
510 | ## This slot is used to get SSL related information for a reply. |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
511 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
512 | ## @param reply reference to the finished reply (QNetworkReply) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
513 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
514 | ## try: |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
515 | ## frame = reply.request().originatingObject() |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
516 | ## except AttributeError: |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
517 | ## frame = None |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
518 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
519 | ## mainFrameRequest = frame == self.mainFrame() |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
520 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
521 | ## if mainFrameRequest and \ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
522 | ## self.__sslConfiguration is not None and \ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
523 | ## reply.url() == self.mainFrame().url(): |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
524 | ## self.__sslConfiguration = None |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
525 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
526 | ## if reply.error() == QNetworkReply.NoError and \ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
527 | ## mainFrameRequest and \ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
528 | ## self.__sslConfiguration is None and \ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
529 | ## reply.url().scheme().lower() == "https" and \ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
530 | ## reply.url() == self.mainFrame().url(): |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
531 | ## self.__sslConfiguration = reply.sslConfiguration() |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
532 | ## self.__sslConfiguration.url = QUrl(reply.url()) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
533 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
534 | ## if reply.error() == QNetworkReply.NoError and \ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
535 | ## mainFrameRequest and \ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
536 | ## reply.url() == self.mainFrame().url(): |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
537 | ## modified = reply.header(QNetworkRequest.LastModifiedHeader) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
538 | ## if modified and modified.isValid(): |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
539 | ## import Helpviewer.HelpWindow |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
540 | ## manager = Helpviewer.HelpWindow.HelpWindow.bookmarksManager() |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
541 | ## from .Bookmarks.BookmarkNode import BookmarkNode |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
542 | ## for bookmark in manager.bookmarksForUrl(reply.url()): |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
543 | ## manager.setTimestamp(bookmark, BookmarkNode.TsModified, |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
544 | ## modified) |
1934
ad6b7c30fb9f
Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1823
diff
changeset
|
545 | |
4710
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
546 | ## def getSslCertificate(self): |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
547 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
548 | ## Public method to get a reference to the SSL certificate. |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
549 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
550 | ## @return amended SSL certificate (QSslCertificate) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
551 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
552 | ## if self.__sslConfiguration is None: |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
553 | ## return None |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
554 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
555 | ## sslInfo = self.__sslConfiguration.peerCertificate() |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
556 | ## sslInfo.url = QUrl(self.__sslConfiguration.url) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
557 | ## return sslInfo |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
558 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
559 | ## def getSslCertificateChain(self): |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
560 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
561 | ## Public method to get a reference to the SSL certificate chain. |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
562 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
563 | ## @return SSL certificate chain (list of QSslCertificate) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
564 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
565 | ## if self.__sslConfiguration is None: |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
566 | ## return [] |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
567 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
568 | ## chain = self.__sslConfiguration.peerCertificateChain() |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
569 | ## return chain |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
570 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
571 | ## def getSslConfiguration(self): |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
572 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
573 | ## Public method to return a reference to the current SSL configuration. |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
574 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
575 | ## @return reference to the SSL configuration in use (QSslConfiguration) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
576 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
577 | ## return self.__sslConfiguration |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
578 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
579 | ## def showSslInfo(self, pos): |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
580 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
581 | ## Public slot to show some SSL information for the loaded page. |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
582 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
583 | ## @param pos position to show the info at (QPoint) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
584 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
585 | ## if SSL_AVAILABLE and self.__sslConfiguration is not None: |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
586 | ## from E5Network.E5SslInfoWidget import E5SslInfoWidget |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
587 | ## widget = E5SslInfoWidget( |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
588 | ## self.mainFrame().url(), self.__sslConfiguration, self.view()) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
589 | ## widget.showAt(pos) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
590 | ## else: |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
591 | ## E5MessageBox.warning( |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
592 | ## self.view(), |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
593 | ## self.tr("SSL Info"), |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
594 | ## self.tr("""This site does not contain SSL information.""")) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
595 | ## |
4717
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
596 | def hasValidSslInfo(self): |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
597 | """ |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
598 | Public method to check, if the page has a valid SSL certificate. |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
599 | |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
600 | @return flag indicating a valid SSL certificate (boolean) |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
601 | """ |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
602 | if self.__sslConfiguration is None: |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
603 | return False |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
604 | |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
605 | certList = self.__sslConfiguration.peerCertificateChain() |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
606 | if not certList: |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
607 | return False |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
608 | |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
609 | certificateDict = Globals.toDict( |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
610 | Preferences.Prefs.settings.value("Ssl/CaCertificatesDict")) |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
611 | for server in certificateDict: |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
612 | localCAList = QSslCertificate.fromData(certificateDict[server]) |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
613 | for cert in certList: |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
614 | if cert in localCAList: |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
615 | return True |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
616 | |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
617 | for cert in certList: |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
618 | if cert.isBlacklisted(): |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
619 | return False |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
620 | |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
621 | return True |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
622 | |
4710
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
623 | ## @classmethod |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
624 | ## def webPluginFactory(cls): |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
625 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
626 | ## Class method to get a reference to the web plug-in factory |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
627 | ## instance. |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
628 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
629 | ## @return reference to the web plug-in factory instance (WebPluginFactory |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
630 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
631 | ## if cls._webPluginFactory is None: |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
632 | ## from .WebPlugins.WebPluginFactory import WebPluginFactory |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
633 | ## cls._webPluginFactory = WebPluginFactory() |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
634 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
635 | ## return cls._webPluginFactory |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
636 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
637 | ## def event(self, evt): |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
638 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
639 | ## Public method implementing the event handler. |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
640 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
641 | ## @param evt reference to the event (QEvent) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
642 | ## @return flag indicating that the event was handled (boolean) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
643 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
644 | ## if evt.type() == QEvent.Leave: |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
645 | ## # Fake a mouse move event just outside of the widget to trigger |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
646 | ## # the WebKit event handler's mouseMoved function. This implements |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
647 | ## # the interesting mouse-out behavior like invalidating scrollbars. |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
648 | ## fakeEvent = QMouseEvent(QEvent.MouseMove, QPoint(0, -1), |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
649 | ## Qt.NoButton, Qt.NoButton, Qt.NoModifier) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
650 | ## return super(HelpWebPage, self).event(fakeEvent) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
651 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
652 | ## return super(HelpWebPage, self).event(evt) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
653 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
654 | ## def __saveFrameStateRequested(self, frame, itm): |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
655 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
656 | ## Private slot to save the page state (i.e. zoom level and scroll |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
657 | ## position). |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
658 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
659 | ## Note: Code is based on qutebrowser. |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
660 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
661 | ## @param frame frame to be saved |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
662 | ## @type QWebFrame |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
663 | ## @param itm web history item to be saved |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
664 | ## @type QWebHistoryItem |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
665 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
666 | ## try: |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
667 | ## if frame != self.mainFrame(): |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
668 | ## return |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
669 | ## except RuntimeError: |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
670 | ## # With Qt 5.2.1 (Ubuntu Trusty) we get this when closing a tab: |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
671 | ## # RuntimeError: wrapped C/C++ object of type BrowserPage has |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
672 | ## # been deleted |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
673 | ## # Since the information here isn't that important for closing web |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
674 | ## # views anyways, we ignore this error. |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
675 | ## return |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
676 | ## data = { |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
677 | ## 'zoom': frame.zoomFactor(), |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
678 | ## 'scrollPos': frame.scrollPosition(), |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
679 | ## } |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
680 | ## itm.setUserData(data) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
681 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
682 | ## def __restoreFrameStateRequested(self, frame): |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
683 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
684 | ## Private slot to restore scroll position and zoom level from |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
685 | ## history. |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
686 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
687 | ## Note: Code is based on qutebrowser. |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
688 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
689 | ## @param frame frame to be restored |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
690 | ## @type QWebFrame |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
691 | ## """ |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
692 | ## if frame != self.mainFrame(): |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
693 | ## return |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
694 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
695 | ## data = self.history().currentItem().userData() |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
696 | ## if data is None: |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
697 | ## return |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
698 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
699 | ## if 'zoom' in data: |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
700 | ## frame.page().view().setZoomValue(int(data['zoom'] * 100), |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
701 | ## saveValue=False) |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
702 | ## |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
703 | ## if 'scrollPos' in data and frame.scrollPosition() == QPoint(0, 0): |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
704 | ## frame.setScrollPosition(data['scrollPos']) |
1518
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
705 | |
4710
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
706 | def __featurePermissionRequested(self, url, feature): |
4316
493891cbacee
Added support for feature permissions to the eric web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4275
diff
changeset
|
707 | """ |
493891cbacee
Added support for feature permissions to the eric web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4275
diff
changeset
|
708 | Private slot handling a feature permission request. |
493891cbacee
Added support for feature permissions to the eric web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4275
diff
changeset
|
709 | |
4710
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
710 | @param url url requesting the feature |
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
711 | @type QUrl |
4316
493891cbacee
Added support for feature permissions to the eric web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4275
diff
changeset
|
712 | @param feature requested feature |
4710
370a38e03efe
Started with the web browser page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
713 | @type QWebEnginePage.Feature |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
714 | """ |
4742
f9d1090f6ab9
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4741
diff
changeset
|
715 | manager = WebBrowser.WebBrowserWindow.WebBrowserWindow\ |
f9d1090f6ab9
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4741
diff
changeset
|
716 | .featurePermissionManager() |
f9d1090f6ab9
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4741
diff
changeset
|
717 | manager.requestFeaturePermission(self, url, feature) |
4717
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
718 | |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
719 | def execJavaScript(self, script): |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
720 | """ |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
721 | Public method to execute a JavaScript function synchroneously. |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
722 | |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
723 | @param script JavaScript script source to be executed |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
724 | @type str |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
725 | @return result of the script |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
726 | @rtype depending upon script result |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
727 | """ |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
728 | loop = QEventLoop() |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
729 | resultDict = {"res": None} |
4728
0367675d783d
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4726
diff
changeset
|
730 | QTimer.singleShot(500, loop.quit); |
4717
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
731 | |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
732 | def resultCallback(res, resDict=resultDict): |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
733 | if loop and loop.isRunning(): |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
734 | resDict["res"] = res |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
735 | loop.quit() |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
736 | |
4728
0367675d783d
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4726
diff
changeset
|
737 | self.runJavaScript(script, resultCallback) |
4717
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
738 | |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
739 | loop.exec_() |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
740 | return resultDict["res"] |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
741 | |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
742 | def scroll(self, x, y): |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
743 | """ |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
744 | Public method to scroll by the given amount of pixels. |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
745 | |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
746 | @param x horizontal scroll value |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
747 | @type int |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
748 | @param y vertical scroll value |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
749 | @type int |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
750 | """ |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
751 | self.runJavaScript( |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
752 | "window.scrollTo(window.scrollX + {0}, window.scrollY + {1})" |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
753 | .format(x, y) |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
754 | ) |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
755 | |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
756 | def hitTestContent(self, pos): |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
757 | """ |
4728
0367675d783d
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4726
diff
changeset
|
758 | Public method to test the content at a specified position. |
4717
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
759 | |
4728
0367675d783d
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4726
diff
changeset
|
760 | @param pos position to execute the test at |
4717
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
761 | @type QPoint |
4728
0367675d783d
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4726
diff
changeset
|
762 | @return test result object |
0367675d783d
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4726
diff
changeset
|
763 | @rtype WebHitTestResult |
4717
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
764 | """ |
4728
0367675d783d
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4726
diff
changeset
|
765 | return WebHitTestResult(self, pos) |
4717
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
766 | |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
767 | def setupWebChannel(self): |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
768 | """ |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
769 | Public method to setup a web channel to our external object. |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
770 | """ |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
771 | oldChannel = self.webChannel() |
4744
ad3f6c1caf8d
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4743
diff
changeset
|
772 | newChannel = QWebChannel(self) |
4717
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
773 | newChannel.registerObject("eric_object", ExternalJsObject(self)) |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
774 | self.setWebChannel(newChannel) |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
775 | |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
776 | if oldChannel: |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
777 | del oldChannel.registeredObjects["eric_object"] |
5841f229baf7
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4715
diff
changeset
|
778 | del oldChannel |
4725
b19ff70ba509
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4717
diff
changeset
|
779 | |
b19ff70ba509
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4717
diff
changeset
|
780 | def certificateError(self, error): |
b19ff70ba509
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4717
diff
changeset
|
781 | """ |
4726
c26e2a2dc0cb
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4725
diff
changeset
|
782 | Public method to handle SSL certificate errors. |
4725
b19ff70ba509
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4717
diff
changeset
|
783 | |
b19ff70ba509
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4717
diff
changeset
|
784 | @param error object containing the certificate error information |
b19ff70ba509
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4717
diff
changeset
|
785 | @type QWebEngineCertificateError |
b19ff70ba509
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4717
diff
changeset
|
786 | @return flag indicating to ignore this error |
b19ff70ba509
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4717
diff
changeset
|
787 | @rtype bool |
b19ff70ba509
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4717
diff
changeset
|
788 | """ |
b19ff70ba509
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4717
diff
changeset
|
789 | return WebBrowser.WebBrowserWindow.WebBrowserWindow.networkManager()\ |
b19ff70ba509
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4717
diff
changeset
|
790 | .certificateError(error, self.view()) |