1 // Copyright 2015 Samsung Electronics Co, Ltd. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef WRT_EXTENSION_EXTENSION_SERVER_H_
6 #define WRT_EXTENSION_EXTENSION_SERVER_H_
8 #include <ewk_ipc_message.h>
15 #include "extension/extension.h"
21 class ExtensionServer : public Extension::ExtensionDelegate {
23 typedef std::vector<std::string> StringVector;
25 explicit ExtensionServer(Ewk_Context* ewk_context);
26 virtual ~ExtensionServer();
29 void Start(const StringVector& paths);
31 void HandleWrtMessage(Ewk_IPC_Wrt_Message_Data* message);
34 void RegisterExtension(const std::string& path);
35 void RegisterSystemExtensions();
36 bool RegisterSymbols(Extension* extension);
38 void AddRuntimeVariable(const std::string& key, const std::string& value);
39 void GetRuntimeVariable(const char* key, char* value, size_t value_len);
40 void ClearRuntimeVariables();
42 void SendWrtMessage(const std::string& type);
43 void SendWrtMessage(const std::string& type, const std::string& id,
44 const std::string& ref_id, const std::string& value);
46 void OnGetExtensions(const std::string& id);
47 void OnCreateInstance(const std::string& instance_id,
48 const std::string& extension_name);
49 void OnDestroyInstance(const std::string& instance_id);
50 void OnSendSyncMessageToNative(const std::string& msg_id,
51 const std::string& instance_id,
52 const std::string& msg_body);
53 void OnPostMessageToNative(const std::string& instance_id,
54 const std::string& msg_body);
56 void OnPostMessageToJS(const std::string& instance_id,
57 const std::string& msg);
58 void OnSendSyncReplyToJS(const std::string& instance_id,
59 const std::string& msg);
61 Ewk_Context* ewk_context_;
63 typedef std::set<std::string> StringSet;
64 StringSet extension_symbols_;
66 typedef std::map<std::string, std::string> StringMap;
67 StringMap runtime_variables_;
69 typedef std::map<std::string, Extension*> ExtensionMap;
70 ExtensionMap extensions_;
72 typedef std::map<std::string, ExtensionInstance*> InstanceMap;
73 InstanceMap instances_;
78 #endif // WRT_EXTENSION_EXTENSION_SERVER_H_