File indexing completed on 2024-05-12 04:57:55
0001 /* ============================================================ 0002 * Falkon - Qt web browser 0003 * Copyright (C) 2010-2018 David Rosca <nowrep@gmail.com> 0004 * 0005 * This program is free software: you can redistribute it and/or modify 0006 * it under the terms of the GNU General Public License as published by 0007 * the Free Software Foundation, either version 3 of the License, or 0008 * (at your option) any later version. 0009 * 0010 * This program is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0013 * GNU General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU General Public License 0016 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0017 * ============================================================ */ 0018 #ifndef AUTOFILL_H 0019 #define AUTOFILL_H 0020 0021 #include <QObject> 0022 #include <QPointer> 0023 0024 #include "qzcommon.h" 0025 0026 class QUrl; 0027 class QWebEnginePage; 0028 0029 class WebPage; 0030 class BrowserWindow; 0031 class PasswordManager; 0032 class AutoFillNotification; 0033 struct PageFormData; 0034 struct PasswordEntry; 0035 0036 struct PageFormData { 0037 QString username; 0038 QString password; 0039 QByteArray postData; 0040 0041 bool isValid() const { 0042 return !password.isEmpty(); 0043 } 0044 }; 0045 0046 class FALKON_EXPORT AutoFill : public QObject 0047 { 0048 Q_OBJECT 0049 0050 public: 0051 explicit AutoFill(QObject* parent = nullptr); 0052 0053 PasswordManager* passwordManager() const; 0054 void loadSettings(); 0055 0056 bool isStored(const QUrl &url); 0057 bool isStoringEnabled(const QUrl &url); 0058 void blockStoringforUrl(const QUrl &url); 0059 0060 QVector<PasswordEntry> getFormData(const QUrl &url); 0061 QVector<PasswordEntry> getAllFormData(); 0062 0063 void updateLastUsed(PasswordEntry &data); 0064 0065 void addEntry(const QUrl &url, const QString &name, const QString &pass); 0066 void addEntry(const QUrl &url, const PageFormData &formData); 0067 0068 void updateEntry(const QUrl &url, const QString &name, const QString &pass); 0069 bool updateEntry(const PasswordEntry &entry); 0070 0071 void removeEntry(const PasswordEntry &entry); 0072 void removeAllEntries(); 0073 0074 void saveForm(WebPage *page, const QUrl &frameUrl, const PageFormData &formData); 0075 QStringList completePage(WebPage *page, const QUrl &frameUrl); 0076 0077 QByteArray exportPasswords(); 0078 bool importPasswords(const QByteArray &data); 0079 0080 private: 0081 PasswordManager* m_manager; 0082 bool m_isStoring = false; 0083 bool m_isAutoComplete = false; 0084 QPointer<AutoFillNotification> m_lastNotification; 0085 WebPage *m_lastNotificationPage = nullptr; 0086 0087 }; 0088 0089 #endif // AUTOFILL_H