Logo ROOT  
Reference Guide
simple_app.h
Go to the documentation of this file.
1// Author: Sergey Linev <S.Linev@gsi.de>
2// Date: 2017-06-29
3// Warning: This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
4
5// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights
6// reserved. Use of this source code is governed by a BSD-style license that
7// can be found in the LICENSE file.
8
9/*************************************************************************
10 * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. *
11 * All rights reserved. *
12 * *
13 * For the licensing terms see $ROOTSYS/LICENSE. *
14 * For the list of contributors see $ROOTSYS/README/CREDITS. *
15 *************************************************************************/
16
17#ifndef ROOT_cef_simple_app
18#define ROOT_cef_simple_app
19
20#include "include/cef_app.h"
21
22#include <string>
23
24#include "gui_handler.h"
25
26class THttpServer;
27
29
30// Implement application-level callbacks for the browser process.
31class SimpleApp : public CefApp,
32#if defined(OS_LINUX)
33 public CefPrintHandler,
34#endif
35 /*, public CefRenderProcessHandler */
37protected:
38 bool fUseViewes{false}; ///<! is views framework used
39 THttpServer *fFirstServer; ///<! first server
40 std::string fFirstUrl; ///<! first URL to open
41 std::string fFirstContent; ///<! first page content open
42 CefRect fFirstRect; ///<! original width
43 bool fFirstHeadless{false}; ///<! is first window is headless
44 RCefWebDisplayHandle *fNextHandle{nullptr}; ///< next handle where browser will be created
45
46 CefRefPtr<GuiHandler> fGuiHandler; ///<! normal handler
47
48public:
49 SimpleApp(bool use_viewes,
50 THttpServer *serv = nullptr, const std::string &url = "", const std::string &cont = "",
51 int width = 0, int height = 0, bool headless = false);
52
54
55 // CefApp methods:
56 virtual CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler() override { return this; }
57
58#if defined(OS_LINUX)
59#if CEF_VERSION_MAJOR < 95
60 // only on Linux special print handler is required to return PDF size
61 virtual CefRefPtr<CefPrintHandler> GetPrintHandler() override { return this; }
62#endif
63#endif
64 // virtual CefRefPtr<CefRenderProcessHandler> GetRenderProcessHandler() override { return this; }
65
66 virtual void OnRegisterCustomSchemes(CefRawPtr<CefSchemeRegistrar> registrar) override;
67
68 // CefBrowserProcessHandler methods:
69 virtual void OnContextInitialized() override;
70
71 virtual void
72 OnBeforeCommandLineProcessing(const CefString &process_type, CefRefPtr<CefCommandLine> command_line) override;
73
74 virtual void OnBeforeChildProcessLaunch(CefRefPtr<CefCommandLine> command_line) override;
75
76#if defined(OS_LINUX)
77 // CefPrintHandler methods
78#if CEF_VERSION_MAJOR < 95
79 virtual CefSize GetPdfPaperSize(int device_units_per_inch) override { return CefSize(device_units_per_inch*8.25, device_units_per_inch*11.75); }
80#else
81 virtual CefSize GetPdfPaperSize(CefRefPtr<CefBrowser>, int device_units_per_inch) override { return CefSize(device_units_per_inch*8.25, device_units_per_inch*11.75); }
82#endif
83 virtual bool OnPrintDialog( CefRefPtr< CefBrowser > browser, bool has_selection, CefRefPtr< CefPrintDialogCallback > callback ) override { return false; }
84 virtual bool OnPrintJob( CefRefPtr< CefBrowser > browser, const CefString& document_name, const CefString& pdf_file_path, CefRefPtr< CefPrintJobCallback > callback ) override { return false; }
85 virtual void OnPrintReset( CefRefPtr< CefBrowser > browser ) override {}
86 virtual void OnPrintSettings( CefRefPtr< CefBrowser > browser, CefRefPtr< CefPrintSettings > settings, bool get_defaults ) override {}
87 virtual void OnPrintStart( CefRefPtr< CefBrowser > browser ) override {}
88#endif
89
90
91 void StartWindow(THttpServer *serv, const std::string &url, const std::string &cont, CefRect &rect);
92
93 // CefRenderProcessHandler methods
94 // virtual void OnContextCreated(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
95 // CefRefPtr<CefV8Context> context) override;
96
97private:
98 // Include the default reference counting implementation.
101};
102
103#endif // ROOT_cef_simple_app
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t rect
Option_t Option_t width
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
RCefWebDisplayHandle * fNextHandle
next handle where browser will be created
Definition: simple_app.h:44
SimpleApp(bool use_viewes, THttpServer *serv=nullptr, const std::string &url="", const std::string &cont="", int width=0, int height=0, bool headless=false)
Definition: simple_app.cxx:112
std::string fFirstUrl
! first URL to open
Definition: simple_app.h:40
bool fUseViewes
! is views framework used
Definition: simple_app.h:38
virtual void OnContextInitialized() override
Definition: simple_app.cxx:168
virtual CefRefPtr< CefBrowserProcessHandler > GetBrowserProcessHandler() override
Definition: simple_app.h:56
THttpServer * fFirstServer
! first server
Definition: simple_app.h:39
void StartWindow(THttpServer *serv, const std::string &url, const std::string &cont, CefRect &rect)
Definition: simple_app.cxx:180
bool fFirstHeadless
! is first window is headless
Definition: simple_app.h:43
virtual void OnBeforeChildProcessLaunch(CefRefPtr< CefCommandLine > command_line) override
Definition: simple_app.cxx:157
CefRect fFirstRect
! original width
Definition: simple_app.h:42
void SetNextHandle(RCefWebDisplayHandle *handle)
Definition: simple_app.cxx:134
virtual void OnRegisterCustomSchemes(CefRawPtr< CefSchemeRegistrar > registrar) override
Definition: simple_app.cxx:140
CefRefPtr< GuiHandler > fGuiHandler
! normal handler
Definition: simple_app.h:46
std::string fFirstContent
! first page content open
Definition: simple_app.h:41
DISALLOW_COPY_AND_ASSIGN(SimpleApp)
IMPLEMENT_REFCOUNTING(SimpleApp)
virtual void OnBeforeCommandLineProcessing(const CefString &process_type, CefRefPtr< CefCommandLine > command_line) override
Definition: simple_app.cxx:146
Online http server for arbitrary ROOT application.
Definition: THttpServer.h:31