summaryrefslogtreecommitdiffstats
path: root/src/core/request_controller.h
blob: 8008b2edbae7a2de5335e9ac0cb08870681673ae (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
// Copyright (C) 2018 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 REQUEST_CONTROLLER_H
#define REQUEST_CONTROLLER_H

#include "qtwebenginecoreglobal.h"

#include <QUrl>

namespace QtWebEngineCore {

class RequestController {
public:
    RequestController(QUrl origin)
        : m_answered(false)
        , m_origin(std::move(origin))
    {}

    QUrl origin() const { return m_origin; }

    void accept()
    {
        if (!m_answered) {
            m_answered = true;
            accepted();
        }
    }

    void reject()
    {
        if (!m_answered) {
            m_answered = true;
            rejected();
        }
    }

    virtual ~RequestController() {}

protected:
    virtual void accepted() = 0;
    virtual void rejected() = 0;

private:
    bool m_answered;
    QUrl m_origin;
};

} // namespace QtWebEngineCore

#endif // !REQUEST_CONTROLLER_H