Add back KWallet support to Konqueror
ClosedPublic

Authored by stefanocrocco on Jan 29 2018, 2:56 PM.

Details

Summary

Added back the ability to store user names and passwords to KWallet and automatically fill them when loading a page.

I copied the files kwebwallet.cpp and kwebwallet.h from the KDEWebKit framework and modified it to adapt to QWebEngine. In particular, I needed to modify the way form data is passed from javascript to C++ serializing it using JSON and read it back using QJsonDocument. Also, since QWebEnginePage doesn't allow to access frames from the C++ side, I needed to remove all the code dealing with recurisve searches and implement it in javascript.

As the old code, this intentionally doesn't work with input elements with the autocomplete attribute set to false.

I've not modified the copyright information in the files I copied from KDEWebKit as I don't know which is the correct way to do so: I must make clear my files are based on the work on other people but at the same time that I've changed them: how do I do this?

Test Plan

I tried to access several sites requiring a login in, asking Konqueror to save the password, then logging out and visiting the page again. Except when the autocomplete attribute was false (checked by looking at the html code), Konqueror always saved and restored login information correctly.

Diff Detail

Repository
R226 Konqueror
Lint
Lint Skipped
Unit
Unit Tests Skipped
stefanocrocco requested review of this revision.Jan 29 2018, 2:56 PM
stefanocrocco created this revision.
stefanocrocco edited the summary of this revision. (Show Details)Jan 29 2018, 3:04 PM
dfaure requested changes to this revision.Feb 3 2018, 9:58 AM

About copyright information: just add your own copyright line below the existing one(s) in files that you modified (with more than trivial changes like indentation, spelling, naming...)

webenginepart/src/webenginepart.cpp
321

this code looks like it was duplicated by....

332

why the old form here (SIGNAL() / SLOT()) and the new form for connect?

340

... this code.

Should the first one be removed?
I can't tell because context is missing. Please use arc diff (arcanist) to upload your future commits.

480

coding style: newline after if(wallet), I'd recommend curly braces too { ... } even for one-line statements, matching the KF5 coding style.

787

one space too many before ||

webenginepart/src/webenginepartfactory.cpp
24

is this include useful? there's no other change to the cpp file, so it looks unnecessary

webenginepart/src/webenginewallet.cpp
41

#define is so 1990 :-)

You can make this proper C++ (and more readable) by doing

static const char s_fillableFormElementExtractorJs[] = "(function(){"
    "..."
    "...";
102

same here (const char [])

136

This code makes no sense to me. QWebEnginePage isn't a QWidget, you can't ever cast page to a QWidget.

187

make it const, so that all the map[...] below don't detach.

433

should probably be removed

466

duplicated line

webenginepart/src/webenginewallet.h
63

QVector would be much better, since WebField is bigger than a pointer, which means QList has to allocate memory (with new) for every item in the list.

69

QVector here as well

72

typo, Ein -> En

227

Why are there virtual methods in this class? Who/what reimplements it?

I don't like "virtual just in case" because it makes refactoring harder, one has to look for subclasses or assume any method can be reimplemented independently, before changing anything.

This revision now requires changes to proceed.Feb 3 2018, 9:58 AM

Made all required changes

stefanocrocco marked 14 inline comments as done.Feb 4 2018, 10:16 AM

Removed another virtual I missed in the previous update

stefanocrocco marked 2 inline comments as done.Feb 4 2018, 10:20 AM
dfaure requested changes to this revision.Feb 4 2018, 1:58 PM
dfaure added inline comments.
webenginepart/src/webenginewallet.cpp
401

If the parent object is always a page (as seems to be the case where "new WebEngineWallet" is done), this code is useless... The caller already makes a best effort at determining WId, so it seems to be this whole if (!wid) code can be removed, no?

This revision now requires changes to proceed.Feb 4 2018, 1:58 PM

Removed the attempt to guess the WId from WebEngineWallet constructor

stefanocrocco marked an inline comment as done.Feb 4 2018, 2:50 PM
dfaure accepted this revision.Feb 4 2018, 5:03 PM
This revision is now accepted and ready to land.Feb 4 2018, 5:03 PM
This revision was automatically updated to reflect the committed changes.