/usr/share/webbrowser-app/webcontainer/webapp-container.qml is in webapp-container 0.23+16.04.20160413-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 | /*
* Copyright 2013-2016 Canonical Ltd.
*
* This file is part of webbrowser-app.
*
* webbrowser-app is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* webbrowser-app is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.4
import Ubuntu.Components 1.3
import Ubuntu.UnityWebApps 0.1 as UnityWebApps
import Ubuntu.Web 0.2
import webcontainer.private 0.1
import ".."
BrowserWindow {
id: root
objectName: "webappContainer"
property bool backForwardButtonsVisible: true
property bool chromeVisible: true
property string localCookieStoreDbPath: ""
property string url: ""
property url webappIcon: ""
property string webappName: ""
property string webappModelSearchPath: ""
property var webappUrlPatterns
property string accountProvider: ""
property bool accountSwitcher: false
property string popupRedirectionUrlPrefixPattern: ""
property url webviewOverrideFile: ""
property var __webappCookieStore: null
property alias webContextSessionCookieMode: webappViewLoader.webContextSessionCookieMode
property string localUserAgentOverride: ""
property bool blockOpenExternalUrls: false
property bool openExternalUrlInOverlay: false
currentWebview: webappViewLoader.item ? webappViewLoader.item.currentWebview : null
property bool runningLocalApplication: false
title: getWindowTitle()
// Used for testing
signal schemeUriHandleFilterResult(string uri)
function getWindowTitle() {
var webappViewTitle =
webappViewLoader.item
? webappViewLoader.item.title : ""
var name = getWebappName()
if (typeof(name) === 'string' && name.length !== 0) {
return name
} else if (webappViewTitle) {
// TRANSLATORS: %1 refers to the current page’s title
return i18n.tr("%1 - Ubuntu Web Browser").arg(webappViewTitle)
} else {
return i18n.tr("Ubuntu Web Browser")
}
}
Component {
id: webappViewComponent
WebApp {
id: browser
url: accountProvider.length !== 0 ? "" : root.url
accountSwitcher: root.accountSwitcher
dataPath: webappDataLocation
chromeVisible: root.chromeVisible
backForwardButtonsVisible: root.backForwardButtonsVisible
developerExtrasEnabled: root.developerExtrasEnabled
webappModelSearchPath: root.webappModelSearchPath
webappUrlPatterns: root.webappUrlPatterns
blockOpenExternalUrls: root.blockOpenExternalUrls
openExternalUrlInOverlay: root.openExternalUrlInOverlay
popupRedirectionUrlPrefixPattern: root.popupRedirectionUrlPrefixPattern
localUserAgentOverride: getLocalUserAgentOverrideIfAny()
runningLocalApplication: root.runningLocalApplication
webviewOverrideFile: root.webviewOverrideFile
anchors.fill: parent
webbrowserWindow: webbrowserWindowProxy
onWebappNameChanged: {
if (root.webappName !== browser.webappName) {
root.webappName = browser.webappName;
root.title = getWindowTitle();
}
}
onChooseAccount: {
showAccountsPage()
onlineAccountsController.showAccountSwitcher()
}
}
}
function getWebappName() {
/**
Any webapp name coming from the command line takes over.
A webapp can also be defined by a specific drop-in webapp-properties.json
file that can bundle a few specific 'properties' (as the name implies)
instead of having them listed in the command line.
*/
if (webappName)
return webappName
return webappModelSearchPath && webappModel.providesSingleInlineWebapp()
? webappModel.getSingleInlineWebappName()
: ""
}
function getLocalUserAgentOverrideIfAny() {
if (localUserAgentOverride.length !== 0)
return localUserAgentOverride
var name = getWebappName()
if (name && webappModel.exists(name))
return webappModel.userAgentOverrideFor(name)
return ""
}
UnityWebApps.UnityWebappsAppModel {
id: webappModel
searchPath: root.webappModelSearchPath
onModelContentChanged: {
var name = getWebappName()
if (name && root.url.length === 0) {
var idx = webappModel.getWebappIndex(name)
root.url = webappModel.data(
idx, UnityWebApps.UnityWebappsAppModel.Homepage)
}
}
}
// Because of https://launchpad.net/bugs/1398046, it's important that this
// is the first child
Loader {
id: webappViewLoader
anchors.fill: parent
property var webContextSessionCookieMode: ""
property var webappDataLocation
onLoaded: {
var context = item.currentWebview.context
onlineAccountsController.setupWebcontextForAccount(context)
}
}
OnlineAccountsController {
id: onlineAccountsController
anchors.fill: parent
z: -1 // This is needed to have the dialogs shown; see above comment about bug 1398046
providerId: accountProvider
applicationId: unversionedAppId
accountSwitcher: root.accountSwitcher
webappName: getWebappName()
webappIcon: root.webappIcon
onAccountSelected: {
var newWebappDataLocation = dataLocation + accountDataLocation
console.log("Loading webview on " + newWebappDataLocation)
if (newWebappDataLocation == webappViewLoader.webappDataLocation) {
showWebView()
return
}
webappViewLoader.sourceComponent = null
webappViewLoader.webappDataLocation = newWebappDataLocation
// If we need to preserve session cookies, make sure that the
// mode is "restored" and not "persistent", or the cookies
// transferred from OA would be lost.
// We check if the webContextSessionCookieMode is defined and, if so,
// we override it in the webapp loader.
if (willMoveCookies && typeof webContextSessionCookieMode === "string") {
webappViewLoader.webContextSessionCookieMode = "restored"
}
webappViewLoader.sourceComponent = webappViewComponent
}
onContextReady: startBrowsing()
onQuitRequested: Qt.quit()
}
Component.onCompleted: {
i18n.domain = "webbrowser-app"
}
function showWebView() {
onlineAccountsController.visible = false
webappViewLoader.visible = true
}
function showAccountsPage() {
webappViewLoader.visible = false
onlineAccountsController.visible = true
}
function startBrowsing() {
console.log("Start browsing")
// This will activate the UnityWebApp element used in WebApp.qml
webappViewLoader.item.webappName = root.webappName
// As we use StateSaver to restore the URL, we need to check first if
// it has not been set previously before setting the URL to the default property
// homepage.
var webView = webappViewLoader.item.currentWebview
var current_url = webView.url.toString();
if (!current_url || current_url.length === 0) {
webView.url = root.url
}
showWebView()
}
function makeUrlFromResult(result) {
var scheme = null
var hostname = null
var url = root.currentWebview.url || root.url
if (result.host
&& result.host.length !== 0) {
hostname = result.host
}
else {
var matchHostname = url.toString().match(/.*:\/\/([^/]*)\/.*/)
if (matchHostname.length > 1) {
hostname = matchHostname[1]
}
}
if (result.scheme
&& result.scheme.length !== 0) {
scheme = result.scheme
}
else {
var matchScheme = url.toString().match(/(.*):\/\/[^/]*\/.*/)
if (matchScheme.length > 1) {
scheme = matchScheme[1]
}
}
return scheme
+ '://'
+ hostname
+ "/"
+ (result.path
? result.path : "")
}
/**
*
*/
function translateHandlerUri(uri) {
//
var scheme = uri.substr(0, uri.indexOf(":"))
if (scheme.indexOf("http") === 0) {
schemeUriHandleFilterResult(uri)
return uri
}
var result = webappSchemeFilter.applyFilter(uri)
var mapped_uri = makeUrlFromResult(result)
uri = mapped_uri
// Report the result of the intent uri filtering (if any)
// Done for testing purposed. It is not possible at this point
// to have AP call a slot and retrieve its result synchronously.
schemeUriHandleFilterResult(uri)
return uri
}
onOpenUrls: {
// only consider the first one (if multiple)
if (urls.length === 0 || !root.currentWebview) {
return;
}
var requestedUrl = urls[0].toString();
if (popupRedirectionUrlPrefixPattern.length !== 0
&& requestedUrl.match(popupRedirectionUrlPrefixPattern)) {
return;
}
requestedUrl = translateHandlerUri(requestedUrl);
// Add a small guard to prevent browsing to invalid urls
if (currentWebview
&& currentWebview.shouldAllowNavigationTo
&& !currentWebview.shouldAllowNavigationTo(requestedUrl)) {
return;
}
root.url = requestedUrl
root.currentWebview.url = requestedUrl
}
}
|