#pragma once #include #include "WebApp.h" namespace Atomic { // Web app implementation for the renderer process. class WebAppRenderer : public WebApp, public CefRenderProcessHandler { public: // Interface for renderer delegates. All Delegates must be returned via // CreateDelegates. Do not perform work in the Delegate // constructor. See CefRenderProcessHandler for documentation. class Delegate : public virtual CefBase { public: virtual void OnRenderThreadCreated(CefRefPtr app, CefRefPtr extra_info) {} virtual void OnWebKitInitialized(CefRefPtr app) {} virtual void OnBrowserCreated(CefRefPtr app, CefRefPtr browser) {} virtual void OnBrowserDestroyed(CefRefPtr app, CefRefPtr browser) {} virtual CefRefPtr GetLoadHandler(CefRefPtr app) { return NULL; } virtual bool OnBeforeNavigation(CefRefPtr app, CefRefPtr browser, CefRefPtr frame, CefRefPtr request, cef_navigation_type_t navigation_type, bool is_redirect) { return false; } virtual void OnContextCreated(CefRefPtr app, CefRefPtr browser, CefRefPtr frame, CefRefPtr context) {} virtual void OnContextReleased(CefRefPtr app, CefRefPtr browser, CefRefPtr frame, CefRefPtr context) {} virtual void OnUncaughtException(CefRefPtr app, CefRefPtr browser, CefRefPtr frame, CefRefPtr context, CefRefPtr exception, CefRefPtr stackTrace) {} virtual void OnFocusedNodeChanged(CefRefPtr app, CefRefPtr browser, CefRefPtr frame, CefRefPtr node) {} // Called when a process message is received. Return true if the message was // handled and should not be passed on to other handlers. Delegates // should check for unique message names to avoid interfering with each // other. virtual bool OnProcessMessageReceived( CefRefPtr app, CefRefPtr browser, CefProcessId source_process, CefRefPtr message) { return false; } }; typedef List> DelegateSet; WebAppRenderer(); private: // Creates all of the Delegate objects. Implemented by cefclient in // client_app_delegates_renderer.cc static void CreateDelegates(DelegateSet& delegates); // CefApp methods. CefRefPtr GetRenderProcessHandler() OVERRIDE { return this; } // CefRenderProcessHandler methods. void OnRenderThreadCreated(CefRefPtr extra_info) OVERRIDE; void OnWebKitInitialized() OVERRIDE; void OnBrowserCreated(CefRefPtr browser) OVERRIDE; void OnBrowserDestroyed(CefRefPtr browser) OVERRIDE; CefRefPtr GetLoadHandler() OVERRIDE; bool OnBeforeNavigation(CefRefPtr browser, CefRefPtr frame, CefRefPtr request, NavigationType 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; private: // Set of supported Delegates. DelegateSet delegates_; IMPLEMENT_REFCOUNTING(WebAppRenderer); DISALLOW_COPY_AND_ASSIGN(WebAppRenderer); }; }