~daker/ubuntu-html5-theme/fix.toggle-zindex

« back to all changes in this revision

Viewing changes to src/plugin/Ubuntu/WebApps/WebAppContainer.qml

Add a better cordova qml component search pattern for the cordovaview mostly to account for the cordova 3.4 version that is to be installed locally; Add autopilot tests for the container,. Fixes: https://bugs.launchpad.net/bugs/1277665.

Approved by PS Jenkins bot, Alexandre Abreu, David Barth.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright 2013 Canonical Ltd.
 
2
 * Copyright 2014 Canonical Ltd.
3
3
 *
4
4
 * This file is part of ubuntu-html5-container.
5
5
 *
18
18
 
19
19
import QtQuick 2.0
20
20
import Ubuntu.Components 0.1
21
 
import CordovaUbuntu 2.8
22
 
import Ubuntu.UnityWebApps 0.1
 
21
import Ubuntu.Components.Extras.Browser 0.1
23
22
 
24
23
 
25
24
/*!
26
25
    \qmltype WebAppContainer
27
26
    \inqmlmodule Ubuntu.WebApps 0.1
28
27
    \ingroup ubuntu
29
 
    \brief WebAppContainer is the root Item that should be used for all HTML5 applications.
 
28
    \brief WebAppContainer is the root element that should be used for all HTML5 applications.
30
29
*/
31
30
MainView {
32
31
    id: root
41
40
 
42
41
      The path is absolute or relative to the current dir.
43
42
      */
44
 
    property string htmlIndexDirectory
 
43
    property alias htmlIndexDirectory: cordovaWebviewProvider.htmlIndexDirectory
45
44
 
46
45
    Page {
47
46
        id: mainPage
49
48
        /*!
50
49
          \internal
51
50
         */
52
 
        CordovaView {
53
 
            id: cordovaView
54
 
            objectName: "view"
55
 
            wwwDir: root.htmlIndexDirectory
 
51
        CordovaLoader {
 
52
            id: cordovaWebviewProvider
56
53
            anchors.fill: parent
57
 
        }
58
 
 
59
 
        /*!
60
 
          \internal
61
 
         */
62
 
        function getUnityWebappsProxies() {
63
 
            return UnityWebAppsUtils.makeProxiesForQtWebViewBindee(cordovaView.mainWebview);
 
54
            onCreationError: {
 
55
                mainPage._onCordovaCreationError();
 
56
            }
 
57
            onCreated: {
 
58
                bindings.bindingMainWebview = Qt.binding(function() {
 
59
                    return cordovaInstance.mainWebview;
 
60
                });
 
61
            }
 
62
        }
 
63
 
 
64
        /*!
 
65
          \internal
 
66
         */
 
67
        function _onCordovaCreationError() {
 
68
            mainPage._fallbackToWebview();
 
69
        }
 
70
 
 
71
        /*!
 
72
          \internal
 
73
         */
 
74
        function _fallbackToWebview() {
 
75
            console.debug('Falling back on the plain Webview backend.')
 
76
 
 
77
            webviewFallbackComponentLoader.sourceComponent = Qt.binding(function() {
 
78
                return root.htmlIndexDirectory.length !== 0
 
79
                        ? webviewFallbackComponent : null;
 
80
            });
 
81
        }
 
82
 
 
83
        /*!
 
84
          \internal
 
85
         */
 
86
        function _getAppStartupIndexFileUri() {
 
87
            return 'file://' + root.htmlIndexDirectory + '/index.html';
64
88
        }
65
89
 
66
90
        /*!
67
91
          \internal
68
92
         */
69
93
        Loader {
70
 
            id: webappBindingsLoader
71
 
            visible: false
 
94
            id: webviewFallbackComponentLoader
72
95
            anchors.fill: parent
73
 
            sourceComponent: cordovaView.mainWebview ? webappBindingsComponent : undefined
 
96
            onLoaded: {
 
97
                bindings.bindingMainWebview = item;
 
98
            }
74
99
        }
75
100
 
76
101
        /*!
77
102
          \internal
78
103
         */
79
104
        Component {
80
 
            id: webappBindingsComponent
81
 
 
82
 
            UnityWebApps {
83
 
                id: webapps
84
 
                bindee: mainPage
85
 
                injectExtraUbuntuApis: true
86
 
                requiresInit: false
 
105
            id: webviewFallbackComponent
 
106
            UbuntuWebView {
 
107
                url: mainPage._getAppStartupIndexFileUri()
 
108
 
 
109
                experimental.preferences.localStorageEnabled: true
 
110
                experimental.preferences.offlineWebApplicationCacheEnabled: true
 
111
                experimental.preferences.universalAccessFromFileURLsAllowed: true
 
112
                experimental.preferences.webGLEnabled: true
 
113
 
 
114
                experimental.databaseQuotaDialog: Item {
 
115
                    Timer {
 
116
                        interval: 1
 
117
                        running: true
 
118
                        onTriggered: {
 
119
                            model.accept(model.expectedUsage)
 
120
                        }
 
121
                    }
 
122
                }
 
123
                // port in QTWEBKIT_INSPECTOR_SERVER enviroment variable
 
124
                experimental.preferences.developerExtrasEnabled: true
87
125
            }
88
126
        }
 
127
 
 
128
        /*!
 
129
          \internal
 
130
         */
 
131
        UbuntuJavascriptBindings {
 
132
            id: bindings
 
133
        }
89
134
    }
90
135
}
91
136