Logo ROOT  
Reference Guide
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
20
21#include <string>
22#include <map>
23#include <memory>
24
25namespace ROOT {
26namespace Experimental {
27
29
30protected:
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
59 public:
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
68 public:
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
81public:
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
char name[80]
Definition: TGX11.cxx:109
Holds different arguments for starting browser with RWebDisplayHandle::Display() method.
virtual std::string MakeProfile(std::string &, bool)
void TestProg(const std::string &nexttry, bool check_std_paths=false)
Check if browser executable exists and can be used.
BrowserCreator(bool custom=true, const std::string &exec="")
Class to handle starting of web-browsers like Chrome or Firefox.
virtual void ProcessGeometry(std::string &, const RWebDisplayArgs &)
std::unique_ptr< RWebDisplayHandle > Display(const RWebDisplayArgs &args) override
Display given URL in web browser.
void ProcessGeometry(std::string &, const RWebDisplayArgs &args) override
std::string MakeProfile(std::string &exec, bool) override
Handle profile argument.
virtual std::unique_ptr< RWebDisplayHandle > Display(const RWebDisplayArgs &args)=0
std::string MakeProfile(std::string &exec, bool batch) override
Create Firefox profile to run independent browser window.
static bool DisplayUrl(const std::string &url)
Display provided url in configured web browser.
static std::unique_ptr< Creator > & FindCreator(const std::string &name, const std::string &libname="")
Search for specific browser creator If not found, try to add one.
static std::unique_ptr< RWebDisplayHandle > Display(const RWebDisplayArgs &args)
Create web display.
static std::map< std::string, std::unique_ptr< Creator > > & GetMap()
!< URL used to launch display
VSD Structures.
Definition: StringConv.hxx:21