// Copyright (c) 2012-2014 The CEF Python authors. All rights reserved. // License: New BSD License. // Website: http://code.google.com/p/cefpython/ #pragma once #include "include/cef_app.h" #include "include/cef_print_handler.h" #if defined(OS_LINUX) #include "print_handler_gtk.h" #endif #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, use // the DebugLog() function instead, it will write the message // to the "debug.log" file. class CefPythonApp : public CefApp, public CefBrowserProcessHandler, public CefRenderProcessHandler { protected: std::map > javascriptBindings_; std::string commandLineString_; CefRefPtr print_handler_; public: CefPythonApp(); virtual void OnBeforeCommandLineProcessing( const CefString& process_type, CefRefPtr command_line) OVERRIDE; virtual void OnRegisterCustomSchemes( CefRefPtr registrar) OVERRIDE; virtual CefRefPtr GetResourceBundleHandler() OVERRIDE; virtual CefRefPtr GetBrowserProcessHandler() OVERRIDE; virtual CefRefPtr GetRenderProcessHandler() OVERRIDE; virtual CefRefPtr GetPrintHandler() OVERRIDE; // --------------------------------------------------------------------------- // CefBrowserProcessHandler // --------------------------------------------------------------------------- virtual void OnContextInitialized() OVERRIDE; virtual void OnBeforeChildProcessLaunch( CefRefPtr command_line) OVERRIDE; virtual void OnRenderProcessThreadCreated( CefRefPtr extra_info) OVERRIDE; // --------------------------------------------------------------------------- // CefRenderProcessHandler // --------------------------------------------------------------------------- virtual void OnRenderThreadCreated(CefRefPtr extra_info) OVERRIDE; virtual void OnWebKitInitialized() OVERRIDE; virtual void OnBrowserCreated(CefRefPtr browser) OVERRIDE; virtual void OnBrowserDestroyed(CefRefPtr browser) OVERRIDE; virtual bool OnBeforeNavigation(CefRefPtr browser, CefRefPtr frame, CefRefPtr request, cef_navigation_type_t navigation_type, bool is_redirect) OVERRIDE; virtual void OnContextCreated(CefRefPtr browser, CefRefPtr frame, CefRefPtr context) OVERRIDE; virtual void OnContextReleased(CefRefPtr browser, CefRefPtr frame, CefRefPtr context) OVERRIDE; virtual void OnUncaughtException(CefRefPtr browser, CefRefPtr frame, CefRefPtr context, CefRefPtr exception, CefRefPtr stackTrace) OVERRIDE; virtual void OnFocusedNodeChanged(CefRefPtr browser, CefRefPtr frame, CefRefPtr node) OVERRIDE; virtual bool OnProcessMessageReceived(CefRefPtr browser, CefProcessId source_process, CefRefPtr message) OVERRIDE; // --------------------------------------------------------------------------- // Javascript bindings // --------------------------------------------------------------------------- virtual void SetJavascriptBindings(CefRefPtr browser, CefRefPtr data); virtual CefRefPtr GetJavascriptBindings( CefRefPtr browser); virtual void RemoveJavascriptBindings(CefRefPtr browser); virtual bool BindedFunctionExists(CefRefPtr browser, const CefString& funcName); virtual void DoJavascriptBindingsForBrowser(CefRefPtr browser); virtual void DoJavascriptBindingsForFrame(CefRefPtr browser, CefRefPtr frame, CefRefPtr context); private: IMPLEMENT_REFCOUNTING(CefPythonApp); };