// Copyright (c) 2012 CEF Python, see the Authors file. // All rights reserved. Licensed under BSD 3-clause license. // Project website: https://github.com/cztomczak/cefpython #pragma once #include "include/cef_app.h" #include "include/cef_print_handler.h" #include // CefPythonApp class is instantiated in subprocess and in // cefpython.pyx for the browser process, so the code is shared. // Using printf() in CefRenderProcessHandler won't work on some // operating systems, use LOG(INFO) macro instead, it will write // the message to the "debug.log" file. class CefPythonApp : public CefApp, public CefBrowserProcessHandler, public CefRenderProcessHandler { protected: std::map > javascriptBindings_; CefRefPtr print_handler_; public: CefPythonApp(); void OnBeforeCommandLineProcessing( const CefString& process_type, CefRefPtr command_line) override; void OnRegisterCustomSchemes( CefRawPtr registrar) override; CefRefPtr GetResourceBundleHandler() override; CefRefPtr GetBrowserProcessHandler() override; CefRefPtr GetRenderProcessHandler() override; // --------------------------------------------------------------------------- // CefBrowserProcessHandler // --------------------------------------------------------------------------- void OnContextInitialized() override; void OnBeforeChildProcessLaunch( CefRefPtr command_line) override; void OnRenderProcessThreadCreated( CefRefPtr extra_info) override; CefRefPtr GetPrintHandler() override; void OnScheduleMessagePumpWork(int64 delay_ms) override; // --------------------------------------------------------------------------- // CefRenderProcessHandler // --------------------------------------------------------------------------- void OnRenderThreadCreated(CefRefPtr extra_info) override; void OnWebKitInitialized() override; void OnBrowserCreated(CefRefPtr browser) override; void OnBrowserDestroyed(CefRefPtr browser) override; bool OnBeforeNavigation(CefRefPtr browser, CefRefPtr frame, CefRefPtr request, cef_navigation_type_t navigation_type, bool is_redirect) override; void OnContextCreated(CefRefPtr browser, CefRefPtr frame, CefRefPtr context) override; void OnContextReleased(CefRefPtr browser, CefRefPtr frame, CefRefPtr context) override; void OnUncaughtException(CefRefPtr browser, CefRefPtr frame, CefRefPtr context, CefRefPtr exception, CefRefPtr stackTrace) override; void OnFocusedNodeChanged(CefRefPtr browser, CefRefPtr frame, CefRefPtr node) override; bool OnProcessMessageReceived(CefRefPtr browser, CefProcessId source_process, CefRefPtr message) override; // --------------------------------------------------------------------------- // Javascript bindings // --------------------------------------------------------------------------- void SetJavascriptBindings(CefRefPtr browser, CefRefPtr data); CefRefPtr GetJavascriptBindings( CefRefPtr browser); void RemoveJavascriptBindings(CefRefPtr browser); bool BindedFunctionExists(CefRefPtr browser, const CefString& funcName); void DoJavascriptBindingsForBrowser(CefRefPtr browser); void DoJavascriptBindingsForFrame(CefRefPtr browser, CefRefPtr frame, CefRefPtr context); private: IMPLEMENT_REFCOUNTING(CefPythonApp); };