Merge lp:~mardy/webbrowser-app/per-account-dir into lp:webbrowser-app

Proposed by Alberto Mardegan
Status: Rejected
Rejected by: Alberto Mardegan
Proposed branch: lp:~mardy/webbrowser-app/per-account-dir
Merge into: lp:webbrowser-app
Diff against target: 555 lines (+140/-136)
12 files modified
src/app/WebViewImpl.qml (+5/-0)
src/app/webcontainer/AccountsPage.qml (+5/-29)
src/app/webcontainer/WebApp.qml (+1/-0)
src/app/webcontainer/WebViewImplWebkit.qml (+1/-0)
src/app/webcontainer/WebappContainerWebview.qml (+4/-1)
src/app/webcontainer/chrome-cookie-store.cpp (+0/-13)
src/app/webcontainer/chrome-cookie-store.h (+0/-7)
src/app/webcontainer/cookie-store.cpp (+12/-20)
src/app/webcontainer/online-accounts-cookie-store.cpp (+4/-5)
src/app/webcontainer/oxide-cookie-helper.cpp (+5/-4)
src/app/webcontainer/webapp-container.cpp (+2/-0)
src/app/webcontainer/webapp-container.qml (+101/-57)
To merge this branch: bzr merge lp:~mardy/webbrowser-app/per-account-dir
Reviewer Review Type Date Requested Status
Alberto Mardegan (community) Needs Resubmitting
PS Jenkins bot continuous-integration Needs Fixing
Review via email: mp+237428@code.launchpad.net

Commit message

Use a different data location for different accounts

Move the webview behind a Loader, and set the dataPath according to the account number.

Description of the change

Use a different data location for different accounts

Move the webview behind a Loader, and set the dataPath according to the account number.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
758. By Alberto Mardegan

Remove unused property

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
759. By Alberto Mardegan

Watch URL changes

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
760. By Alberto Mardegan

from trunk

[ Alberto Mardegan ]
Filter out account services which belong to other webapps

761. By Alberto Mardegan

Use dataLocation

Apparmor rules prevent oxide from using ~/.cache/

762. By Alberto Mardegan

Check dates at a later stage

763. By Alberto Mardegan

Fix timestamp conversion

764. By Alberto Mardegan

