mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 02:36:34 +01:00
AutoFill: Add option to disable auto complete on sites
This is particularly useful with Encrypted backend as it will only prompt for password when you actually want to fill passwords.
This commit is contained in:
parent
e719a959d4
commit
89f3b18df3
@ -38,7 +38,6 @@
|
||||
AutoFill::AutoFill(QObject* parent)
|
||||
: QObject(parent)
|
||||
, m_manager(new PasswordManager(this))
|
||||
, m_isStoring(false)
|
||||
{
|
||||
loadSettings();
|
||||
|
||||
@ -62,6 +61,7 @@ void AutoFill::loadSettings()
|
||||
Settings settings;
|
||||
settings.beginGroup("Web-Browser-Settings");
|
||||
m_isStoring = settings.value("SavePasswordsOnSites", true).toBool();
|
||||
m_isAutoComplete = settings.value("AutoCompletePasswords", true).toBool();
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ bool AutoFill::isStored(const QUrl &url)
|
||||
return false;
|
||||
}
|
||||
|
||||
return !m_manager->getEntries(url).isEmpty();
|
||||
return !m_manager->getUsernames(url).isEmpty();
|
||||
}
|
||||
|
||||
bool AutoFill::isStoringEnabled(const QUrl &url)
|
||||
@ -226,6 +226,10 @@ QStringList AutoFill::completePage(WebPage *page, const QUrl &frameUrl)
|
||||
if (!page || !isStored(frameUrl))
|
||||
return usernames;
|
||||
|
||||
if (!m_isAutoComplete) {
|
||||
return m_manager->getUsernames(frameUrl);
|
||||
}
|
||||
|
||||
const auto entries = getFormData(frameUrl);
|
||||
|
||||
if (!entries.isEmpty()) {
|
||||
|
@ -79,7 +79,8 @@ public:
|
||||
|
||||
private:
|
||||
PasswordManager* m_manager;
|
||||
bool m_isStoring;
|
||||
bool m_isStoring = false;
|
||||
bool m_isAutoComplete = false;
|
||||
QPointer<AutoFillNotification> m_lastNotification;
|
||||
WebPage *m_lastNotificationPage = nullptr;
|
||||
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include "autofillwidget.h"
|
||||
#include "ui_autofillwidget.h"
|
||||
#include "autofill.h"
|
||||
#include "qztools.h"
|
||||
#include "webview.h"
|
||||
#include "webpage.h"
|
||||
#include "scripts.h"
|
||||
@ -52,13 +51,22 @@ void AutoFillWidget::setUsernames(const QStringList &usernames)
|
||||
ui->gridLayout->addWidget(button, i++, 0);
|
||||
connect(button, &QPushButton::clicked, this, [=]() {
|
||||
const auto entries = mApp->autoFill()->getFormData(m_view->url());
|
||||
for (PasswordEntry entry : entries) {
|
||||
if (entry.username != username) {
|
||||
continue;
|
||||
PasswordEntry entry;
|
||||
// Find exact username match
|
||||
for (const PasswordEntry &e : entries) {
|
||||
if (e.username == username) {
|
||||
entry = e;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Find by index
|
||||
// This is needed for DatabaseEncryptedPasswordBackend because it also encrypts usernames.
|
||||
if (!entry.isValid()) {
|
||||
entry = entries.value(i - 1);
|
||||
}
|
||||
if (entry.isValid()) {
|
||||
mApp->autoFill()->updateLastUsed(entry);
|
||||
m_view->page()->runJavaScript(Scripts::completeFormData(entry.data), WebPage::SafeJsWorld);
|
||||
break;
|
||||
}
|
||||
close();
|
||||
});
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* ============================================================
|
||||
* Falkon - Qt web browser
|
||||
* Copyright (C) 2013-2014 S. Razi Alavizadeh <s.r.alavizadeh@gmail.com>
|
||||
* Copyright (C) 2013-2017 David Rosca <nowrep@gmail.com>
|
||||
* Copyright (C) 2013-2018 David Rosca <nowrep@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -47,6 +47,24 @@ DatabaseEncryptedPasswordBackend::~DatabaseEncryptedPasswordBackend()
|
||||
{
|
||||
}
|
||||
|
||||
QStringList DatabaseEncryptedPasswordBackend::getUsernames(const QUrl &url)
|
||||
{
|
||||
if (!m_askMasterPassword) {
|
||||
return PasswordBackend::getUsernames(url);
|
||||
}
|
||||
|
||||
QSqlQuery query(SqlDatabase::instance()->database());
|
||||
query.prepare("SELECT username_encrypted FROM autofill_encrypted WHERE server=? ORDER BY last_used DESC");
|
||||
query.addBindValue(PasswordManager::createHost(url));
|
||||
query.exec();
|
||||
|
||||
QStringList list;
|
||||
while (query.next()) {
|
||||
list.append(QSL("Encrypted %1").arg(list.size() + 1));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
QVector<PasswordEntry> DatabaseEncryptedPasswordBackend::getEntries(const QUrl &url)
|
||||
{
|
||||
QVector<PasswordEntry> list;
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* ============================================================
|
||||
* Falkon - Qt web browser
|
||||
* Copyright (C) 2013-2014 S. Razi Alavizadeh <s.r.alavizadeh@gmail.com>
|
||||
* Copyright (C) 2013-2014 David Rosca <nowrep@gmail.com>
|
||||
* Copyright (C) 2013-2018 David Rosca <nowrep@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -40,6 +40,7 @@ public:
|
||||
|
||||
~DatabaseEncryptedPasswordBackend();
|
||||
|
||||
QStringList getUsernames(const QUrl &url);
|
||||
QVector<PasswordEntry> getEntries(const QUrl &url);
|
||||
QVector<PasswordEntry> getAllEntries();
|
||||
|
||||
|
@ -83,6 +83,12 @@ void PasswordManager::loadSettings()
|
||||
m_backend->setActive(true);
|
||||
}
|
||||
|
||||
QStringList PasswordManager::getUsernames(const QUrl &url)
|
||||
{
|
||||
ensureLoaded();
|
||||
return m_backend->getUsernames(url);
|
||||
}
|
||||
|
||||
QVector<PasswordEntry> PasswordManager::getEntries(const QUrl &url)
|
||||
{
|
||||
ensureLoaded();
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* ============================================================
|
||||
* Falkon - Qt web browser
|
||||
* Copyright (C) 2013-2014 David Rosca <nowrep@gmail.com>
|
||||
* Copyright (C) 2013-2018 David Rosca <nowrep@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -63,6 +63,7 @@ public:
|
||||
|
||||
void loadSettings();
|
||||
|
||||
QStringList getUsernames(const QUrl &url);
|
||||
QVector<PasswordEntry> getEntries(const QUrl &url);
|
||||
QVector<PasswordEntry> getAllEntries();
|
||||
|
||||
|
@ -294,6 +294,7 @@ Preferences::Preferences(BrowserWindow* window)
|
||||
|
||||
//PASSWORD MANAGER
|
||||
ui->allowPassManager->setChecked(settings.value("SavePasswordsOnSites", true).toBool());
|
||||
ui->autoCompletePasswords->setChecked(settings.value("AutoCompletePasswords", true).toBool());
|
||||
connect(ui->allowPassManager, SIGNAL(toggled(bool)), this, SLOT(showPassManager(bool)));
|
||||
|
||||
showPassManager(ui->allowPassManager->isChecked());
|
||||
@ -984,6 +985,7 @@ void Preferences::saveSettings()
|
||||
|
||||
//PASSWORD MANAGER
|
||||
settings.setValue("SavePasswordsOnSites", ui->allowPassManager->isChecked());
|
||||
settings.setValue("AutoCompletePasswords", ui->autoCompletePasswords->isChecked());
|
||||
|
||||
//PRIVACY
|
||||
//Web storage
|
||||
|
@ -1966,7 +1966,7 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="3">
|
||||
<item row="3" column="0" colspan="3">
|
||||
<widget class="QFrame" name="AutoFillFrame">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
@ -1981,6 +1981,13 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QCheckBox" name="autoCompletePasswords">
|
||||
<property name="text">
|
||||
<string>Automatically complete passwords on sites</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="privacyPage">
|
||||
@ -2412,8 +2419,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>96</width>
|
||||
<height>31</height>
|
||||
<width>560</width>
|
||||
<height>80</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_14">
|
||||
|
Loading…
Reference in New Issue
Block a user