| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- #pragma once
- #include <Atomic/Container/List.h>
- #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<WebAppRenderer> app,
- CefRefPtr<CefListValue> extra_info) {}
- virtual void OnWebKitInitialized(CefRefPtr<WebAppRenderer> app) {}
- virtual void OnBrowserCreated(CefRefPtr<WebAppRenderer> app,
- CefRefPtr<CefBrowser> browser) {}
- virtual void OnBrowserDestroyed(CefRefPtr<WebAppRenderer> app,
- CefRefPtr<CefBrowser> browser) {}
- virtual CefRefPtr<CefLoadHandler> GetLoadHandler(CefRefPtr<WebAppRenderer> app)
- {
- return NULL;
- }
- virtual bool OnBeforeNavigation(CefRefPtr<WebAppRenderer> app,
- CefRefPtr<CefBrowser> browser,
- CefRefPtr<CefFrame> frame,
- CefRefPtr<CefRequest> request,
- cef_navigation_type_t navigation_type,
- bool is_redirect)
- {
- return false;
- }
- virtual void OnContextCreated(CefRefPtr<WebAppRenderer> app,
- CefRefPtr<CefBrowser> browser,
- CefRefPtr<CefFrame> frame,
- CefRefPtr<CefV8Context> context) {}
- virtual void OnContextReleased(CefRefPtr<WebAppRenderer> app,
- CefRefPtr<CefBrowser> browser,
- CefRefPtr<CefFrame> frame,
- CefRefPtr<CefV8Context> context) {}
- virtual void OnUncaughtException(CefRefPtr<WebAppRenderer> app,
- CefRefPtr<CefBrowser> browser,
- CefRefPtr<CefFrame> frame,
- CefRefPtr<CefV8Context> context,
- CefRefPtr<CefV8Exception> exception,
- CefRefPtr<CefV8StackTrace> stackTrace) {}
- virtual void OnFocusedNodeChanged(CefRefPtr<WebAppRenderer> app,
- CefRefPtr<CefBrowser> browser,
- CefRefPtr<CefFrame> frame,
- CefRefPtr<CefDOMNode> 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<WebAppRenderer> app,
- CefRefPtr<CefBrowser> browser,
- CefProcessId source_process,
- CefRefPtr<CefProcessMessage> message)
- {
- return false;
- }
- };
- typedef List<CefRefPtr<Delegate>> 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<CefRenderProcessHandler> GetRenderProcessHandler() OVERRIDE {
- return this;
- }
- // CefRenderProcessHandler methods.
- void OnRenderThreadCreated(CefRefPtr<CefListValue> extra_info) OVERRIDE;
- void OnWebKitInitialized() OVERRIDE;
- void OnBrowserCreated(CefRefPtr<CefBrowser> browser) OVERRIDE;
- void OnBrowserDestroyed(CefRefPtr<CefBrowser> browser) OVERRIDE;
- CefRefPtr<CefLoadHandler> GetLoadHandler() OVERRIDE;
- bool OnBeforeNavigation(CefRefPtr<CefBrowser> browser,
- CefRefPtr<CefFrame> frame,
- CefRefPtr<CefRequest> request,
- NavigationType navigation_type,
- bool is_redirect) OVERRIDE;
- void OnContextCreated(CefRefPtr<CefBrowser> browser,
- CefRefPtr<CefFrame> frame,
- CefRefPtr<CefV8Context> context) OVERRIDE;
- void OnContextReleased(CefRefPtr<CefBrowser> browser,
- CefRefPtr<CefFrame> frame,
- CefRefPtr<CefV8Context> context) OVERRIDE;
- void OnUncaughtException(CefRefPtr<CefBrowser> browser,
- CefRefPtr<CefFrame> frame,
- CefRefPtr<CefV8Context> context,
- CefRefPtr<CefV8Exception> exception,
- CefRefPtr<CefV8StackTrace> stackTrace) OVERRIDE;
- void OnFocusedNodeChanged(CefRefPtr<CefBrowser> browser,
- CefRefPtr<CefFrame> frame,
- CefRefPtr<CefDOMNode> node) OVERRIDE;
- bool OnProcessMessageReceived(
- CefRefPtr<CefBrowser> browser,
- CefProcessId source_process,
- CefRefPtr<CefProcessMessage> message) OVERRIDE;
- private:
- // Set of supported Delegates.
- DelegateSet delegates_;
- IMPLEMENT_REFCOUNTING(WebAppRenderer);
- DISALLOW_COPY_AND_ASSIGN(WebAppRenderer);
- };
- }
|