This file is indexed.

/usr/share/webbrowser-app/webcontainer/PopupWindowController.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
/*
 * Copyright 2014-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 com.canonical.Oxide 1.0 as Oxide
import Ubuntu.Components 1.3
import Ubuntu.Components.Popups 1.3
import Qt.labs.settings 1.0

Item {
    id: controller

    property var webappUrlPatterns
    property var mainWebappView
    property var views: []
    property bool blockOpenExternalUrls: false
    property var mediaAccessDialogComponent
    property bool wide: false

    // Used to access runtime behavior during tests
    signal openExternalUrlTriggered(string url)
    signal newViewCreated(string url)
    signal windowOverlayOpenAnimationDone()

    signal initializeOverlayViewsWithUrls(var urls)

    readonly property int maxSimultaneousViews: 3

    Settings {
        id: webviewOverlayUrlsSettings
        property string overlayUrls
    }

    QtObject {
        id: internal
        property var urlPerOverlayView
    }

    function updateOverlayUrlsSettings() {
        var urls = []
        webviewOverlayUrlsSettings.overlayUrls = "[]"
        for (var i in internal.urlPerOverlayView) {
            urls.push(internal.urlPerOverlayView[i].toString())
        }
        webviewOverlayUrlsSettings.overlayUrls = JSON.stringify(urls)
    }
    function onUrlUpdatedForOverlay(overlayView, url) {
        if (!internal.urlPerOverlayView) {
            internal.urlPerOverlayView = {}
        }

        internal.urlPerOverlayView[overlayView] = url

        updateOverlayUrlsSettings()
    }

    Connections {
        target: Qt.application
        onAboutToQuit: {
            webviewOverlayUrlsSettings.overlayUrls = "[]"
        }
    }

    Component.onCompleted: {
        if (webviewOverlayUrlsSettings.overlayUrls
                && webviewOverlayUrlsSettings.overlayUrls.length > 0) {
            try {
                var urls = JSON.parse(webviewOverlayUrlsSettings.overlayUrls)
                if (typeof(urls) === 'object'
                        && urls.length != undefined
                        && urls.length > 0) {
                    initializeOverlayViewsWithUrls(urls)
                }
            } catch (e) {}
        }
    }

    function openUrlExternally(url) {
        if (!blockOpenExternalUrls) {
            Qt.openUrlExternally(url)
        }
        openExternalUrlTriggered(url)
    }

    function onOverlayMoved(popup, diffY) {
        if ((popup.y + diffY) > 0) {
            popup.y += diffY
        }
    }
    function handleNewViewAdded(view) {
        if (views.length !== 0) {
            var topView = views[views.length-1]
        }
        views.push(view)

        view.webviewUrlChanged.connect(function(webviewUrl) {
            onUrlUpdatedForOverlay(view, webviewUrl)
        })
    }
    function handleOpenInUrlBrowserForView(url, view) {
        handleViewRemoved(view)
        openExternalUrlTriggered(url)
        openUrlExternally(url)
    }
    function createViewSlidingHandlerFor(newView, viewBelow) {
        var parentHeight = viewBelow.parent.height
        return function() {
            if (viewBelow && newView) {
                viewBelow.opacity =
                    newView.y / parentHeight
            }
        }
    }
    function topViewOnStack() {
        if (views.length !== 0) {
            return views[views.length-1]
        }
        return mainWebappView
    }
    function handleViewRemoved(view) {
        if (views.length === 0) {
            return
        }

        var topMostView = views[views.length-1]
        if (topMostView !== view) {
            return
        }
        views.pop()
        if (internal.urlPerOverlayView) {
            delete internal.urlPerOverlayView[topMostView]
            updateOverlayUrlsSettings()
        }

        var parentHeight = topMostView.parent.height
        var nextView = topViewOnStack()
        nextView.visible = true

        function onViewSlidingOut() {
            if (topMostView.y >= (topMostView.parent.height - 10)) {
                topMostView.yChanged.disconnect(onViewSlidingOut)
                topMostView.destroy()

                updateViewVisibility(nextView, true)
            }
        }
        topMostView.yChanged.connect(onViewSlidingOut)
        topMostView.y = topMostView.parent.height
    }
    function updateViewVisibility(view, visible) {
        if (view) {
            view.opacity = visible ? 1.0 : 0.0
        }
    }
    function createPopupView(parentView, params, isRequestFromMainWebappWebview, context) {
        var view = popupWebOverlayFactory.createObject(
            parentView,
            params);

        var topMostView = topViewOnStack()

        // handle opacity updates of the view below this one
        // when the view is sliding
        view.yChanged.connect(
            createViewSlidingHandlerFor(view, topMostView))

        function onViewSlidingIn() {
            var parentHeight = view.parent.height

            if (view.y <= 10) {
                view.yChanged.disconnect(onViewSlidingIn)

                updateViewVisibility(topMostView, false)
            }
        }
        view.yChanged.connect(onViewSlidingIn)

        view.y = 0
        handleNewViewAdded(view)
        newViewCreated(view.url)
    }
    function createPopupViewForRequest(parentView, request, isRequestFromMainWebappWebview, context) {
        createPopupView(parentView,
                        { request: request,
                          webContext: context,
                          popupWindowController: controller,
                          mediaAccessDialogComponent: mediaAccessDialogComponent
                        },
                        isRequestFromMainWebappWebview,
                        context)
    }
    function createPopupViewForUrl(parentView,
                                   overlayUrl,
                                   isRequestFromMainWebappWebview,
                                   context) {
        createPopupView(parentView,
                        { url: overlayUrl,
                          webContext: context,
                          popupWindowController: controller,
                          mediaAccessDialogComponent: mediaAccessDialogComponent
                        },
                        isRequestFromMainWebappWebview,
                        context)
    }

    Component {
        id: popupWebOverlayFactory
        PopupWindowOverlay {
            id: overlay

            height: parent.height
            width: parent.width

            wide: controller.wide

            y: overlay.parent.height

            // Poor mans heuristic to know when an overlay has been
            // loaded and is in full view. We cannot rely on the
            // NumberAnimation running/started since they dont
            // work properly when inside a Behavior
            onYChanged: {
                if (y === 0) {
                    windowOverlayOpenAnimationDone()
                }
            }
	    
            Behavior on y {
                NumberAnimation {
                    duration: 500
                    easing.type: Easing.InOutQuad
                }
            }
        }
    }

    function handleNewForegroundNavigationRequest(
            url, request, isRequestFromMainWebappWebview) {

        if (views.length >= maxSimultaneousViews) {
            request.action = Oxide.NavigationRequest.ActionReject
            // Default to open externally, maybe should present a dialog
            openUrlExternally(url.toString())
            console.log("Maximum number of popup overlay opened, opening: "
                        + url
                        + " in the browser")
            return false
        }
        return true
    }
}