1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 02:36:34 +01:00

[AutoFill] Show key icon only when password was actually filled in page.

If you have saved multiple passwords eg. for gmail.com, it will now
only show key icon when trying to login, instead of showing it all the
time on gmail.com (even after logging in).
This commit is contained in:
nowrep 2013-02-25 15:03:53 +01:00
parent 0ca121898d
commit 6cf3cb637c
3 changed files with 14 additions and 8 deletions

View File

@ -254,8 +254,10 @@ void AutoFill::updateEntry(const PageFormData &formData, const AutoFillData &upd
mApp->dbWriter()->executeQuery(query);
}
// If password was filled in the page, returns all saved passwords on this page
QList<AutoFillData> AutoFill::completePage(WebPage* page)
{
bool completed = false;
QList<AutoFillData> list;
if (!page) {
@ -273,7 +275,11 @@ QList<AutoFillData> AutoFill::completePage(WebPage* page)
const AutoFillData data = getFirstFormData(pageUrl);
PageFormCompleter completer(page);
completer.completePage(data.postData);
completed = completer.completePage(data.postData);
}
if (!completed) {
list.clear();
}
return list;

View File

@ -90,8 +90,10 @@ PageFormData PageFormCompleter::extractFormData(const QByteArray &postData) cons
return formData;
}
void PageFormCompleter::completePage(const QByteArray &data) const
// Returns if any data was actually filled in page
bool PageFormCompleter::completePage(const QByteArray &data) const
{
bool completed = false;
const QueryItems &queryItems = createQueryItems(data);
// Input types that are being completed
@ -105,11 +107,6 @@ void PageFormCompleter::completePage(const QByteArray &data) const
const QString &key = queryItems.at(i).first;
const QString &value = queryItems.at(i).second;
/* Is it really necessary?
key = QUrl::fromEncoded(key.toUtf8()).toString();
value = QUrl::fromEncoded(value.toUtf8()).toString();
*/
for (int i = 0; i < inputs.count(); i++) {
QWebElement element = inputs.at(i);
const QString &typeAttr = element.attribute("type");
@ -119,10 +116,13 @@ void PageFormCompleter::completePage(const QByteArray &data) const
}
if (key == element.attribute("name")) {
completed = true;
element.setAttribute("value", value);
}
}
}
return completed;
}
bool PageFormCompleter::queryItemsContains(const QueryItems &queryItems, const QString &attributeName,

View File

@ -41,7 +41,7 @@ public:
explicit PageFormCompleter(QWebPage* page);
PageFormData extractFormData(const QByteArray &postData) const;
void completePage(const QByteArray &data) const;
bool completePage(const QByteArray &data) const;
private:
typedef QPair<QString, QString> QueryItem;