2011-03-03 18:29:20 +01:00
|
|
|
/* ============================================================
|
|
|
|
* QupZilla - WebKit based browser
|
2014-01-11 16:11:42 +01:00
|
|
|
* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com>
|
2011-03-03 18:29:20 +01:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
* ============================================================ */
|
2014-02-26 19:55:49 +01:00
|
|
|
#ifndef AUTOFILL_H
|
|
|
|
#define AUTOFILL_H
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2012-12-20 14:45:35 +01:00
|
|
|
#include <QObject>
|
2012-02-29 18:33:50 +01:00
|
|
|
|
2014-02-26 20:03:20 +01:00
|
|
|
#include "qzcommon.h"
|
2012-02-29 18:33:50 +01:00
|
|
|
|
|
|
|
class QUrl;
|
2015-08-31 18:56:52 +02:00
|
|
|
class QWebEnginePage;
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2015-09-24 23:00:27 +02:00
|
|
|
class WebPage;
|
2014-02-19 22:07:21 +01:00
|
|
|
class BrowserWindow;
|
2013-05-14 17:25:55 +02:00
|
|
|
class PasswordManager;
|
2013-01-24 17:47:50 +01:00
|
|
|
struct PageFormData;
|
2013-05-14 17:25:55 +02:00
|
|
|
struct PasswordEntry;
|
2013-02-08 13:02:53 +01:00
|
|
|
|
2015-08-31 18:56:52 +02:00
|
|
|
struct PageFormData {
|
|
|
|
QString username;
|
|
|
|
QString password;
|
|
|
|
QByteArray postData;
|
|
|
|
|
|
|
|
bool isValid() const {
|
|
|
|
return !password.isEmpty();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-02-19 22:12:32 +01:00
|
|
|
class QUPZILLA_EXPORT AutoFill : public QObject
|
2011-03-02 16:57:41 +01:00
|
|
|
{
|
2013-06-05 23:14:03 +02:00
|
|
|
Q_OBJECT
|
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
public:
|
2013-05-14 17:25:55 +02:00
|
|
|
explicit AutoFill(QObject* parent = 0);
|
2012-01-21 20:27:45 +01:00
|
|
|
|
2013-05-15 20:05:45 +02:00
|
|
|
PasswordManager* passwordManager() const;
|
2012-01-21 20:27:45 +01:00
|
|
|
void loadSettings();
|
2011-03-02 16:57:41 +01:00
|
|
|
|
|
|
|
bool isStored(const QUrl &url);
|
|
|
|
bool isStoringEnabled(const QUrl &url);
|
2013-02-08 13:02:53 +01:00
|
|
|
void blockStoringforUrl(const QUrl &url);
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2013-05-14 17:25:55 +02:00
|
|
|
QVector<PasswordEntry> getFormData(const QUrl &url);
|
2013-05-14 22:45:20 +02:00
|
|
|
QVector<PasswordEntry> getAllFormData();
|
2013-02-08 15:07:56 +01:00
|
|
|
|
2013-05-20 11:05:54 +02:00
|
|
|
void updateLastUsed(PasswordEntry &data);
|
2013-01-31 23:11:57 +01:00
|
|
|
|
2011-12-08 21:52:03 +01:00
|
|
|
void addEntry(const QUrl &url, const QString &name, const QString &pass);
|
2013-01-24 17:47:50 +01:00
|
|
|
void addEntry(const QUrl &url, const PageFormData &formData);
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2013-02-04 12:11:27 +01:00
|
|
|
void updateEntry(const QUrl &url, const QString &name, const QString &pass);
|
2013-06-08 13:14:00 +02:00
|
|
|
bool updateEntry(const PasswordEntry &entry);
|
2013-01-31 23:11:57 +01:00
|
|
|
|
2013-05-14 22:45:20 +02:00
|
|
|
void removeEntry(const PasswordEntry &entry);
|
|
|
|
void removeAllEntries();
|
|
|
|
|
2015-09-24 23:00:27 +02:00
|
|
|
void saveForm(WebPage *page, const QUrl &frameUrl, const PageFormData &formData);
|
2015-08-31 18:56:52 +02:00
|
|
|
QVector<PasswordEntry> completePage(QWebEnginePage *page, const QUrl &frameUrl);
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2013-05-22 15:43:44 +02:00
|
|
|
QByteArray exportPasswords();
|
|
|
|
bool importPasswords(const QByteArray &data);
|
2012-02-06 20:10:50 +01:00
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
private:
|
2013-05-14 17:25:55 +02:00
|
|
|
PasswordManager* m_manager;
|
2011-03-02 16:57:41 +01:00
|
|
|
bool m_isStoring;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2014-02-26 19:55:49 +01:00
|
|
|
#endif // AUTOFILL_H
|