Remove error msg

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alberto Mardegan (mardy) wrote :
review: Needs Resubmitting

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/app/WebViewImpl.qml'
--- src/app/WebViewImpl.qml 2014-09-15 14:53:14 +0000
+++ src/app/WebViewImpl.qml 2014-10-08 14:35:55 +0000
@@ -29,6 +29,7 @@
29 property var certificateError29 property var certificateError
30 // Invalid certificates the user has explicitly allowed for this session30 // Invalid certificates the user has explicitly allowed for this session
31 property var allowedCertificates: []31 property var allowedCertificates: []
32 property url dataPath
3233
33 /*experimental.certificateVerificationDialog: CertificateVerificationDialog {}34 /*experimental.certificateVerificationDialog: CertificateVerificationDialog {}
34 experimental.authenticationDialog: AuthenticationDialog {}35 experimental.authenticationDialog: AuthenticationDialog {}
@@ -39,6 +40,10 @@
39 beforeUnloadDialog: BeforeUnloadDialog {}40 beforeUnloadDialog: BeforeUnloadDialog {}
40 filePicker: filePickerLoader.item41 filePicker: filePickerLoader.item
4142
43 context: WebContext {
44 dataPath: webview.dataPath
45 }
46
42 onDownloadRequested: {47 onDownloadRequested: {
43 if (downloadLoader.status == Loader.Ready) {48 if (downloadLoader.status == Loader.Ready) {
44 var headers = { }49 var headers = { }
4550
=== modified file 'src/app/webcontainer/AccountsPage.qml'
--- src/app/webcontainer/AccountsPage.qml 2014-08-21 15:15:21 +0000
+++ src/app/webcontainer/AccountsPage.qml 2014-10-08 14:35:55 +0000
@@ -25,12 +25,10 @@
2525
26 property alias accountProvider: accountsLogin.accountProvider26 property alias accountProvider: accountsLogin.accountProvider
27 property alias applicationName: accountsLogin.applicationName27 property alias applicationName: accountsLogin.applicationName
28 property var webappCookieStore: null28
29 property var onlineAccountStoreComponent: null29 signal done(bool successful, var credentialsId)
3030
31 signal done()31 visible: true
32
33 visible: false
34 anchors.fill: parent32 anchors.fill: parent
3533
36 AccountsLoginPage {34 AccountsLoginPage {
@@ -38,32 +36,10 @@
3836
39 anchors.fill: parent37 anchors.fill: parent
4038
41 QtObject {
42 id: internal
43 function onMoved(result) {
44 webappCookieStore.moved.disconnect(internal.onMoved)
45 if (!result) {
46 console.error("Unable to move cookies")
47 }
48 accountsPage.done()
49 }
50 }
51
52 onDone: {39 onDone: {
53 if (!accountsPage.visible)40 if (!accountsPage.visible)
54 return41 return
55 if (!credentialsId) {42 accountsPage.done(credentialsId != null, credentialsId)
56 accountsPage.done()
57 return
58 }
59
60 if (webappCookieStore) {
61 var instance = onlineAccountStoreComponent.createObject(accountsLogin, { "accountId": credentialsId })
62 webappCookieStore.moved.connect(internal.onMoved)
63 webappCookieStore.moveFrom(instance)
64 } else {
65 accountsPage.done()
66 }
67 }43 }
68 }44 }
69}45}
7046
=== modified file 'src/app/webcontainer/WebApp.qml'
--- src/app/webcontainer/WebApp.qml 2014-10-03 14:41:14 +0000
+++ src/app/webcontainer/WebApp.qml 2014-10-08 14:35:55 +0000
@@ -38,6 +38,7 @@
38 property alias webappUrlPatterns: webview.webappUrlPatterns38 property alias webappUrlPatterns: webview.webappUrlPatterns
39 property alias popupRedirectionUrlPrefix: webview.popupRedirectionUrlPrefix39 property alias popupRedirectionUrlPrefix: webview.popupRedirectionUrlPrefix
40 property alias webviewOverrideFile: webview.webviewOverrideFile40 property alias webviewOverrideFile: webview.webviewOverrideFile
41 property alias dataPath: webview.dataPath
41 property string localUserAgentOverride: ""42 property string localUserAgentOverride: ""
4243
43 property bool backForwardButtonsVisible: false44 property bool backForwardButtonsVisible: false
4445
=== modified file 'src/app/webcontainer/WebViewImplWebkit.qml'
--- src/app/webcontainer/WebViewImplWebkit.qml 2014-07-29 21:51:07 +0000
+++ src/app/webcontainer/WebViewImplWebkit.qml 2014-10-08 14:35:55 +0000
@@ -35,6 +35,7 @@
35 property var webappUrlPatterns: null35 property var webappUrlPatterns: null
36 property string localUserAgentOverride: ""36 property string localUserAgentOverride: ""
37 property string popupRedirectionUrlPrefix: ""37 property string popupRedirectionUrlPrefix: ""
38 property url dataPath // unused
3839
39 function getUAString() {40 function getUAString() {
40 return webview.localUserAgentOverride.length === 0 ? undefined : webview.localUserAgentOverride41 return webview.localUserAgentOverride.length === 0 ? undefined : webview.localUserAgentOverride
4142
=== modified file 'src/app/webcontainer/WebappContainerWebview.qml'
--- src/app/webcontainer/WebappContainerWebview.qml 2014-09-02 06:29:12 +0000
+++ src/app/webcontainer/WebappContainerWebview.qml 2014-10-08 14:35:55 +0000
@@ -30,6 +30,7 @@
30 property bool withOxide: false30 property bool withOxide: false
31 property bool developerExtrasEnabled: false31 property bool developerExtrasEnabled: false
32 property string webappName: ""32 property string webappName: ""
33 property url dataPath
33 property var currentWebview: webappContainerWebViewLoader.item34 property var currentWebview: webappContainerWebViewLoader.item
34 property var webappUrlPatterns35 property var webappUrlPatterns
35 property string localUserAgentOverride: ""36 property string localUserAgentOverride: ""
@@ -39,9 +40,10 @@
39 Loader {40 Loader {
40 id: webappContainerWebViewLoader41 id: webappContainerWebViewLoader
41 anchors.fill: parent42 anchors.fill: parent
42 asynchronous: true
43 }43 }
4444
45 onUrlChanged: if (webappContainerWebViewLoader.item) webappContainerWebViewLoader.item.url = url
46
45 Component.onCompleted: {47 Component.onCompleted: {
46 var webappEngineSource =48 var webappEngineSource =
47 withOxide ?49 withOxide ?
@@ -60,6 +62,7 @@
60 { localUserAgentOverride: containerWebview.localUserAgentOverride62 { localUserAgentOverride: containerWebview.localUserAgentOverride
61 , url: containerWebview.url63 , url: containerWebview.url
62 , webappName: containerWebview.webappName64 , webappName: containerWebview.webappName
65 , dataPath: dataPath
63 , webappUrlPatterns: containerWebview.webappUrlPatterns66 , webappUrlPatterns: containerWebview.webappUrlPatterns
64 , developerExtrasEnabled: containerWebview.developerExtrasEnabled67 , developerExtrasEnabled: containerWebview.developerExtrasEnabled
65 , popupRedirectionUrlPrefix: containerWebview.popupRedirectionUrlPrefix})68 , popupRedirectionUrlPrefix: containerWebview.popupRedirectionUrlPrefix})
6669
=== modified file 'src/app/webcontainer/chrome-cookie-store.cpp'
--- src/app/webcontainer/chrome-cookie-store.cpp 2014-09-18 13:37:07 +0000
+++ src/app/webcontainer/chrome-cookie-store.cpp 2014-10-08 14:35:55 +0000
@@ -33,19 +33,6 @@
33 this, SLOT(oxideCookiesUpdated(const QList<QNetworkCookie>&)));33 this, SLOT(oxideCookiesUpdated(const QList<QNetworkCookie>&)));
34}34}
3535
36void ChromeCookieStore::setHomepage(const QUrl& homepage) {
37 if (homepage == m_homepage)
38 return;
39
40 m_homepage = homepage;
41
42 emit homepageChanged();
43}
44
45QUrl ChromeCookieStore::homepage() const {
46 return m_homepage;
47}
48
49void ChromeCookieStore::setOxideStoreBackend(QObject* backend)36void ChromeCookieStore::setOxideStoreBackend(QObject* backend)
50{37{
51 m_cookieHelper->setOxideStoreBackend(backend);38 m_cookieHelper->setOxideStoreBackend(backend);
5239
=== modified file 'src/app/webcontainer/chrome-cookie-store.h'
--- src/app/webcontainer/chrome-cookie-store.h 2014-09-18 13:37:07 +0000
+++ src/app/webcontainer/chrome-cookie-store.h 2014-10-08 14:35:55 +0000
@@ -30,7 +30,6 @@
30{30{
31 Q_OBJECT31 Q_OBJECT
3232
33 Q_PROPERTY(QUrl homepage READ homepage WRITE setHomepage NOTIFY homepageChanged)
34 Q_PROPERTY(QString dbPath READ dbPath WRITE setDbPath NOTIFY dbPathChanged)33 Q_PROPERTY(QString dbPath READ dbPath WRITE setDbPath NOTIFY dbPathChanged)
35 Q_PROPERTY(QObject* oxideStoreBackend READ oxideStoreBackend WRITE setOxideStoreBackend NOTIFY oxideStoreBackendChanged)34 Q_PROPERTY(QObject* oxideStoreBackend READ oxideStoreBackend WRITE setOxideStoreBackend NOTIFY oxideStoreBackendChanged)
3635
@@ -41,10 +40,6 @@
41 void setDbPath(const QString& path);40 void setDbPath(const QString& path);
42 QString dbPath() const;41 QString dbPath() const;
4342
44 // dbpaths
45 void setHomepage(const QUrl& path);
46 QUrl homepage() const;
47
48 // oxideStoreBackend43 // oxideStoreBackend
49 void setOxideStoreBackend(QObject* backend);44 void setOxideStoreBackend(QObject* backend);
50 QObject* oxideStoreBackend() const;45 QObject* oxideStoreBackend() const;
@@ -55,7 +50,6 @@
55Q_SIGNALS:50Q_SIGNALS:
56 void dbPathChanged();51 void dbPathChanged();
57 void oxideStoreBackendChanged();52 void oxideStoreBackendChanged();
58 void homepageChanged();
5953
60private Q_SLOTS:54private Q_SLOTS:
61 void oxideCookiesReceived(int requestId, const QVariant& cookies);55 void oxideCookiesReceived(int requestId, const QVariant& cookies);
@@ -67,7 +61,6 @@
6761
68private:62private:
69 OxideCookieHelper* m_cookieHelper;63 OxideCookieHelper* m_cookieHelper;
70 QUrl m_homepage;
71 QString m_dbPath;64 QString m_dbPath;
72};65};
7366
7467
=== modified file 'src/app/webcontainer/cookie-store.cpp'
--- src/app/webcontainer/cookie-store.cpp 2014-08-26 09:49:32 +0000
+++ src/app/webcontainer/cookie-store.cpp 2014-10-08 14:35:55 +0000
@@ -91,8 +91,20 @@
91 if (Q_UNLIKELY(!request))91 if (Q_UNLIKELY(!request))
92 return;92 return;
9393
94 QDateTime lastRemoteCookieUpdate =
95 request->_cookieStore->lastUpdateTimeStamp();
96 QDateTime lastLocalCookieUpdate = lastUpdateTimeStamp();
97
94 delete request;98 delete request;
9599
100 if (lastRemoteCookieUpdate.isValid() &&
101 lastLocalCookieUpdate.isValid() &&
102 (lastRemoteCookieUpdate < lastLocalCookieUpdate))
103 {
104 Q_EMIT moved(false);
105 return;
106 }
107
96 connect(this, &CookieStore::cookiesSet,108 connect(this, &CookieStore::cookiesSet,
97 this, &CookieStore::moved);109 this, &CookieStore::moved);
98110
@@ -104,26 +116,6 @@
104 if (Q_UNLIKELY(!store))116 if (Q_UNLIKELY(!store))
105 return;117 return;
106118
107 QDateTime lastRemoteCookieUpdate = store->lastUpdateTimeStamp();
108 QDateTime lastLocalCookieUpdate = lastUpdateTimeStamp();
109
110 // Disabled for now since.
111 // There is an obvious race if the WebView is instanciated
112 // (since it creates a cookies db file at creation time).
113 // But when delaying the creation, only using the WebContext to
114 // access the cookieManager, and manually creating a cookies db file
115 // if none is found (since the cookie manager does not create one
116 // when setting its cookies), something fails.
117#if 0
118 if (lastRemoteCookieUpdate.isValid() &&
119 lastLocalCookieUpdate.isValid() &&
120 (lastRemoteCookieUpdate < lastLocalCookieUpdate))
121 {
122 Q_EMIT moved(false);
123 return;
124 }
125#endif
126
127 CookieStoreRequest* storeRequest = new CookieStoreRequest(store);119 CookieStoreRequest* storeRequest = new CookieStoreRequest(store);
128 _currentStoreRequests.insert(storeRequest, true);120 _currentStoreRequests.insert(storeRequest, true);
129121
130122
=== modified file 'src/app/webcontainer/online-accounts-cookie-store.cpp'
--- src/app/webcontainer/online-accounts-cookie-store.cpp 2014-08-05 00:25:20 +0000
+++ src/app/webcontainer/online-accounts-cookie-store.cpp 2014-10-08 14:35:55 +0000
@@ -116,15 +116,14 @@
116116
117 if (arguments.count() > 1)117 if (arguments.count() > 1)
118 {118 {
119 QDateTime t;119 qint64 timeStamp = arguments.at(1).toLongLong();
120 QVariant timeStampVariant(arguments.at(1));120 if (timeStamp != 0)
121 if (timeStampVariant.canConvert(QMetaType::LongLong))
122 {121 {
123 qDebug() << "Got a cookie timestamp of"122 qDebug() << "Got a cookie timestamp of"
124 << arguments.at(1).toLongLong()123 << timeStamp
125 << "from Online Accounts DBUS cookiesForIdentity() call.";124 << "from Online Accounts DBUS cookiesForIdentity() call.";
126125
127 t.fromMSecsSinceEpoch(arguments.at(1).toLongLong() * 1000);126 QDateTime t = QDateTime::fromMSecsSinceEpoch(timeStamp * 1000);
128 updateLastUpdateTimestamp(t);127 updateLastUpdateTimestamp(t);
129 }128 }
130 }129 }
131130
=== modified file 'src/app/webcontainer/oxide-cookie-helper.cpp'
--- src/app/webcontainer/oxide-cookie-helper.cpp 2014-10-03 11:47:36 +0000
+++ src/app/webcontainer/oxide-cookie-helper.cpp 2014-10-08 14:35:55 +0000
@@ -53,6 +53,7 @@
53 m_backend(0),53 m_backend(0),
54 q_ptr(q)54 q_ptr(q)
55{55{
56 qRegisterMetaType<QList<QNetworkCookie> >();
56}57}
5758
58void OxideCookieHelperPrivate::setCookies(const QList<QNetworkCookie>& cookies)59void OxideCookieHelperPrivate::setCookies(const QList<QNetworkCookie>& cookies)
@@ -75,7 +76,7 @@
75 /* We don't simply use Q_EMIT because we want the signal to be emitted76 /* We don't simply use Q_EMIT because we want the signal to be emitted
76 * asynchronously */77 * asynchronously */
77 QMetaObject::invokeMethod(q, "cookiesSet", Qt::QueuedConnection,78 QMetaObject::invokeMethod(q, "cookiesSet", Qt::QueuedConnection,
78 Q_ARG(const QList<QNetworkCookie>&, cookies));79 Q_ARG(QList<QNetworkCookie>, cookies));
79 return;80 return;
80 }81 }
8182
@@ -119,8 +120,8 @@
119 QMetaObject::invokeMethod(m_backend, "setNetworkCookies",120 QMetaObject::invokeMethod(m_backend, "setNetworkCookies",
120 Qt::DirectConnection,121 Qt::DirectConnection,
121 Q_RETURN_ARG(int, requestId),122 Q_RETURN_ARG(int, requestId),
122 Q_ARG(const QUrl&, url),123 Q_ARG(QUrl, url),
123 Q_ARG(const QList<QNetworkCookie>&, it.value()));124 Q_ARG(QList<QNetworkCookie>, it.value()));
124 if (Q_UNLIKELY(requestId == -1)) {125 if (Q_UNLIKELY(requestId == -1)) {
125 m_failedCookies.append(cookiesWithDomain(it.value(), url.host()));126 m_failedCookies.append(cookiesWithDomain(it.value(), url.host()));
126 } else {127 } else {
@@ -133,7 +134,7 @@
133 /* We don't simply use Q_EMIT because we want the signal to be emitted134 /* We don't simply use Q_EMIT because we want the signal to be emitted
134 * asynchronously */135 * asynchronously */
135 QMetaObject::invokeMethod(q, "cookiesSet", Qt::QueuedConnection,136 QMetaObject::invokeMethod(q, "cookiesSet", Qt::QueuedConnection,
136 Q_ARG(const QList<QNetworkCookie>&, m_failedCookies));137 Q_ARG(QList<QNetworkCookie>, m_failedCookies));
137 }138 }
138}139}
139140
140141
=== modified file 'src/app/webcontainer/webapp-container.cpp'
--- src/app/webcontainer/webapp-container.cpp 2014-10-03 14:41:14 +0000
+++ src/app/webcontainer/webapp-container.cpp 2014-10-08 14:35:55 +0000
@@ -157,6 +157,8 @@
157 }157 }
158158
159 context->setContextProperty("webappContainerHelper", m_webappContainerHelper.data());159 context->setContextProperty("webappContainerHelper", m_webappContainerHelper.data());
160 context->setContextProperty("cacheLocation",
161 QStandardPaths::writableLocation(QStandardPaths::CacheLocation));
160162
161 if ( ! m_popupRedirectionUrlPrefix.isEmpty()) {163 if ( ! m_popupRedirectionUrlPrefix.isEmpty()) {
162 m_window->setProperty("popupRedirectionUrlPrefix", m_popupRedirectionUrlPrefix);164 m_window->setProperty("popupRedirectionUrlPrefix", m_popupRedirectionUrlPrefix);
163165
=== modified file 'src/app/webcontainer/webapp-container.qml'
--- src/app/webcontainer/webapp-container.qml 2014-10-03 14:41:14 +0000
+++ src/app/webcontainer/webapp-container.qml 2014-10-08 14:35:55 +0000
@@ -53,54 +53,52 @@
53 title: getWindowTitle()53 title: getWindowTitle()
5454
55 function getWindowTitle() {55 function getWindowTitle() {
56 var webappViewTitle = webappViewLoader.item ? webappViewLoader.item.title : ""
56 if (typeof(webappName) === 'string' && webappName.length !== 0) {57 if (typeof(webappName) === 'string' && webappName.length !== 0) {
57 return webappName58 return webappName
58 } else if (browser.title) {59 } else if (webappViewTitle) {
59 // TRANSLATORS: %1 refers to the current page’s title60 // TRANSLATORS: %1 refers to the current page’s title
60 return i18n.tr("%1 - Ubuntu Web Browser").arg(browser.title)61 return i18n.tr("%1 - Ubuntu Web Browser").arg(webappViewTitle)
61 } else {62 } else {
62 return i18n.tr("Ubuntu Web Browser")63 return i18n.tr("Ubuntu Web Browser")
63 }64 }
64 }65 }
6566
66 WebApp {67 Component {
67 id: browser68 id: webappViewComponent
6869
69 // Initially set as non visible to leave a chance70 WebApp {
70 // for the OA dialog to appear71 id: browser
71 visible: false72
7273 url: accountProvider.length !== 0 ? "" : root.url
73 url: accountProvider.length === 0 ? root.url : ""74
7475 dataPath: webappDataLocation
75 chromeVisible: root.chromeVisible76 webappName: root.webappName
76 backForwardButtonsVisible: root.backForwardButtonsVisible77 chromeVisible: root.chromeVisible
77 developerExtrasEnabled: root.developerExtrasEnabled78 backForwardButtonsVisible: root.backForwardButtonsVisible
78 oxide: root.oxide79 developerExtrasEnabled: root.developerExtrasEnabled
79 webappModelSearchPath: root.webappModelSearchPath80 oxide: root.oxide
80 webappUrlPatterns: root.webappUrlPatterns81 webappModelSearchPath: root.webappModelSearchPath
8182 webappUrlPatterns: root.webappUrlPatterns
82 localUserAgentOverride: root.localUserAgentOverride83
8384 localUserAgentOverride: root.localUserAgentOverride
84 popupRedirectionUrlPrefix: root.popupRedirectionUrlPrefix85
85 webviewOverrideFile: root.webviewOverrideFile86 popupRedirectionUrlPrefix: root.popupRedirectionUrlPrefix
8687 webviewOverrideFile: root.webviewOverrideFile
87 anchors.fill: parent88
8889 anchors.fill: parent
89 webbrowserWindow: webbrowserWindowProxy90
9091 webbrowserWindow: webbrowserWindowProxy
91 onWebappNameChanged: {92
92 if (root.webappName !== browser.webappName) {93 onWebappNameChanged: {
93 root.webappName = browser.webappName;94 if (root.webappName !== browser.webappName) {
94 root.title = getWindowTitle();95 root.webappName = browser.webappName;
96 root.title = getWindowTitle();
97 }
95 }98 }
96 }99
97100 Component.onCompleted: i18n.domain = "webbrowser-app"
98 onCurrentWebviewChanged: {101 }
99 if (currentWebview)
100 root.updateCurrentView()
101 }
102
103 Component.onCompleted: i18n.domain = "webbrowser-app"
104 }102 }
105103
106 UnityWebApps.UnityWebappsAppModel {104 UnityWebApps.UnityWebappsAppModel {
@@ -117,7 +115,9 @@
117115
118 // XXX: work around https://bugs.launchpad.net/unity8/+bug/1328839116 // XXX: work around https://bugs.launchpad.net/unity8/+bug/1328839
119 // by toggling fullscreen on the window only on desktop.117 // by toggling fullscreen on the window only on desktop.
120 visibility: browser.currentWebview && browser.currentWebview.fullscreen &&118 visibility: webappViewLoader.item &&
119 webappViewLoader.item.currentWebview &&
120 webappViewLoader.item.currentWebview.fullscreen &&
121 (formFactor === "desktop") ? Window.FullScreen : Window.AutomaticVisibility121 (formFactor === "desktop") ? Window.FullScreen : Window.AutomaticVisibility
122122
123 Loader {123 Loader {
@@ -134,17 +134,62 @@
134 }134 }
135 }135 }
136136
137 Loader {
138 id: webappViewLoader
139 anchors.fill: parent
140
141 property var credentialsId: null
142 property var webappDataLocation: credentialsId != null ? dataLocation + "/id-" + credentialsId : dataLocation
143 }
144
145 function onCookiesMoved(result) {
146 if (__webappCookieStore) {
147 __webappCookieStore.moved.disconnect(onCookiesMoved)
148 }
149 if (!result) {
150 console.log("Cookies were not moved")
151 }
152 webappViewLoader.item.url = root.url
153 }
154
155 function moveCookies(credentialsId) {
156 if (!__webappCookieStore) {
157 var context = webappViewLoader.item.currentWebview.context
158 __webappCookieStore = oxideCookieStoreComponent.createObject(this, {
159 "oxideStoreBackend": context.cookieManager,
160 "dbPath": context.dataPath + "/cookies.sqlite"
161 })
162 }
163
164 var storeComponent = localCookieStoreDbPath.length !== 0 ?
165 localCookieStoreComponent : onlineAccountStoreComponent
166
167 var instance = storeComponent.createObject(root, { "accountId": credentialsId })
168 __webappCookieStore.moved.connect(onCookiesMoved)
169 __webappCookieStore.moveFrom(instance)
170 }
171
137 Connections {172 Connections {
138 target: accountsPageComponentLoader.item173 target: accountsPageComponentLoader.item
139 onDone: loadWebAppView()174 onDone: {
175 if (successful && credentialsId) {
176 webappViewLoader.loaded.connect(function () {
177 if (webappViewLoader.status == Loader.Ready) {
178 moveCookies(webappViewLoader.credentialsId)
179 }
180 });
181 webappViewLoader.credentialsId = credentialsId
182 webappViewLoader.sourceComponent = webappViewComponent
183 }
184 else {
185 loadWebAppView()
186 }
187 }
140 }188 }
141189
142 Component {190 Component {
143 id: oxideCookieStoreComponent191 id: oxideCookieStoreComponent
144 ChromeCookieStore {192 ChromeCookieStore {
145 dbPath: dataLocation + "/cookies.sqlite"
146 homepage: root.url
147 oxideStoreBackend: browser.currentWebview ? browser.currentWebview.context.cookieManager : null
148 }193 }
149 }194 }
150195
@@ -155,6 +200,10 @@
155 }200 }
156 }201 }
157202
203 Component.onCompleted: {
204 updateCurrentView()
205 }
206
158 Component {207 Component {
159 id: onlineAccountStoreComponent208 id: onlineAccountStoreComponent
160 OnlineAccountsCookieStore { }209 OnlineAccountsCookieStore { }
@@ -163,7 +212,7 @@
163 function updateCurrentView() {212 function updateCurrentView() {
164 // check if we are to display the login view213 // check if we are to display the login view
165 // or directly switch to the webapp view214 // or directly switch to the webapp view
166 if (accountProvider.length !== 0 && !__webappCookieStore && oxide) {215 if (accountProvider.length !== 0 && oxide) {
167 loadLoginView();216 loadLoginView();
168 } else {217 } else {
169 loadWebAppView();218 loadWebAppView();
@@ -171,27 +220,22 @@
171 }220 }
172221
173 function loadLoginView() {222 function loadLoginView() {
174 if (!__webappCookieStore) {
175 __webappCookieStore = oxideCookieStoreComponent.createObject(this)
176 }
177 accountsPageComponentLoader.setSource("AccountsPage.qml", {223 accountsPageComponentLoader.setSource("AccountsPage.qml", {
178 "accountProvider": accountProvider,224 "accountProvider": accountProvider,
179 "applicationName": unversionedAppId,225 "applicationName": unversionedAppId,
180 "webappCookieStore": __webappCookieStore,
181 "onlineAccountStoreComponent": localCookieStoreDbPath.length !== 0 ?
182 localCookieStoreComponent : onlineAccountStoreComponent
183 })226 })
184 }227 }
185228
186 function loadWebAppView() {229 function loadWebAppView() {
187 if (accountsPageComponentLoader.item)230 if (accountsPageComponentLoader.item)
188 accountsPageComponentLoader.item.visible = false231 accountsPageComponentLoader.item.visible = false
189 browser.visible = true;232
190 if (browser.currentWebview) {233 webappViewLoader.loaded.connect(function () {
191 browser.currentWebview.visible = true;234 if (webappViewLoader.status === Loader.Ready) {
192 browser.currentWebview.url = root.url235 webappViewLoader.item.currentWebview.url = root.url
193 browser.webappName = root.webappName236 }
194 }237 });
238 webappViewLoader.sourceComponent = webappViewComponent
195 }239 }
196240
197 // Handle runtime requests to open urls as defined241 // Handle runtime requests to open urls as defined

Subscribers

People subscribed via source and target branches

to status/vote changes: