summaryrefslogtreecommitdiffstats
path: root/src/core/extensions/unpacked_extension_installer.h
blob: 170487ec81859093e7af473f84ca37e834053058 (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
// Copyright (C) 2025 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

#ifndef UNPACKED_EXTENSION_INSTALLER_H_
#define UNPACKED_EXTENSION_INSTALLER_H_

#include <string>

#include "extension_loader.h"

#include "base/files/file_path.h"
#include "base/functional/callback.h"
#include "base/memory/ref_counted.h"
#include "base/task/sequenced_task_runner.h"

namespace QtWebEngineCore {
class UnpackedExtensionInstaller : public base::RefCountedThreadSafe<UnpackedExtensionInstaller>
{
public:
    using DoneCallback = base::OnceCallback<void(const base::FilePath &src,
                                                 const base::FilePath &extensionsInstallDir,
                                                 const std::string &error)>;
    static scoped_refptr<UnpackedExtensionInstaller>
    Create(const scoped_refptr<base::SequencedTaskRunner> &taskRunner, DoneCallback doneCallback);

    struct InstallInfo
    {
        std::string error{};
        base::FilePath extensionInstallPath{};
    };

    void install(const base::FilePath &src, const base::FilePath &installDir);
    static InstallInfo installUnpackedExtensionOnFileThread(const base::FilePath &src,
                                                            const base::FilePath &installDir);

private:
    UnpackedExtensionInstaller(const scoped_refptr<base::SequencedTaskRunner> &taskRunner,
                               DoneCallback doneCallback);
    void installInternal(const base::FilePath &src, const base::FilePath &installDir,
                         const ExtensionLoader::LoadingInfo &loadingInfo);
    void installDone(const base::FilePath &src, const InstallInfo &installInfo);

    scoped_refptr<base::SequencedTaskRunner> m_taskRunner;
    DoneCallback m_doneCallback;
};
} // namespace QtWebEngineCore
#endif // UNPACKED_EXTENSION_INSTALLER_H_