// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights // reserved. Use of this source code is governed by a BSD-style license that // can be found in the LICENSE file. #ifndef CEF_TESTS_CEFCLIENT_RENDERER_CLIENT_APP_RENDERER_H_ #define CEF_TESTS_CEFCLIENT_RENDERER_CLIENT_APP_RENDERER_H_ #pragma once #include #include "cefclient/common/client_app.h" namespace client { // Client app implementation for the renderer process. class ClientAppRenderer : public ClientApp, 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 std::set > DelegateSet; ClientAppRenderer(); 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(ClientAppRenderer); DISALLOW_COPY_AND_ASSIGN(ClientAppRenderer); }; } // namespace client #endif // CEF_TESTS_CEFCLIENT_RENDERER_CLIENT_APP_RENDERER_H_