Warning, file /include/root/ROOT/RWebDisplayHandle.hxx was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef ROOT7_RWebDisplayHandle
0014 #define ROOT7_RWebDisplayHandle
0015
0016 #include <ROOT/RWebDisplayArgs.hxx>
0017
0018 #include <string>
0019 #include <map>
0020 #include <memory>
0021 #include <vector>
0022 #include "TString.h"
0023
0024 namespace ROOT {
0025
0026 class RWebDisplayHandle {
0027
0028 std::string fUrl;
0029
0030 std::string fContent;
0031
0032 protected:
0033
0034 class Creator {
0035 public:
0036 virtual std::unique_ptr<RWebDisplayHandle> Display(const RWebDisplayArgs &args) = 0;
0037 virtual bool IsActive() const { return true; }
0038 virtual ~Creator() = default;
0039 virtual bool IsSnapBrowser() const { return false; }
0040 };
0041
0042 class BrowserCreator : public Creator {
0043 protected:
0044 std::string fProg;
0045 std::string fExec;
0046 std::string fHeadlessExec;
0047 std::string fBatchExec;
0048 void TestProg(const std::string &nexttry, bool check_std_paths = false);
0049 virtual void ProcessGeometry(std::string &, const RWebDisplayArgs &) {}
0050 virtual std::string MakeProfile(std::string &, bool) { return ""; }
0051 public:
0052 BrowserCreator(bool custom = true, const std::string &exec = "");
0053 std::unique_ptr<RWebDisplayHandle> Display(const RWebDisplayArgs &args) override;
0054 ~BrowserCreator() override = default;
0055 static FILE *TemporaryFile(TString &name, int use_home_dir = 0, const char *suffix = nullptr);
0056 };
0057
0058 class SafariCreator : public BrowserCreator {
0059 public:
0060 SafariCreator();
0061 ~SafariCreator() override = default;
0062 bool IsActive() const override;
0063 };
0064
0065 class ChromeCreator : public BrowserCreator {
0066 bool fEdge{false};
0067 std::string fEnvPrefix;
0068 int fChromeVersion{-1};
0069 public:
0070 ChromeCreator(bool is_edge = false);
0071 ~ChromeCreator() override = default;
0072 bool IsActive() const override { return !fProg.empty(); }
0073 bool IsSnapBrowser() const override { return fProg == "/snap/bin/chromium"; }
0074 void ProcessGeometry(std::string &, const RWebDisplayArgs &) override;
0075 std::string MakeProfile(std::string &exec, bool) override;
0076 };
0077
0078 class FirefoxCreator : public BrowserCreator {
0079 public:
0080 FirefoxCreator();
0081 ~FirefoxCreator() override = default;
0082 bool IsActive() const override { return !fProg.empty(); }
0083 bool IsSnapBrowser() const override { return fProg == "/snap/bin/firefox"; }
0084 void ProcessGeometry(std::string &, const RWebDisplayArgs &) override;
0085 std::string MakeProfile(std::string &exec, bool batch) override;
0086 };
0087
0088 static std::map<std::string, std::unique_ptr<Creator>> &GetMap();
0089
0090 static std::unique_ptr<Creator> &FindCreator(const std::string &name, const std::string &libname = "");
0091
0092 static bool CheckIfCanProduceImages(RWebDisplayArgs &args);
0093
0094 public:
0095
0096
0097 RWebDisplayHandle(const std::string &url) : fUrl(url) {}
0098
0099
0100 virtual ~RWebDisplayHandle() = default;
0101
0102
0103 const std::string &GetUrl() const { return fUrl; }
0104
0105
0106 void SetContent(const std::string &cont) { fContent = cont; }
0107
0108 const std::string &GetContent() const { return fContent; }
0109
0110
0111 virtual bool Resize(int, int) { return false; }
0112
0113
0114 virtual void RemoveStartupFiles() {}
0115
0116 static bool NeedHttpServer(const RWebDisplayArgs &args);
0117
0118 static std::unique_ptr<RWebDisplayHandle> Display(const RWebDisplayArgs &args);
0119
0120 static bool DisplayUrl(const std::string &url);
0121
0122 static bool CanProduceImages(const std::string &browser = "");
0123
0124 static std::string GetImageFormat(const std::string &fname);
0125
0126 static bool ProduceImage(const std::string &fname, const std::string &json, int width = 800, int height = 600, const char *batch_file = nullptr);
0127
0128 static bool ProduceImages(const std::string &fname, const std::vector<std::string> &jsons, const std::vector<int> &widths, const std::vector<int> &heights, const char *batch_file = nullptr);
0129
0130 static std::vector<std::string> ProduceImagesNames(const std::string &fname, unsigned nfiles = 1);
0131
0132 static bool ProduceImages(const std::vector<std::string> &fnames, const std::vector<std::string> &jsons, const std::vector<int> &widths, const std::vector<int> &heights, const char *batch_file = nullptr);
0133
0134 };
0135
0136 }
0137
0138 #endif