summaryrefslogtreecommitdiffstats
path: root/src/core/content_utility_client_qt.cpp
blob: a80254886a7bc73c5608c0faad133a9440a97013 (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
55
56
57
58
59
60
61
62
63
64
65
// 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
// Qt-Security score:significant reason:default

#include "content_utility_client_qt.h"

#include <QtWebEngineCore/qtwebenginecoreglobal.h>
#include "mojo/public/cpp/bindings/service_factory.h"
#include "services/proxy_resolver/proxy_resolver_factory_impl.h"

#if BUILDFLAG(IS_WIN)
#include "services/proxy_resolver_win/public/mojom/proxy_resolver_win.mojom.h"
#include "services/proxy_resolver_win/windows_system_proxy_resolver_impl.h"
#endif

#if QT_CONFIG(webengine_extensions)
#include "components/services/unzip/public/mojom/unzipper.mojom.h"
#include "components/services/unzip/unzipper_impl.h"
#endif

namespace QtWebEngineCore {

ContentUtilityClientQt::ContentUtilityClientQt()
{
}

ContentUtilityClientQt::~ContentUtilityClientQt() = default;

auto RunProxyResolver(mojo::PendingReceiver<proxy_resolver::mojom::ProxyResolverFactory> receiver)
{
    return std::make_unique<proxy_resolver::ProxyResolverFactoryImpl>(std::move(receiver));
}

#if BUILDFLAG(IS_WIN)
auto RunWindowsSystemProxyResolver(
        mojo::PendingReceiver<proxy_resolver_win::mojom::WindowsSystemProxyResolver> receiver)
{
    return std::make_unique<proxy_resolver_win::WindowsSystemProxyResolverImpl>(
            std::move(receiver));
}
#endif

void ContentUtilityClientQt::RegisterIOThreadServices(mojo::ServiceFactory &services)
{
    services.Add(RunProxyResolver);
#if BUILDFLAG(IS_WIN)
    services.Add(RunWindowsSystemProxyResolver);
#endif
}

#if QT_CONFIG(webengine_extensions)
auto RunUnzipper(mojo::PendingReceiver<unzip::mojom::Unzipper> receiver)
{
    return std::make_unique<unzip::UnzipperImpl>(std::move(receiver));
}
#endif

void ContentUtilityClientQt::RegisterMainThreadServices(mojo::ServiceFactory &services)
{
#if QT_CONFIG(webengine_extensions)
    services.Add(RunUnzipper);
#endif
}

} // namespace