/// \file base_handler.h /// \ingroup WebGui /// \author Sergey Linev /// \date 2017-06-29 /// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback /// is welcome! /************************************************************************* * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. * * All rights reserved. * * * * For the licensing terms see $ROOTSYS/LICENSE. * * For the list of contributors see $ROOTSYS/README/CREDITS. * *************************************************************************/ #ifndef ROOT_cef_base_handler #define ROOT_cef_base_handler #include "include/cef_client.h" #include class THttpServer; /// Class used to handle off-screen application and should emulate some render requests class BaseHandler : public CefClient, public CefLifeSpanHandler, public CefLoadHandler, public CefDisplayHandler { protected: THttpServer *fServer{nullptr}; int fConsole{0}; public: explicit BaseHandler(THttpServer *serv = nullptr); // Provide access to the single global instance of this object. // static BaseHandler *GetInstance(); // CefClient methods: virtual CefRefPtr GetLifeSpanHandler() OVERRIDE { return this; } virtual CefRefPtr GetLoadHandler() OVERRIDE { return this; } virtual CefRefPtr GetDisplayHandler() OVERRIDE { return this; } // CefLifeSpanHandler methods: virtual void OnAfterCreated(CefRefPtr browser) OVERRIDE; virtual bool DoClose(CefRefPtr browser) OVERRIDE; virtual void OnBeforeClose(CefRefPtr browser) OVERRIDE; // CefLoadHandler methods: virtual void OnLoadError(CefRefPtr browser, CefRefPtr frame, ErrorCode errorCode, const CefString &errorText, const CefString &failedUrl) OVERRIDE; // CefDisplayHandler methods: virtual void OnTitleChange(CefRefPtr browser, const CefString &title) OVERRIDE; virtual bool OnConsoleMessage(CefRefPtr browser, cef_log_severity_t level, const CefString &message, const CefString &source, int line) OVERRIDE; // Request that all existing browser windows close. void CloseAllBrowsers(bool force_close); bool IsClosing() const { return is_closing_; } private: // List of existing browser windows. Only accessed on the CEF UI thread. typedef std::list> BrowserList; BrowserList browser_list_; bool is_closing_; // Include the default reference counting implementation. IMPLEMENT_REFCOUNTING(BaseHandler); DISALLOW_COPY_AND_ASSIGN(BaseHandler); }; #endif // ROOT_cef_base_handler