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

Proposed by Alberto Mardegan
Status: Merged
Approved by: Olivier Tilloy
Approved revision: 785
Merged at revision: 824
Proposed branch: lp:~mardy/webbrowser-app/per-account-dir2
Merge into: lp:webbrowser-app
Prerequisite: lp:~abreu-alexandre/webbrowser-app/fix-webapp-properties-ua-override
Diff against target: 603 lines (+159/-157)
11 files modified
src/app/webcontainer/AccountsPage.qml (+5/-29)
src/app/webcontainer/WebApp.qml (+1/-0)
src/app/webcontainer/WebViewImplOxide.qml (+5/-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.qml (+122/-78)
To merge this branch: bzr merge lp:~mardy/webbrowser-app/per-account-dir2
Reviewer Review Type Date Requested Status
Olivier Tilloy Approve
PS Jenkins bot continuous-integration Needs Fixing
Review via email: mp+239263@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.

This fixes the bug described in the linked bug report, and also another potential issue (which IIRC we never saw happening): merging all cookies from different accounts can lock the webapp into an invalid state. Usually the set of cookie keys is the same even among different accounts, so this problem does not happen because all the old keys are overwritten by the newly copied cookies. But if the sets of keys are not the same (that is, if one account has one cookie more than another one), the remote website could enter a wrong state.

Testing instructions: have multiple GMail or Twitter accounts configured, but make sure that only one (for each provider) has the webapp application enabled. Then use the GMail or the twitter webapp, and verify that they work properly.
Close the webapps, go to the Accounts in System Settings, and disable the webapps from the accounts where they are enabled, and enabled them in the other account. Open the webapps again, verify that you are logged in with the proper (new) account.
Then check that the cookies.db files have been created under <dataLocation>/id-<CredentialsId> (where CredentialsId can be seen with "account-console show <account-id>", and the account IDs can be seen with "account-console list").

To post a comment you must log in.
773. By Alberto Mardegan

cleanups

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)
774. By Alberto Mardegan

Restore line removed by accident

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

from trunk

