20import Lomiri.Components 1.3
21import Lomiri.Components.Popups 1.3
22import Lomiri.Components.ListItems 1.3 as ListItem
23import Lomiri.Content 1.3
24import QtQuick.Controls 2.1 as QQC2
26import Dekko.Components 1.0
27import Dekko.Mail.Settings 1.0
28import Dekko.Lomiri.Components 1.0
29import Dekko.Lomiri.Dialogs 1.0
30import Dekko.WebContext 1.0
31import QtQuick.Controls.Suru 2.2
36 property bool fullScreen: false
37 property int messageUid
38 readonly property alias contentBlocked: internal.remoteContentBlockRunning
39 property alias context: webview.profile
41 zoomFactor: units.gu(1) / 8
43 function setCidQuery(uid) {
47 function setBodyUrl(body) {
51 function allowBlockedContent() {
52 internal.remoteContentBlockRunning =
false
53 ctxt.remoteContentAllowed =
true;
64 javascriptEnabled:
false
65 javascriptCanAccessClipboard:
false
66 localContentCanAccessFileUrls:
false
68 localStorageEnabled:
false
69 hyperlinkAuditingEnabled:
false
70 defaultTextEncoding:
"UTF-8"
75 sourceUrl: Qt.resolvedUrl(
"./userscripts/font_user_script.js")
79 sourceUrl: Qt.resolvedUrl(
"./userscripts/viewport_shim.js")
87 readonly
property string defaultUserAgent: _ua.defaultUA
89 qmlEngineInjector: parent
91 httpUserAgent: defaultUserAgent
92 httpCacheMaximumSize: cacheSizeHint
93 cachePath: cacheLocation
94 persistentStoragePath: dataLocation
96 persistentCookiesPolicy: WebEngineProfile.NoPersistentCookies
98 messageUid: webview.messageUid
99 remoteContentAllowed: PolicyManager.privacy.allowRemoteContent
101 onRemoteContentBlocked: {
102 if (!internal.remoteContentBlockRunning) {
103 internal.remoteContentBlockRunning =
true
107 property QtObject _ua: QtObject {
111 readonly
property bool smallScreen: ctxt.screenDiagonal < 190
126 readonly
property string _template:
"Mozilla/5.0 (Linux; Ubuntu %1%2%3) AppleWebKit/%4 Chromium/%5 %6Safari/%7%8"
129 readonly
property string _ubuntuVersion:
"20.04"
131 readonly
property string _attributes: smallScreen ?
"like Android" :
""
133 readonly
property string _hardwareID:
""
136 readonly
property string _webkitVersion:
"537.36"
142 readonly
property string _chromiumVersion:
"35.0.1870.2"
144 readonly
property string _formFactor: smallScreen ?
"Mobile" :
""
146 readonly
property string _more:
""
148 property string defaultUA: {
150 ua = ua.arg(_ubuntuVersion)
151 ua = ua.arg((_attributes !==
"") ?
" %1".arg(_attributes) :
"")
152 ua = ua.arg((_hardwareID !==
"") ?
"; %1".arg(_hardwareID) :
"")
153 ua = ua.arg(_webkitVersion)
154 ua = ua.arg(_chromiumVersion)
155 ua = ua.arg((_formFactor !==
"") ?
"%1 ".arg(_formFactor) :
"")
156 ua = ua.arg(_webkitVersion)
157 ua = ua.arg((_more !==
"") ?
" %1".arg(_more) :
"")
170 onContextMenuRequested: {
171 request.accepted =
true
174 if (request.selectedText !==
"") {
175 contextMenuShape.contextContentText =
""
178 else if (request.linkText !==
"") {
179 contextMenuShape.contextContentText = request.linkUrl
182 if (openMenu && !contextMenuShape.visible) {
183 contextMenuShape.visible =
true
184 contextMenuShape.x = webview.x + units.gu(10)
185 contextMenuShape.y = webview.y + units.gu(10)
189 onNewViewRequested: {
190 if (request.userInitiated) {
191 console.log(
"[Dekko Web View] New View requested, requestedUrl", request.requestedUrl)
192 PopupUtils.open(linkClickedDialog, dekko, {externalLink: request.requestedUrl})
194 console.log(
"[Dekko Web View] Ignoring non-user initiated New View Request with requestedUrl", request.requestedUrl)
198 onNavigationRequested: {
199 console.log(
"[Dekko Web View] RequestUrl", request.url)
200 if ((
"" + request.url).startsWith(
"dekko-msg") ||
201 (
"" + request.url).startsWith(
"dekko-part") ||
202 (
"" + request.url).startsWith(
"cid")) {
206 PopupUtils.open(linkClickedDialog, dekko, {externalLink: request.url})
211 onJavaScriptConsoleMessage: {
212 var msg =
"[Dekko Web View] [JS] (%1:%2) %3".arg(sourceID).arg(lineNumber).arg(message)
217 id: contextualRectangle
219 readonly
property real locationBarOffset: (webview.locationBarController ? (webview.locationBarController.height + webview.locationBarController.offset) : 0)
220 x: internal.contextModel ? internal.contextModel.position.x : 0
221 y: internal.contextModel ? internal.contextModel.position.y + locationBarOffset : 0
226 property QtObject ctxtModel: null
227 property bool remoteContentBlockRunning: false
241 id: linkClickedDialog
244 property string externalLink
245 title: qsTr(
"Open in browser?")
246 text: qsTr(
"Confirm to open %1 in web browser").arg(externalLink.substring(0, 30))
247 onConfirmClicked: Qt.openUrlExternally(externalLink)