summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/am/applets/web_browser.h
blob: 8d4027411112677f2fdc5113223ebd8e536ccaa6 (plain) (blame)
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// Copyright 2018 yuzu emulator team
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.

#pragma once

#include <map>
#include "core/file_sys/vfs_types.h"
#include "core/hle/service/am/am.h"
#include "core/hle/service/am/applets/applets.h"

namespace Core {
class System;
}

namespace Service::AM::Applets {

enum class ShimKind : u32;
enum class ShopWebTarget;
enum class WebArgTLVType : u16;

class WebBrowser final : public Applet {
public:
    WebBrowser(Core::System& system_, Core::Frontend::WebBrowserApplet& frontend_,
               Core::Frontend::ECommerceApplet* frontend_e_commerce_ = nullptr);

    ~WebBrowser() override;

    void Initialize() override;

    bool TransactionComplete() const override;
    ResultCode GetStatus() const override;
    void ExecuteInteractive() override;
    void Execute() override;

    // Callback to be fired when the frontend needs the manual RomFS unpacked to temporary
    // directory. This is a blocking call and may take a while as some manuals can be up to 100MB in
    // size. Attempting to access files at filename before invocation is likely to not work.
    void UnpackRomFS();

    // Callback to be fired when the frontend is finished browsing. This will delete the temporary
    // manual RomFS extracted files, so ensure this is only called at actual finalization.
    void Finalize();

private:
    void InitializeInternal();
    void ExecuteInternal();

    // Specific initializers for the types of web applets
    void InitializeShop();
    void InitializeOffline();

    // Specific executors for the types of web applets
    void ExecuteShop();
    void ExecuteOffline();

    Core::Frontend::WebBrowserApplet& frontend;

    // Extra frontends for specialized functions
    Core::Frontend::ECommerceApplet* frontend_e_commerce;

    bool complete = false;
    bool unpacked = false;
    ResultCode status = RESULT_SUCCESS;

    ShimKind kind;
    std::map<WebArgTLVType, std::vector<u8>> args;

    FileSys::VirtualFile offline_romfs;
    std::string temporary_dir;
    std::string filename;

    ShopWebTarget shop_web_target;
    std::map<std::string, std::string, std::less<>> shop_query;
    std::optional<u64> title_id = 0;
    std::optional<u128> user_id;
    std::optional<bool> shop_full_display;
    std::string shop_extra_parameter;

    Core::System& system;
};

} // namespace Service::AM::Applets