2 * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef WRT_EXTENSION_EXTENSION_INSTANCE_H_
18 #define WRT_EXTENSION_EXTENSION_INSTANCE_H_
23 #include "extension/xwalk/XW_Extension.h"
29 class ExtensionInstance {
31 typedef std::function<void(const std::string&)> MessageCallback;
33 ExtensionInstance(Extension* extension, XW_Instance xw_instance);
34 virtual ~ExtensionInstance();
36 void HandleMessage(const std::string& msg);
37 void HandleSyncMessage(const std::string& msg);
39 void SetPostMessageCallback(MessageCallback callback);
40 void SetSendSyncReplyCallback(MessageCallback callback);
43 friend class ExtensionAdapter;
45 void PostMessageToJS(const std::string& msg);
46 void SyncReplyToJS(const std::string& reply);
48 Extension* extension_;
49 XW_Instance xw_instance_;
52 MessageCallback post_message_callback_;
53 MessageCallback send_sync_reply_callback_;
58 #endif // WRT_EXTENSION_EXTENSION_INSTANCE_H_