#ifndef __METHOD_DISPATCHER_H__ #define __METHOD_DISPATCHER_H__ #include #include #include using namespace Awesomium; class Application; typedef std::pair ObjectMethodKey; typedef std::function ObjectMethodDelegate; typedef std::function ObjectMethodWithRetvalDelegate; typedef std::map BoundMethodMap; typedef std::map BoundMethodWithRetvalMap; class MethodDispatcher : public JSMethodHandler { public: MethodDispatcher(Application* app); void Bind(JSObject& object, const WebString& name, ObjectMethodDelegate callback); void BindWithRetval(JSObject& object, const WebString& name, ObjectMethodWithRetvalDelegate callback); // Inherited from JSMethodHandler void OnMethodCall(Awesomium::WebView* caller, unsigned int remote_object_id, const Awesomium::WebString& method_name, const Awesomium::JSArray& args); // Inherited from JSMethodHandler JSValue OnMethodCallWithReturnValue(Awesomium::WebView* caller, unsigned int remote_object_id, const Awesomium::WebString& method_name, const Awesomium::JSArray& args); protected: Application* app_; BoundMethodMap bound_methods_; BoundMethodWithRetvalMap bound_methods_with_retval_; }; #endif // __METHOD_DISPATCHER_H__