summaryrefslogtreecommitdiffstats
path: root/src/core/net/ssl_host_state_delegate_qt.h
blob: 0b3d7974c2c7ea960fa22e8d355e5331c8b1d643 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#ifndef SSL_HOST_STATE_DELEGATE_QT_H
#define SSL_HOST_STATE_DELEGATE_QT_H

#include "content/public/browser/ssl_host_state_delegate.h"

#include <map>
#include <string>

namespace QtWebEngineCore {

class CertPolicy
{
public:
    CertPolicy();
    ~CertPolicy();
    bool Check(const net::X509Certificate &cert, int error) const;
    void Allow(const net::X509Certificate &cert, int error);
    bool HasAllowException() const { return m_allowed.size() > 0; }

private:
    std::map<net::SHA256HashValue, int> m_allowed;
};

class SSLHostStateDelegateQt : public content::SSLHostStateDelegate
{

public:
    SSLHostStateDelegateQt();
    ~SSLHostStateDelegateQt();

    // content::SSLHostStateDelegate implementation:
    void AllowCert(const std::string &, const net::X509Certificate &cert, int error, content::StoragePartition *storage_partition) override;
    void Clear(base::RepeatingCallback<bool(const std::string&)> host_filter) override;
    CertJudgment QueryPolicy(const std::string &host, const net::X509Certificate &cert, int error, content::StoragePartition *web_contents) override;
    void HostRanInsecureContent(const std::string &host, int child_id, InsecureContentType content_type) override;
    bool DidHostRunInsecureContent(const std::string &host, int child_id, InsecureContentType content_type) override;
    void AllowHttpForHost(const std::string &host, content::StoragePartition *web_contents) override;
    bool IsHttpAllowedForHost(const std::string &host, content::StoragePartition *web_contents) override;
    void SetHttpsEnforcementForHost(const std::string &host, bool enforce, content::StoragePartition *storage_partition) override;
    bool IsHttpsEnforcedForHost(const std::string &host, content::StoragePartition *web_contents) override;
    void RevokeUserAllowExceptions(const std::string &host) override;
    bool HasAllowException(const std::string &host, content::StoragePartition *web_contents) override;
    bool HasAllowExceptionForAnyHost(content::StoragePartition *storage_partition) override;

private:
    std::map<std::string, CertPolicy> m_certPolicyforHost;
};

} // namespace QtWebEngineCore

#endif // SSL_HOST_STATE_DELEGATE_QT_H