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
=== 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-11-25 15:01:18 +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-11-19 17:16:38 +0000
+++ src/app/webcontainer/WebApp.qml 2014-11-25 15:01:18 +0000
@@ -40,6 +40,7 @@
40 property alias webviewOverrideFile: webview.webviewOverrideFile40 property alias webviewOverrideFile: webview.webviewOverrideFile
41 property alias blockOpenExternalUrls: webview.blockOpenExternalUrls41 property alias blockOpenExternalUrls: webview.blockOpenExternalUrls
42 property alias localUserAgentOverride: webview.localUserAgentOverride42 property alias localUserAgentOverride: webview.localUserAgentOverride
43 property alias dataPath: webview.dataPath
43 property alias runningLocalApplication: webview.runningLocalApplication44 property alias runningLocalApplication: webview.runningLocalApplication
4445
45 property bool backForwardButtonsVisible: false46 property bool backForwardButtonsVisible: false
4647
=== modified file 'src/app/webcontainer/WebViewImplOxide.qml'
--- src/app/webcontainer/WebViewImplOxide.qml 2014-11-20 16:46:17 +0000
+++ src/app/webcontainer/WebViewImplOxide.qml 2014-11-25 15:01:18 +0000
@@ -34,6 +34,7 @@
34 property string localUserAgentOverride: ""34 property string localUserAgentOverride: ""
35 property var webappUrlPatterns: null35 property var webappUrlPatterns: null
36 property string popupRedirectionUrlPrefixPattern: ""36 property string popupRedirectionUrlPrefixPattern: ""
37 property url dataPath
3738
38 // Mostly used for testing & avoid external urls to39 // Mostly used for testing & avoid external urls to
39 // "leak" in the default browser40 // "leak" in the default browser
@@ -47,6 +48,10 @@
4748
48 currentWebview: webview49 currentWebview: webview
4950
51 context: WebContext {
52 dataPath: webview.dataPath
53 }
54
50 preferences.allowFileAccessFromFileUrls: runningLocalApplication55 preferences.allowFileAccessFromFileUrls: runningLocalApplication
51 preferences.allowUniversalAccessFromFileUrls: runningLocalApplication56 preferences.allowUniversalAccessFromFileUrls: runningLocalApplication
5257
5358
=== modified file 'src/app/webcontainer/WebViewImplWebkit.qml'
--- src/app/webcontainer/WebViewImplWebkit.qml 2014-11-12 21:24:10 +0000
+++ src/app/webcontainer/WebViewImplWebkit.qml 2014-11-25 15:01:18 +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 popupRedirectionUrlPrefixPattern: ""37 property string popupRedirectionUrlPrefixPattern: ""
38 property url dataPath // unused
38 property bool runningLocalApplication: false39 property bool runningLocalApplication: false
3940
40 function getUAString() {41 function getUAString() {
4142
=== modified file 'src/app/webcontainer/WebappContainerWebview.qml'
--- src/app/webcontainer/WebappContainerWebview.qml 2014-11-13 00:05:18 +0000
+++ src/app/webcontainer/WebappContainerWebview.qml 2014-11-25 15:01:18 +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.item ?34 property var currentWebview: webappContainerWebViewLoader.item ?
34 webappContainerWebViewLoader.item.currentWebview35 webappContainerWebViewLoader.item.currentWebview
35 : null36 : null
@@ -44,9 +45,10 @@
44 id: webappContainerWebViewLoader45 id: webappContainerWebViewLoader
45 objectName: "containerWebviewLoader"46 objectName: "containerWebviewLoader"
46 anchors.fill: parent47 anchors.fill: parent
47 asynchronous: true
48 }48 }
4949
50 onUrlChanged: if (webappContainerWebViewLoader.item) webappContainerWebViewLoader.item.url = url
51
50 Component.onCompleted: {52 Component.onCompleted: {
51 var webappEngineSource =53 var webappEngineSource =
52 withOxide ?54 withOxide ?
@@ -65,6 +67,7 @@
65 { localUserAgentOverride: containerWebview.localUserAgentOverride67 { localUserAgentOverride: containerWebview.localUserAgentOverride
66 , url: containerWebview.url68 , url: containerWebview.url
67 , webappName: containerWebview.webappName69 , webappName: containerWebview.webappName
70 , dataPath: dataPath
68 , webappUrlPatterns: containerWebview.webappUrlPatterns71 , webappUrlPatterns: containerWebview.webappUrlPatterns
69 , developerExtrasEnabled: containerWebview.developerExtrasEnabled72 , developerExtrasEnabled: containerWebview.developerExtrasEnabled
70 , popupRedirectionUrlPrefixPattern: containerWebview.popupRedirectionUrlPrefixPattern73 , popupRedirectionUrlPrefixPattern: containerWebview.popupRedirectionUrlPrefixPattern
7174
=== 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-11-25 15:01:18 +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-11-25 15:01:18 +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-11-25 15:01:18 +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-11-25 15:01:18 +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-11-25 15:01:18 +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.qml'
--- src/app/webcontainer/webapp-container.qml 2014-11-12 21:24:10 +0000
+++ src/app/webcontainer/webapp-container.qml 2014-11-25 15:01:18 +0000
@@ -19,6 +19,7 @@
19import QtQuick 2.019import QtQuick 2.0
20import Ubuntu.Components 1.120import Ubuntu.Components 1.1
21import Ubuntu.UnityWebApps 0.1 as UnityWebApps21import Ubuntu.UnityWebApps 0.1 as UnityWebApps
22import Ubuntu.Web 0.2
22import webcontainer.private 0.123import webcontainer.private 0.1
23import ".."24import ".."
2425
@@ -43,64 +44,60 @@
43 property string localUserAgentOverride: ""44 property string localUserAgentOverride: ""
44 property bool blockOpenExternalUrls: false45 property bool blockOpenExternalUrls: false
4546
46 currentWebview: browser.currentWebview47 currentWebview: webappViewLoader.item ? webappViewLoader.item.currentWebview : null
4748
48 property bool runningLocalApplication: false49 property bool runningLocalApplication: false
4950
50 title: getWindowTitle()51 title: getWindowTitle()
5152
52 function getWindowTitle() {53 function getWindowTitle() {
54 var webappViewTitle = webappViewLoader.item ? webappViewLoader.item.title : ""
53 if (typeof(webappName) === 'string' && webappName.length !== 0) {55 if (typeof(webappName) === 'string' && webappName.length !== 0) {
54 return webappName56 return webappName
55 } else if (browser.title) {57 } else if (webappViewTitle) {
56 // TRANSLATORS: %1 refers to the current page’s title58 // TRANSLATORS: %1 refers to the current page’s title
57 return i18n.tr("%1 - Ubuntu Web Browser").arg(browser.title)59 return i18n.tr("%1 - Ubuntu Web Browser").arg(webappViewTitle)
58 } else {60 } else {
59 return i18n.tr("Ubuntu Web Browser")61 return i18n.tr("Ubuntu Web Browser")
60 }62 }
61 }63 }
6264
63 WebApp {65 Component {
64 id: browser66 id: webappViewComponent
6567
66 // Initially set as non visible to leave a chance68 WebApp {
67 // for the OA dialog to appear69 id: browser
68 visible: false70
6971 url: accountProvider.length !== 0 ? "" : root.url
70 url: accountProvider.length === 0 ? root.url : ""72
7173 dataPath: webappDataLocation
72 chromeVisible: root.chromeVisible74 webappName: root.webappName
73 backForwardButtonsVisible: root.backForwardButtonsVisible75 chromeVisible: root.chromeVisible
74 developerExtrasEnabled: root.developerExtrasEnabled76 backForwardButtonsVisible: root.backForwardButtonsVisible
75 oxide: root.oxide77 developerExtrasEnabled: root.developerExtrasEnabled
76 webappModelSearchPath: root.webappModelSearchPath78 oxide: root.oxide
77 webappUrlPatterns: root.webappUrlPatterns79 webappModelSearchPath: root.webappModelSearchPath
78 blockOpenExternalUrls: root.blockOpenExternalUrls80 webappUrlPatterns: root.webappUrlPatterns
7981 blockOpenExternalUrls: root.blockOpenExternalUrls
80 popupRedirectionUrlPrefixPattern: root.popupRedirectionUrlPrefixPattern82
8183 popupRedirectionUrlPrefixPattern: root.popupRedirectionUrlPrefixPattern
82 localUserAgentOverride: getLocalUserAgentOverrideIfAny()84
8385 localUserAgentOverride: getLocalUserAgentOverrideIfAny()
84 runningLocalApplication: root.runningLocalApplication86
85 webviewOverrideFile: root.webviewOverrideFile87 runningLocalApplication: root.runningLocalApplication
8688 webviewOverrideFile: root.webviewOverrideFile
87 anchors.fill: parent89
8890 anchors.fill: parent
89 webbrowserWindow: webbrowserWindowProxy91
9092 webbrowserWindow: webbrowserWindowProxy
91 onWebappNameChanged: {93
92 if (root.webappName !== browser.webappName) {94 onWebappNameChanged: {
93 root.webappName = browser.webappName;95 if (root.webappName !== browser.webappName) {
94 root.title = getWindowTitle();96 root.webappName = browser.webappName;
97 root.title = getWindowTitle();
98 }
95 }99 }
96 }100 }
97
98 onCurrentWebviewChanged: {
99 if (currentWebview)
100 root.updateCurrentView()
101 }
102
103 Component.onCompleted: i18n.domain = "webbrowser-app"
104 }101 }
105102
106 function getLocalUserAgentOverrideIfAny() {103 function getLocalUserAgentOverrideIfAny() {
@@ -139,17 +136,72 @@
139 }136 }
140 }137 }
141138
139 Loader {
140 id: webappViewLoader
141 anchors.fill: parent
142
143 property var credentialsId: null
144 property var webContextSessionCookieMode: null
145 property var webappDataLocation: credentialsId != null ? dataLocation + "/id-" + credentialsId : dataLocation
146 }
147
148 function onCookiesMoved(result) {
149 if (__webappCookieStore) {
150 __webappCookieStore.moved.disconnect(onCookiesMoved)
151 }
152 if (!result) {
153 console.log("Cookies were not moved")
154 }
155 webappViewLoader.item.url = root.url
156 }
157
158 function moveCookies(credentialsId) {
159 if (!__webappCookieStore) {
160 var context = webappViewLoader.item.currentWebview.context
161 __webappCookieStore = oxideCookieStoreComponent.createObject(this, {
162 "oxideStoreBackend": context.cookieManager,
163 "dbPath": context.dataPath + "/cookies.sqlite"
164 })
165 }
166
167 var storeComponent = localCookieStoreDbPath.length !== 0 ?
168 localCookieStoreComponent : onlineAccountStoreComponent
169
170 var instance = storeComponent.createObject(root, { "accountId": credentialsId })
171 __webappCookieStore.moved.connect(onCookiesMoved)
172 __webappCookieStore.moveFrom(instance)
173 }
174
142 Connections {175 Connections {
143 target: accountsPageComponentLoader.item176 target: accountsPageComponentLoader.item
144 onDone: loadWebAppView()177 onDone: {
178 if (successful) {
179 webappViewLoader.loaded.connect(function () {
180 if (webappViewLoader.status == Loader.Ready) {
181 moveCookies(webappViewLoader.credentialsId)
182 }
183 });
184 webappViewLoader.credentialsId = credentialsId
185 // If we need to preserve session cookies, make sure that the
186 // mode is "restored" and not "persistent", or the cookies
187 // transferred from OA would be lost.
188 // We check if the webContextSessionCookieMode is defined and, if so,
189 // we override it in the webapp loader.
190 if (typeof webContextSessionCookieMode === "string") {
191 webappViewLoader.webContextSessionCookieMode = "restored"
192 }
193
194 webappViewLoader.sourceComponent = webappViewComponent
195 }
196 else {
197 loadWebAppView()
198 }
199 }
145 }200 }
146201
147 Component {202 Component {
148 id: oxideCookieStoreComponent203 id: oxideCookieStoreComponent
149 ChromeCookieStore {204 ChromeCookieStore {
150 dbPath: dataLocation + "/cookies.sqlite"
151 homepage: root.url
152 oxideStoreBackend: browser.currentWebview ? browser.currentWebview.context.cookieManager : null
153 }205 }
154 }206 }
155207
@@ -160,57 +212,47 @@
160 }212 }
161 }213 }
162214
163 Component {215 Component.onCompleted: {
164 id: onlineAccountStoreComponent216 i18n.domain = "webbrowser-app"
165 OnlineAccountsCookieStore { }
166 }
167217
168 function updateCurrentView() {
169 // check if we are to display the login view218 // check if we are to display the login view
170 // or directly switch to the webapp view219 // or directly switch to the webapp view
171 if (accountProvider.length !== 0 && !__webappCookieStore && oxide) {220 if (accountProvider.length !== 0 && oxide) {
172 loadLoginView();221 loadLoginView();
173 } else {222 } else {
174 loadWebAppView();223 loadWebAppView();
175 }224 }
176 }225 }
177226
227 Component {
228 id: onlineAccountStoreComponent
229 OnlineAccountsCookieStore { }
230 }
231
178 function loadLoginView() {232 function loadLoginView() {
179 if (!__webappCookieStore) {
180 __webappCookieStore = oxideCookieStoreComponent.createObject(this)
181 }
182 accountsPageComponentLoader.setSource("AccountsPage.qml", {233 accountsPageComponentLoader.setSource("AccountsPage.qml", {
183 "accountProvider": accountProvider,234 "accountProvider": accountProvider,
184 "applicationName": unversionedAppId,235 "applicationName": unversionedAppId,
185 "webappCookieStore": __webappCookieStore,
186 "onlineAccountStoreComponent": localCookieStoreDbPath.length !== 0 ?
187 localCookieStoreComponent : onlineAccountStoreComponent
188 })236 })
189 }237 }
190238
191 function loadWebAppView() {239 function loadWebAppView() {
192 if (accountsPageComponentLoader.item)240 if (accountsPageComponentLoader.item)
193 accountsPageComponentLoader.item.visible = false241 accountsPageComponentLoader.item.visible = false
194 browser.visible = true;
195 if (browser.currentWebview) {
196 browser.currentWebview.visible = true;
197 browser.webappName = root.webappName;
198242
199 // As we use StateSaver to restore the URL, we need to check first if243 webappViewLoader.loaded.connect(function () {
200 // it has not been set previously before setting the URL to the default property 244 if (webappViewLoader.status === Loader.Ready) {
201 // homepage.245 // As we use StateSaver to restore the URL, we need to check first if
202 var current_url = browser.currentWebview.url.toString();246 // it has not been set previously before setting the URL to the default property
203 if (!current_url || current_url.length === 0) {247 // homepage.
204 browser.currentWebview.url = root.url;248 var webView = webappViewLoader.item.currentWebview
249 var current_url = webView.url.toString();
250 if (!current_url || current_url.length === 0) {
251 webView.url = root.url
252 }
205 }253 }
206 }254 });
207 }255 webappViewLoader.sourceComponent = webappViewComponent
208
209 function updateBrowserUrl(url) {
210 root.url = url;
211 if (browser.currentWebview) {
212 browser.currentWebview.url = url;
213 }
214 }256 }
215257
216 // Handle runtime requests to open urls as defined258 // Handle runtime requests to open urls as defined
@@ -223,7 +265,7 @@
223 target: UriHandler265 target: UriHandler
224 onOpened: {266 onOpened: {
225 // only consider the first one (if multiple)267 // only consider the first one (if multiple)
226 if (uris.length === 0 || !browser.currentWebview) {268 if (uris.length === 0 || !root.currentWebview) {
227 return;269 return;
228 }270 }
229 var requestedUrl = uris[0].toString();271 var requestedUrl = uris[0].toString();
@@ -232,7 +274,9 @@
232 && requestedUrl.match(popupRedirectionUrlPrefixPattern)) {274 && requestedUrl.match(popupRedirectionUrlPrefixPattern)) {
233 return;275 return;
234 }276 }
235 updateBrowserUrl(requestedUrl);277
278 root.url = requestedUrl
279 root.currentWebview.url = requestedUrl
236 }280 }
237 }281 }
238}282}

Subscribers

People subscribed via source and target branches

to status/vote changes: