summaryrefslogtreecommitdiff
path: root/Userland/Services/LaunchServer/ClientConnection.h
blob: 1b4658c0a177be6afdf80f7f1c383c893e8583d0 (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
/*
 * Copyright (c) 2020, Nicholas Hollett <niax@niax.co.uk>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <LaunchServer/LaunchClientEndpoint.h>
#include <LaunchServer/LaunchServerEndpoint.h>
#include <LibIPC/ClientConnection.h>

namespace LaunchServer {

class ClientConnection final : public IPC::ClientConnection<LaunchClientEndpoint, LaunchServerEndpoint>
    , public LaunchServerEndpoint {
    C_OBJECT(ClientConnection)
public:
    ~ClientConnection() override;

    virtual void die() override;

private:
    explicit ClientConnection(NonnullRefPtr<Core::LocalSocket>, int client_id);

    virtual Messages::LaunchServer::GreetResponse handle(const Messages::LaunchServer::Greet&) override;
    virtual Messages::LaunchServer::OpenURLResponse handle(const Messages::LaunchServer::OpenURL&) override;
    virtual Messages::LaunchServer::GetHandlersForURLResponse handle(const Messages::LaunchServer::GetHandlersForURL&) override;
    virtual Messages::LaunchServer::GetHandlersWithDetailsForURLResponse handle(const Messages::LaunchServer::GetHandlersWithDetailsForURL&) override;
    virtual Messages::LaunchServer::AddAllowedURLResponse handle(const Messages::LaunchServer::AddAllowedURL&) override;
    virtual Messages::LaunchServer::AddAllowedHandlerWithAnyURLResponse handle(const Messages::LaunchServer::AddAllowedHandlerWithAnyURL&) override;
    virtual Messages::LaunchServer::AddAllowedHandlerWithOnlySpecificURLsResponse handle(const Messages::LaunchServer::AddAllowedHandlerWithOnlySpecificURLs&) override;
    virtual Messages::LaunchServer::SealAllowlistResponse handle(const Messages::LaunchServer::SealAllowlist&) override;

    struct AllowlistEntry {
        String handler_name;
        bool any_url { false };
        Vector<URL> urls;
    };

    Vector<AllowlistEntry> m_allowlist;
    bool m_allowlist_is_sealed { false };
};
}