Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
RWebDisplayHandle.hxx
Go to the documentation of this file.
1 /// \file ROOT/RWebDisplayHandle.hxx
2 /// \ingroup WebGui ROOT7
3 /// \author Sergey Linev <s.linev@gsi.de>
4 /// \date 2018-10-17
5 /// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback
6 /// is welcome!
7 
8 /*************************************************************************
9  * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. *
10  * All rights reserved. *
11  * *
12  * For the licensing terms see $ROOTSYS/LICENSE. *
13  * For the list of contributors see $ROOTSYS/README/CREDITS. *
14  *************************************************************************/
15 
16 #ifndef ROOT7_RWebDisplayHandle
17 #define ROOT7_RWebDisplayHandle
18 
19 #include <ROOT/RWebDisplayArgs.hxx>
20 
21 #include <string>
22 #include <map>
23 #include <memory>
24 
25 namespace ROOT {
26 namespace Experimental {
27 
28 class RWebDisplayHandle {
29 
30 protected:
31  class Creator {
32  public:
33  virtual std::unique_ptr<RWebDisplayHandle> Display(const RWebDisplayArgs &args) = 0;
34  virtual bool IsActive() const { return true; }
35  virtual ~Creator() = default;
36  };
37 
38  class BrowserCreator : public Creator {
39  protected:
40  std::string fProg; ///< browser executable
41  std::string fExec; ///< standard execute line
42  std::string fBatchExec; ///< batch execute line
43 
44  void TestProg(const std::string &nexttry, bool check_std_paths = false);
45 
46  virtual void ProcessGeometry(std::string &, const RWebDisplayArgs &) {}
47  virtual std::string MakeProfile(std::string &, bool) { return ""; }
48 
49  public:
50 
51  BrowserCreator(bool custom = true, const std::string &exec = "");
52 
53  std::unique_ptr<RWebDisplayHandle> Display(const RWebDisplayArgs &args) override;
54 
55  virtual ~BrowserCreator() = default;
56  };
57 
58  class ChromeCreator : public BrowserCreator {
59  public:
60  ChromeCreator();
61  virtual ~ChromeCreator() = default;
62  bool IsActive() const override { return !fProg.empty(); }
63  void ProcessGeometry(std::string &, const RWebDisplayArgs &args) override;
64  std::string MakeProfile(std::string &exec, bool) override;
65  };
66 
67  class FirefoxCreator : public BrowserCreator {
68  public:
69  FirefoxCreator();
70  virtual ~FirefoxCreator() = default;
71  bool IsActive() const override { return !fProg.empty(); }
72  std::string MakeProfile(std::string &exec, bool batch) override;
73  };
74 
75  std::string fUrl; ///!< URL used to launch display
76 
77  static std::map<std::string, std::unique_ptr<Creator>> &GetMap();
78 
79  static std::unique_ptr<Creator> &FindCreator(const std::string &name, const std::string &libname = "");
80 
81 public:
82 
83  RWebDisplayHandle(const std::string &url) : fUrl(url) {}
84 
85  // required virtual destructor for correct cleanup at the end
86  virtual ~RWebDisplayHandle() = default;
87 
88  std::string GetUrl() const { return fUrl; }
89 
90  static std::unique_ptr<RWebDisplayHandle> Display(const RWebDisplayArgs &args);
91 
92  static bool DisplayUrl(const std::string &url);
93 };
94 
95 }
96 }
97 
98 #endif