mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +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:
parent
0ca121898d
commit
6cf3cb637c
@ -254,8 +254,10 @@ void AutoFill::updateEntry(const PageFormData &formData, const AutoFillData &upd
|
|||||||
mApp->dbWriter()->executeQuery(query);
|
mApp->dbWriter()->executeQuery(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If password was filled in the page, returns all saved passwords on this page
|
||||||
QList<AutoFillData> AutoFill::completePage(WebPage* page)
|
QList<AutoFillData> AutoFill::completePage(WebPage* page)
|
||||||
{
|
{
|
||||||
|
bool completed = false;
|
||||||
QList<AutoFillData> list;
|
QList<AutoFillData> list;
|
||||||
|
|
||||||
if (!page) {
|
if (!page) {
|
||||||
@ -273,7 +275,11 @@ QList<AutoFillData> AutoFill::completePage(WebPage* page)
|
|||||||
const AutoFillData data = getFirstFormData(pageUrl);
|
const AutoFillData data = getFirstFormData(pageUrl);
|
||||||
|
|
||||||
PageFormCompleter completer(page);
|
PageFormCompleter completer(page);
|
||||||
completer.completePage(data.postData);
|
completed = completer.completePage(data.postData);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!completed) {
|
||||||
|
list.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
|
@ -90,8 +90,10 @@ PageFormData PageFormCompleter::extractFormData(const QByteArray &postData) cons
|
|||||||
return formData;
|
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);
|
const QueryItems &queryItems = createQueryItems(data);
|
||||||
|
|
||||||
// Input types that are being completed
|
// 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 &key = queryItems.at(i).first;
|
||||||
const QString &value = queryItems.at(i).second;
|
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++) {
|
for (int i = 0; i < inputs.count(); i++) {
|
||||||
QWebElement element = inputs.at(i);
|
QWebElement element = inputs.at(i);
|
||||||
const QString &typeAttr = element.attribute("type");
|
const QString &typeAttr = element.attribute("type");
|
||||||
@ -119,10 +116,13 @@ void PageFormCompleter::completePage(const QByteArray &data) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (key == element.attribute("name")) {
|
if (key == element.attribute("name")) {
|
||||||
|
completed = true;
|
||||||
element.setAttribute("value", value);
|
element.setAttribute("value", value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return completed;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PageFormCompleter::queryItemsContains(const QueryItems &queryItems, const QString &attributeName,
|
bool PageFormCompleter::queryItemsContains(const QueryItems &queryItems, const QString &attributeName,
|
||||||
|
@ -41,7 +41,7 @@ public:
|
|||||||
explicit PageFormCompleter(QWebPage* page);
|
explicit PageFormCompleter(QWebPage* page);
|
||||||
|
|
||||||
PageFormData extractFormData(const QByteArray &postData) const;
|
PageFormData extractFormData(const QByteArray &postData) const;
|
||||||
void completePage(const QByteArray &data) const;
|
bool completePage(const QByteArray &data) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef QPair<QString, QString> QueryItem;
|
typedef QPair<QString, QString> QueryItem;
|
||||||
|
Loading…
Reference in New Issue
Block a user