[ CI bot ]
* Resync trunk
* Fix the override mechanism for navigator.userAgent, and add UA
  override rules for HSBC’s Brazilian mobile site and ESPN’s mobile
  site. (LP: #1316259)
[ Riccardo Padovani ]
* Fixed #1378975 - Fast double click on menu button opens menu twice
  (LP: #1378975)
* Updated the README
[ Jean-Francois Moy ]
* Twitter User Script - Hide the prompt to download the Android
  application. (LP: #1352789)
[ Ubuntu daily release ]
* New rebuild forced
[ Olivier Tilloy ]
* Prevent the browser from trying to download embedded flash
  applications. (LP: #1379806)
* Fix a harmless compilation warning found by clang (non-literal-null-
  conversion).
* Update UITK autopilot test imports. (LP: #1386276)
[ CI bot ]
* Resync trunk
[ Ubuntu daily release ]
* New rebuild forced
[ Olivier Tilloy ]
* Fix the override mechanism for navigator.userAgent, and add UA
  override rules for HSBC’s Brazilian mobile site and ESPN’s mobile
  site. (LP: #1316259)

776. By Alberto Mardegan

Revert pot changes

Revision history for this message
Olivier Tilloy (osomon) wrote :

All the webapp_container autopilot tests now fail: you need to replace "toolkit_emulators" by "uitk" in tests/autopilot/webapp_container/tests/__init__.py, to match a recent import renaming.

review: Needs Fixing
777. By Alberto Mardegan

Fix autopilot tests

Revision history for this message
Olivier Tilloy (osomon) wrote :

In src/app/WebViewImpl.qml:

16 + context: WebContext {
17 + dataPath: webview.dataPath
18 + }

This replaces the use of the custom shared context with a bare one that doesn’t have the functionality of the shared one (UA override mechanism, session cookie mode selection, user scripts). This won’t work.

review: Needs Fixing
Revision history for this message
Olivier Tilloy (osomon) wrote :

Scratch the above comment, I hadn’t noticed that WebContext was resolving to UbuntuWebContext.qml.

However this change will break the browser, because it means we instantiate several contexts with the same datapath (which is the reason why the shared context is a singleton in the first place).

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)
778. By Alberto Mardegan

Move context initialization to WebViewImplOxide.qml

779. By Alberto Mardegan

From trunk

[ Ubuntu daily release ]
* New rebuild forced
[ Alexandre Abreu ]
* A Webapp has the option to either specify a command line option to
  have a specific UA overriding the default or hgave a local webapp-
  properties.json file that defines the UA override such as:

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

from trunk

[ Ubuntu daily release ]
* New rebuild forced
[ Riccardo Padovani ]
* Added new upstream components to fit with design requests: multiple
  selection in History, standard swipe-to-delete. (LP: #1351167)
[ Olivier Tilloy ]
* Do not use a custom scheme to trigger the error page, this won’t
  work any longer as soon as oxide learns how to delegate unhandled
  schemes (see https://launchpad.net/bugs/1384460). (LP: #1384460)
* Ensure that the 'dataLocation' context property is updated when the
  application name changes. (LP: #1387754)
* Really honour the --fullscreen command-line switch. (LP: #1379766)

Revision history for this message
Olivier Tilloy (osomon) wrote :

In webapp-container.qml, there are 4 references to "browser.currentWebview" outside of webappViewComponent which are broken since "browser" is not defined outside its parent component. You’ll need to replace them with "webappViewLoader.item", and of course make the corresponding code conditional on the value of "webappViewLoader.item".

review: Needs Fixing
781. By Alberto Mardegan

Don't use invalid browser.currentWebview

782. By Alberto Mardegan

Remove updateBrowserUrl function

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:780
http://jenkins.qa.ubuntu.com/job/webbrowser-app-ci/1239/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-utopic-touch/6478
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-utopic/4299/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/webbrowser-app-utopic-amd64-ci/438
    SUCCESS: http://jenkins.qa.ubuntu.com/job/webbrowser-app-utopic-armhf-ci/438
        deb: http://jenkins.qa.ubuntu.com/job/webbrowser-app-utopic-armhf-ci/438/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/webbrowser-app-utopic-i386-ci/438
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-mako/6071
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/7730
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/7730/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/15472
    FAILURE: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-utopic/3651/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/4693
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/4693/artifact/work/output/*zip*/output.zip

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/webbrowser-app-ci/1239/rebuild

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

FAILED: Continuous integration, rev:782
http://jenkins.qa.ubuntu.com/job/webbrowser-app-ci/1240/
Executed test runs:
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-utopic-touch/6481
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-utopic/4302/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/webbrowser-app-utopic-amd64-ci/439
    SUCCESS: http://jenkins.qa.ubuntu.com/job/webbrowser-app-utopic-armhf-ci/439
        deb: http://jenkins.qa.ubuntu.com/job/webbrowser-app-utopic-armhf-ci/439/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/webbrowser-app-utopic-i386-ci/439
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-mako/6073
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/7733
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/7733/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/15477
    FAILURE: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-utopic/3653/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/4696
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/4696/artifact/work/output/*zip*/output.zip

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/webbrowser-app-ci/1240/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Olivier Tilloy (osomon) wrote :

118 - asynchronous: true

Why did you remove this attribute from the Loader?

Revision history for this message
Olivier Tilloy (osomon) wrote :

A minor style suggestion, in WebViewImplOxide.qml:

  property url dataPath
  …
  context: WebContext {
    dataPath: webview.dataPath
  }

could have been written:

  property alias dataPath: context.dataPath
  …
  context: WebContext {}

Revision history for this message
Olivier Tilloy (osomon) wrote :

In webapp-container.qml:

  Component.onCompleted: i18n.domain = "webbrowser-app"

should probably be moved to the top-level BrowserWindow component (although it works as is today, it might break in the future if we need translated strings before instantiating the WebApp component).

Revision history for this message
Olivier Tilloy (osomon) wrote :

In webapp-container.qml:

  console.log("Cookies were not moved")

you might want to use console.warn(…) instead.

Revision history for this message
Olivier Tilloy (osomon) wrote :

It looks like the updateCurrentView() function is called in one place only, maybe its implementation can be moved to the Component.onCompleted body instead?

Revision history for this message
Olivier Tilloy (osomon) wrote :

463 + if (successful && credentialsId) {

Isn’t 'credentialsId' guaranteed to be non-null if 'successful' is true? Or are you checking that it’s ≠ 0 as well? If not, I would say that the 'successful' parameter is redundant.

783. By Alberto Mardegan

Address review comments

Revision history for this message
Alberto Mardegan (mardy) wrote :

> 118 - asynchronous: true
>
> Why did you remove this attribute from the Loader?

I'm not sure; this was in the branch by Alex, on which I based my work. Let's ask him later.

> In webapp-container.qml:
> console.log("Cookies were not moved")
> you might want to use console.warn(…) instead.

It can be that cookies are not moved because the OA cookies are older then those in the webapp; actually, this is what will happen most of the times. So, the cookies not being moved is not really an error condition.

All your other suggestions have now been implemented.

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
Chris Coulson (chrisccoulson) wrote :

> Scratch the above comment, I hadn’t noticed that WebContext was resolving to
> UbuntuWebContext.qml.
>
> However this change will break the browser, because it means we instantiate
> several contexts with the same datapath (which is the reason why the shared
> context is a singleton in the first place).

We should really enforce this clearly in Oxide (currently, instantiating more than one WebContext with the same data path will result in obscure aborts like bug 1278315, but we could do an explicit abort with a more helpful error message)

784. By Alberto Mardegan

From trunk

[ Ubuntu daily release ]
* New rebuild forced
[ Alexandre Abreu ]
* Fix facebook content hub share, the proper share API was not enabled
  to access from the webapp-container. (LP: #1386682)
[ Riccardo Padovani ]
* Enabled swipe gesture to delete a bookmark from the new tab view
  (LP: #1351165)
* Fixed #1351149 - Opening a page from the history view should do it
  in a new tab (LP: #1351149)
[ Alexandre Abreu ]
* Fix AP tests for webapp-container (LP: #1389194)
* Fix an inconsistent property binding that is mostly more than
  annoying when the override mechanism is used in certain cases (e.g.
  when the override does not directly implement the webview),
[ Olivier Tilloy ]
* Adjust the new tab view’s background colour to match the visual
  spec. (LP: #1389610)
* Clean up the AddressBar component, and convert a number of related
  autopilot tests to QML tests.
* Update dependency names for QML modules (but keep the old name as
  well for backward compatibility).

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Olivier Tilloy (osomon) wrote :

The following autopilot test is broken:

    webapp_container.tests.test_redirection_pattern.WebappContainerRedirectionPatternTestCase.test_browse_to_redirection_pattern_url

(it wasn’t caught by the CI job because it doesn’t run the webapp_container test suite yet, but I’ve asked CI to add it).

review: Needs Fixing
785. By Alberto Mardegan

Revert alias on dataPath

Aliases work only on ids, not on property names.
Import Ubuntu.Web so that dataLocation is defined.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Olivier Tilloy (osomon) wrote :

This looks good now, thanks!

review: Approve
786. By Alberto Mardegan

OA: never set cookie mode to persistent

Revision history for this message
Olivier Tilloy (osomon) wrote :

In this last change, is the "webContextSessionCookieMode" property on webappViewLoader effectively going to override the engine’s root context "webContextSessionCookieMode" property so that UbuntuWebContext pick it up correctly?

If so, the change looks ok to me, but a comment to explain that would be welcome, as it might seem like black magic to an external developer trying to understand the code.

787. By Alberto Mardegan

Add comment

788. By Alberto Mardegan

merge from trunk

[ CI bot ]
* Resync trunk
[ Ubuntu daily release ]
* New rebuild forced
[ Alexandre Abreu ]
* Make use of the hostMappingRules in oxide and expose it in the
  webcontext Improve container url AP tests with newly introduced
  hostmapping in oxide 1.3
* HTML5 apps are currently using a specific container/launcher as
  their runtime. They should use the webapp container instead. (LP:
  #1392281, #1388988)
[ Olivier Tilloy ]
* Update translation template.
[ Michael Sheldon ]
* Add mimetype and file extension mappings for the new EBooks
  ContentType. (LP: #1383732)
[ Olivier Tilloy ]
* Update runtime dependencies of -autopilot packages. Now that
  autopilot has been removed from touch images, autopilot-touch is
  what we should depend on to ensure all dependencies are correctly
  installed prior to running tests using phablet-test-run.
* Factor the security certificate details popover out of the
  AddressBar component, for improved maintainability.
* Simplify quite a bit the machinery needed to set up the QML tests.
* Always load the webview for a new tab right away. (LP: #1391609)
* Set a stroke color on toolbar buttons. (LP: #1351200)
* Add a sanity unit test that runs flake8 on the autopilot tests code.
* No-change rebuild against Qt 5.3.2.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/app/webcontainer/AccountsPage.qml'
2--- src/app/webcontainer/AccountsPage.qml 2014-08-21 15:15:21 +0000
3+++ src/app/webcontainer/AccountsPage.qml 2014-11-25 15:01:18 +0000
4@@ -25,12 +25,10 @@
5
6 property alias accountProvider: accountsLogin.accountProvider
7 property alias applicationName: accountsLogin.applicationName
8- property var webappCookieStore: null
9- property var onlineAccountStoreComponent: null
10-
11- signal done()
12-
13- visible: false
14+
15+ signal done(bool successful, var credentialsId)
16+
17+ visible: true
18 anchors.fill: parent
19
20 AccountsLoginPage {
21@@ -38,32 +36,10 @@
22
23 anchors.fill: parent
24
25- QtObject {
26- id: internal
27- function onMoved(result) {
28- webappCookieStore.moved.disconnect(internal.onMoved)
29- if (!result) {
30- console.error("Unable to move cookies")
31- }
32- accountsPage.done()
33- }
34- }
35-
36 onDone: {
37 if (!accountsPage.visible)
38 return
39- if (!credentialsId) {
40- accountsPage.done()
41- return
42- }
43-
44- if (webappCookieStore) {
45- var instance = onlineAccountStoreComponent.createObject(accountsLogin, { "accountId": credentialsId })
46- webappCookieStore.moved.connect(internal.onMoved)
47- webappCookieStore.moveFrom(instance)
48- } else {
49- accountsPage.done()
50- }
51+ accountsPage.done(credentialsId != null, credentialsId)
52 }
53 }
54 }
55
56=== modified file 'src/app/webcontainer/WebApp.qml'
57--- src/app/webcontainer/WebApp.qml 2014-11-19 17:16:38 +0000
58+++ src/app/webcontainer/WebApp.qml 2014-11-25 15:01:18 +0000
59@@ -40,6 +40,7 @@
60 property alias webviewOverrideFile: webview.webviewOverrideFile
61 property alias blockOpenExternalUrls: webview.blockOpenExternalUrls
62 property alias localUserAgentOverride: webview.localUserAgentOverride
63+ property alias dataPath: webview.dataPath
64 property alias runningLocalApplication: webview.runningLocalApplication
65
66 property bool backForwardButtonsVisible: false
67
68=== modified file 'src/app/webcontainer/WebViewImplOxide.qml'
69--- src/app/webcontainer/WebViewImplOxide.qml 2014-11-20 16:46:17 +0000
70+++ src/app/webcontainer/WebViewImplOxide.qml 2014-11-25 15:01:18 +0000
71@@ -34,6 +34,7 @@
72 property string localUserAgentOverride: ""
73 property var webappUrlPatterns: null
74 property string popupRedirectionUrlPrefixPattern: ""
75+ property url dataPath
76
77 // Mostly used for testing & avoid external urls to
78 // "leak" in the default browser
79@@ -47,6 +48,10 @@
80
81 currentWebview: webview
82
83+ context: WebContext {
84+ dataPath: webview.dataPath
85+ }
86+
87 preferences.allowFileAccessFromFileUrls: runningLocalApplication
88 preferences.allowUniversalAccessFromFileUrls: runningLocalApplication
89
90
91=== modified file 'src/app/webcontainer/WebViewImplWebkit.qml'
92--- src/app/webcontainer/WebViewImplWebkit.qml 2014-11-12 21:24:10 +0000
93+++ src/app/webcontainer/WebViewImplWebkit.qml 2014-11-25 15:01:18 +0000
94@@ -35,6 +35,7 @@
95 property var webappUrlPatterns: null
96 property string localUserAgentOverride: ""
97 property string popupRedirectionUrlPrefixPattern: ""
98+ property url dataPath // unused
99 property bool runningLocalApplication: false
100
101 function getUAString() {
102
103=== modified file 'src/app/webcontainer/WebappContainerWebview.qml'
104--- src/app/webcontainer/WebappContainerWebview.qml 2014-11-13 00:05:18 +0000
105+++ src/app/webcontainer/WebappContainerWebview.qml 2014-11-25 15:01:18 +0000
106@@ -30,6 +30,7 @@
107 property bool withOxide: false
108 property bool developerExtrasEnabled: false
109 property string webappName: ""
110+ property url dataPath
111 property var currentWebview: webappContainerWebViewLoader.item ?
112 webappContainerWebViewLoader.item.currentWebview
113 : null
114@@ -44,9 +45,10 @@
115 id: webappContainerWebViewLoader
116 objectName: "containerWebviewLoader"
117 anchors.fill: parent
118- asynchronous: true
119 }
120
121+ onUrlChanged: if (webappContainerWebViewLoader.item) webappContainerWebViewLoader.item.url = url
122+
123 Component.onCompleted: {
124 var webappEngineSource =
125 withOxide ?
126@@ -65,6 +67,7 @@
127 { localUserAgentOverride: containerWebview.localUserAgentOverride
128 , url: containerWebview.url
129 , webappName: containerWebview.webappName
130+ , dataPath: dataPath
131 , webappUrlPatterns: containerWebview.webappUrlPatterns
132 , developerExtrasEnabled: containerWebview.developerExtrasEnabled
133 , popupRedirectionUrlPrefixPattern: containerWebview.popupRedirectionUrlPrefixPattern
134
135=== modified file 'src/app/webcontainer/chrome-cookie-store.cpp'
136--- src/app/webcontainer/chrome-cookie-store.cpp 2014-09-18 13:37:07 +0000
137+++ src/app/webcontainer/chrome-cookie-store.cpp 2014-11-25 15:01:18 +0000
138@@ -33,19 +33,6 @@
139 this, SLOT(oxideCookiesUpdated(const QList<QNetworkCookie>&)));
140 }
141
142-void ChromeCookieStore::setHomepage(const QUrl& homepage) {
143- if (homepage == m_homepage)
144- return;
145-
146- m_homepage = homepage;
147-
148- emit homepageChanged();
149-}
150-
151-QUrl ChromeCookieStore::homepage() const {
152- return m_homepage;
153-}
154-
155 void ChromeCookieStore::setOxideStoreBackend(QObject* backend)
156 {
157 m_cookieHelper->setOxideStoreBackend(backend);
158
159=== modified file 'src/app/webcontainer/chrome-cookie-store.h'
160--- src/app/webcontainer/chrome-cookie-store.h 2014-09-18 13:37:07 +0000
161+++ src/app/webcontainer/chrome-cookie-store.h 2014-11-25 15:01:18 +0000
162@@ -30,7 +30,6 @@
163 {
164 Q_OBJECT
165
166- Q_PROPERTY(QUrl homepage READ homepage WRITE setHomepage NOTIFY homepageChanged)
167 Q_PROPERTY(QString dbPath READ dbPath WRITE setDbPath NOTIFY dbPathChanged)
168 Q_PROPERTY(QObject* oxideStoreBackend READ oxideStoreBackend WRITE setOxideStoreBackend NOTIFY oxideStoreBackendChanged)
169
170@@ -41,10 +40,6 @@
171 void setDbPath(const QString& path);
172 QString dbPath() const;
173
174- // dbpaths
175- void setHomepage(const QUrl& path);
176- QUrl homepage() const;
177-
178 // oxideStoreBackend
179 void setOxideStoreBackend(QObject* backend);
180 QObject* oxideStoreBackend() const;
181@@ -55,7 +50,6 @@
182 Q_SIGNALS:
183 void dbPathChanged();
184 void oxideStoreBackendChanged();
185- void homepageChanged();
186
187 private Q_SLOTS:
188 void oxideCookiesReceived(int requestId, const QVariant& cookies);
189@@ -67,7 +61,6 @@
190
191 private:
192 OxideCookieHelper* m_cookieHelper;
193- QUrl m_homepage;
194 QString m_dbPath;
195 };
196
197
198=== modified file 'src/app/webcontainer/cookie-store.cpp'
199--- src/app/webcontainer/cookie-store.cpp 2014-08-26 09:49:32 +0000
200+++ src/app/webcontainer/cookie-store.cpp 2014-11-25 15:01:18 +0000
201@@ -91,8 +91,20 @@
202 if (Q_UNLIKELY(!request))
203 return;
204
205+ QDateTime lastRemoteCookieUpdate =
206+ request->_cookieStore->lastUpdateTimeStamp();
207+ QDateTime lastLocalCookieUpdate = lastUpdateTimeStamp();
208+
209 delete request;
210
211+ if (lastRemoteCookieUpdate.isValid() &&
212+ lastLocalCookieUpdate.isValid() &&
213+ (lastRemoteCookieUpdate < lastLocalCookieUpdate))
214+ {
215+ Q_EMIT moved(false);
216+ return;
217+ }
218+
219 connect(this, &CookieStore::cookiesSet,
220 this, &CookieStore::moved);
221
222@@ -104,26 +116,6 @@
223 if (Q_UNLIKELY(!store))
224 return;
225
226- QDateTime lastRemoteCookieUpdate = store->lastUpdateTimeStamp();
227- QDateTime lastLocalCookieUpdate = lastUpdateTimeStamp();
228-
229- // Disabled for now since.
230- // There is an obvious race if the WebView is instanciated
231- // (since it creates a cookies db file at creation time).
232- // But when delaying the creation, only using the WebContext to
233- // access the cookieManager, and manually creating a cookies db file
234- // if none is found (since the cookie manager does not create one
235- // when setting its cookies), something fails.
236-#if 0
237- if (lastRemoteCookieUpdate.isValid() &&
238- lastLocalCookieUpdate.isValid() &&
239- (lastRemoteCookieUpdate < lastLocalCookieUpdate))
240- {
241- Q_EMIT moved(false);
242- return;
243- }
244-#endif
245-
246 CookieStoreRequest* storeRequest = new CookieStoreRequest(store);
247 _currentStoreRequests.insert(storeRequest, true);
248
249
250=== modified file 'src/app/webcontainer/online-accounts-cookie-store.cpp'
251--- src/app/webcontainer/online-accounts-cookie-store.cpp 2014-08-05 00:25:20 +0000
252+++ src/app/webcontainer/online-accounts-cookie-store.cpp 2014-11-25 15:01:18 +0000
253@@ -116,15 +116,14 @@
254
255 if (arguments.count() > 1)
256 {
257- QDateTime t;
258- QVariant timeStampVariant(arguments.at(1));
259- if (timeStampVariant.canConvert(QMetaType::LongLong))
260+ qint64 timeStamp = arguments.at(1).toLongLong();
261+ if (timeStamp != 0)
262 {
263 qDebug() << "Got a cookie timestamp of"
264- << arguments.at(1).toLongLong()
265+ << timeStamp
266 << "from Online Accounts DBUS cookiesForIdentity() call.";
267
268- t.fromMSecsSinceEpoch(arguments.at(1).toLongLong() * 1000);
269+ QDateTime t = QDateTime::fromMSecsSinceEpoch(timeStamp * 1000);
270 updateLastUpdateTimestamp(t);
271 }
272 }
273
274=== modified file 'src/app/webcontainer/oxide-cookie-helper.cpp'
275--- src/app/webcontainer/oxide-cookie-helper.cpp 2014-10-03 11:47:36 +0000
276+++ src/app/webcontainer/oxide-cookie-helper.cpp 2014-11-25 15:01:18 +0000
277@@ -53,6 +53,7 @@
278 m_backend(0),
279 q_ptr(q)
280 {
281+ qRegisterMetaType<QList<QNetworkCookie> >();
282 }
283
284 void OxideCookieHelperPrivate::setCookies(const QList<QNetworkCookie>& cookies)
285@@ -75,7 +76,7 @@
286 /* We don't simply use Q_EMIT because we want the signal to be emitted
287 * asynchronously */
288 QMetaObject::invokeMethod(q, "cookiesSet", Qt::QueuedConnection,
289- Q_ARG(const QList<QNetworkCookie>&, cookies));
290+ Q_ARG(QList<QNetworkCookie>, cookies));
291 return;
292 }
293
294@@ -119,8 +120,8 @@
295 QMetaObject::invokeMethod(m_backend, "setNetworkCookies",
296 Qt::DirectConnection,
297 Q_RETURN_ARG(int, requestId),
298- Q_ARG(const QUrl&, url),
299- Q_ARG(const QList<QNetworkCookie>&, it.value()));
300+ Q_ARG(QUrl, url),
301+ Q_ARG(QList<QNetworkCookie>, it.value()));
302 if (Q_UNLIKELY(requestId == -1)) {
303 m_failedCookies.append(cookiesWithDomain(it.value(), url.host()));
304 } else {
305@@ -133,7 +134,7 @@
306 /* We don't simply use Q_EMIT because we want the signal to be emitted
307 * asynchronously */
308 QMetaObject::invokeMethod(q, "cookiesSet", Qt::QueuedConnection,
309- Q_ARG(const QList<QNetworkCookie>&, m_failedCookies));
310+ Q_ARG(QList<QNetworkCookie>, m_failedCookies));
311 }
312 }
313
314
315=== modified file 'src/app/webcontainer/webapp-container.qml'
316--- src/app/webcontainer/webapp-container.qml 2014-11-12 21:24:10 +0000
317+++ src/app/webcontainer/webapp-container.qml 2014-11-25 15:01:18 +0000
318@@ -19,6 +19,7 @@
319 import QtQuick 2.0
320 import Ubuntu.Components 1.1
321 import Ubuntu.UnityWebApps 0.1 as UnityWebApps
322+import Ubuntu.Web 0.2
323 import webcontainer.private 0.1
324 import ".."
325
326@@ -43,64 +44,60 @@
327 property string localUserAgentOverride: ""
328 property bool blockOpenExternalUrls: false
329
330- currentWebview: browser.currentWebview
331+ currentWebview: webappViewLoader.item ? webappViewLoader.item.currentWebview : null
332
333 property bool runningLocalApplication: false
334
335 title: getWindowTitle()
336
337 function getWindowTitle() {
338+ var webappViewTitle = webappViewLoader.item ? webappViewLoader.item.title : ""
339 if (typeof(webappName) === 'string' && webappName.length !== 0) {
340 return webappName
341- } else if (browser.title) {
342+ } else if (webappViewTitle) {
343 // TRANSLATORS: %1 refers to the current page’s title
344- return i18n.tr("%1 - Ubuntu Web Browser").arg(browser.title)
345+ return i18n.tr("%1 - Ubuntu Web Browser").arg(webappViewTitle)
346 } else {
347 return i18n.tr("Ubuntu Web Browser")
348 }
349 }
350
351- WebApp {
352- id: browser
353-
354- // Initially set as non visible to leave a chance
355- // for the OA dialog to appear
356- visible: false
357-
358- url: accountProvider.length === 0 ? root.url : ""
359-
360- chromeVisible: root.chromeVisible
361- backForwardButtonsVisible: root.backForwardButtonsVisible
362- developerExtrasEnabled: root.developerExtrasEnabled
363- oxide: root.oxide
364- webappModelSearchPath: root.webappModelSearchPath
365- webappUrlPatterns: root.webappUrlPatterns
366- blockOpenExternalUrls: root.blockOpenExternalUrls
367-
368- popupRedirectionUrlPrefixPattern: root.popupRedirectionUrlPrefixPattern
369-
370- localUserAgentOverride: getLocalUserAgentOverrideIfAny()
371-
372- runningLocalApplication: root.runningLocalApplication
373- webviewOverrideFile: root.webviewOverrideFile
374-
375- anchors.fill: parent
376-
377- webbrowserWindow: webbrowserWindowProxy
378-
379- onWebappNameChanged: {
380- if (root.webappName !== browser.webappName) {
381- root.webappName = browser.webappName;
382- root.title = getWindowTitle();
383+ Component {
384+ id: webappViewComponent
385+
386+ WebApp {
387+ id: browser
388+
389+ url: accountProvider.length !== 0 ? "" : root.url
390+
391+ dataPath: webappDataLocation
392+ webappName: root.webappName
393+ chromeVisible: root.chromeVisible
394+ backForwardButtonsVisible: root.backForwardButtonsVisible
395+ developerExtrasEnabled: root.developerExtrasEnabled
396+ oxide: root.oxide
397+ webappModelSearchPath: root.webappModelSearchPath
398+ webappUrlPatterns: root.webappUrlPatterns
399+ blockOpenExternalUrls: root.blockOpenExternalUrls
400+
401+ popupRedirectionUrlPrefixPattern: root.popupRedirectionUrlPrefixPattern
402+
403+ localUserAgentOverride: getLocalUserAgentOverrideIfAny()
404+
405+ runningLocalApplication: root.runningLocalApplication
406+ webviewOverrideFile: root.webviewOverrideFile
407+
408+ anchors.fill: parent
409+
410+ webbrowserWindow: webbrowserWindowProxy
411+
412+ onWebappNameChanged: {
413+ if (root.webappName !== browser.webappName) {
414+ root.webappName = browser.webappName;
415+ root.title = getWindowTitle();
416+ }
417 }
418 }
419-
420- onCurrentWebviewChanged: {
421- if (currentWebview)
422- root.updateCurrentView()
423- }
424-
425- Component.onCompleted: i18n.domain = "webbrowser-app"
426 }
427
428 function getLocalUserAgentOverrideIfAny() {
429@@ -139,17 +136,72 @@
430 }
431 }
432
433+ Loader {
434+ id: webappViewLoader
435+ anchors.fill: parent
436+
437+ property var credentialsId: null
438+ property var webContextSessionCookieMode: null
439+ property var webappDataLocation: credentialsId != null ? dataLocation + "/id-" + credentialsId : dataLocation
440+ }
441+
442+ function onCookiesMoved(result) {
443+ if (__webappCookieStore) {
444+ __webappCookieStore.moved.disconnect(onCookiesMoved)
445+ }
446+ if (!result) {
447+ console.log("Cookies were not moved")
448+ }
449+ webappViewLoader.item.url = root.url
450+ }
451+
452+ function moveCookies(credentialsId) {
453+ if (!__webappCookieStore) {
454+ var context = webappViewLoader.item.currentWebview.context
455+ __webappCookieStore = oxideCookieStoreComponent.createObject(this, {
456+ "oxideStoreBackend": context.cookieManager,
457+ "dbPath": context.dataPath + "/cookies.sqlite"
458+ })
459+ }
460+
461+ var storeComponent = localCookieStoreDbPath.length !== 0 ?
462+ localCookieStoreComponent : onlineAccountStoreComponent
463+
464+ var instance = storeComponent.createObject(root, { "accountId": credentialsId })
465+ __webappCookieStore.moved.connect(onCookiesMoved)
466+ __webappCookieStore.moveFrom(instance)
467+ }
468+
469 Connections {
470 target: accountsPageComponentLoader.item
471- onDone: loadWebAppView()
472+ onDone: {
473+ if (successful) {
474+ webappViewLoader.loaded.connect(function () {
475+ if (webappViewLoader.status == Loader.Ready) {
476+ moveCookies(webappViewLoader.credentialsId)
477+ }
478+ });
479+ webappViewLoader.credentialsId = credentialsId
480+ // If we need to preserve session cookies, make sure that the
481+ // mode is "restored" and not "persistent", or the cookies
482+ // transferred from OA would be lost.
483+ // We check if the webContextSessionCookieMode is defined and, if so,
484+ // we override it in the webapp loader.
485+ if (typeof webContextSessionCookieMode === "string") {
486+ webappViewLoader.webContextSessionCookieMode = "restored"
487+ }
488+
489+ webappViewLoader.sourceComponent = webappViewComponent
490+ }
491+ else {
492+ loadWebAppView()
493+ }
494+ }
495 }
496
497 Component {
498 id: oxideCookieStoreComponent
499 ChromeCookieStore {
500- dbPath: dataLocation + "/cookies.sqlite"
501- homepage: root.url
502- oxideStoreBackend: browser.currentWebview ? browser.currentWebview.context.cookieManager : null
503 }
504 }
505
506@@ -160,57 +212,47 @@
507 }
508 }
509
510- Component {
511- id: onlineAccountStoreComponent
512- OnlineAccountsCookieStore { }
513- }
514+ Component.onCompleted: {
515+ i18n.domain = "webbrowser-app"
516
517- function updateCurrentView() {
518 // check if we are to display the login view
519 // or directly switch to the webapp view
520- if (accountProvider.length !== 0 && !__webappCookieStore && oxide) {
521+ if (accountProvider.length !== 0 && oxide) {
522 loadLoginView();
523 } else {
524 loadWebAppView();
525 }
526 }
527
528+ Component {
529+ id: onlineAccountStoreComponent
530+ OnlineAccountsCookieStore { }
531+ }
532+
533 function loadLoginView() {
534- if (!__webappCookieStore) {
535- __webappCookieStore = oxideCookieStoreComponent.createObject(this)
536- }
537 accountsPageComponentLoader.setSource("AccountsPage.qml", {
538 "accountProvider": accountProvider,
539 "applicationName": unversionedAppId,
540- "webappCookieStore": __webappCookieStore,
541- "onlineAccountStoreComponent": localCookieStoreDbPath.length !== 0 ?
542- localCookieStoreComponent : onlineAccountStoreComponent
543 })
544 }
545
546 function loadWebAppView() {
547 if (accountsPageComponentLoader.item)
548 accountsPageComponentLoader.item.visible = false
549- browser.visible = true;
550- if (browser.currentWebview) {
551- browser.currentWebview.visible = true;
552- browser.webappName = root.webappName;
553
554- // As we use StateSaver to restore the URL, we need to check first if
555- // it has not been set previously before setting the URL to the default property
556- // homepage.
557- var current_url = browser.currentWebview.url.toString();
558- if (!current_url || current_url.length === 0) {
559- browser.currentWebview.url = root.url;
560+ webappViewLoader.loaded.connect(function () {
561+ if (webappViewLoader.status === Loader.Ready) {
562+ // As we use StateSaver to restore the URL, we need to check first if
563+ // it has not been set previously before setting the URL to the default property
564+ // homepage.
565+ var webView = webappViewLoader.item.currentWebview
566+ var current_url = webView.url.toString();
567+ if (!current_url || current_url.length === 0) {
568+ webView.url = root.url
569+ }
570 }
571- }
572- }
573-
574- function updateBrowserUrl(url) {
575- root.url = url;
576- if (browser.currentWebview) {
577- browser.currentWebview.url = url;
578- }
579+ });
580+ webappViewLoader.sourceComponent = webappViewComponent
581 }
582
583 // Handle runtime requests to open urls as defined
584@@ -223,7 +265,7 @@
585 target: UriHandler
586 onOpened: {
587 // only consider the first one (if multiple)
588- if (uris.length === 0 || !browser.currentWebview) {
589+ if (uris.length === 0 || !root.currentWebview) {
590 return;
591 }
592 var requestedUrl = uris[0].toString();
593@@ -232,7 +274,9 @@
594 && requestedUrl.match(popupRedirectionUrlPrefixPattern)) {
595 return;
596 }
597- updateBrowserUrl(requestedUrl);
598+
599+ root.url = requestedUrl
600+ root.currentWebview.url = requestedUrl
601 }
602 }
603 }

Subscribers

People subscribed via source and target branches

to status/vote changes: