File indexing completed on 2025-01-26 04:57:22

0001 /*
0002    SPDX-FileCopyrightText: 2016-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "webengineviewer_export.h"
0010 #include <QObject>
0011 #include <memory>
0012 
0013 namespace WebEngineViewer
0014 {
0015 class HashCacheManagerPrivate;
0016 // https://developers.google.com/safe-browsing/v4/caching
0017 /**
0018  * @brief The HashCacheManager class
0019  * @author Laurent Montel <montel@kde.org>
0020  */
0021 class WEBENGINEVIEWER_EXPORT HashCacheManager : public QObject
0022 {
0023     Q_OBJECT
0024 public:
0025     enum UrlStatus { UrlOk = 0, MalWare = 1, Unknown = 2 };
0026     explicit HashCacheManager(QObject *parent = nullptr);
0027     ~HashCacheManager() override;
0028 
0029     static HashCacheManager *self();
0030 
0031     void clearCache();
0032 
0033     void addHashStatus(const QByteArray &hash, HashCacheManager::UrlStatus status, uint cacheDuration);
0034 
0035     [[nodiscard]] HashCacheManager::UrlStatus hashStatus(const QByteArray &hash);
0036 
0037 private:
0038     std::unique_ptr<HashCacheManagerPrivate> const d;
0039 };
0040 }
0041 
0042 Q_DECLARE_METATYPE(WebEngineViewer::HashCacheManager::UrlStatus)