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_H_
18 #define WRT_EXTENSION_EXTENSION_H_
23 #include "extension/extension_instance.h"
24 #include "extension/xwalk/XW_Extension.h"
25 #include "extension/xwalk/XW_Extension_SyncMessage.h"
29 class ExtensionAdapter;
30 class ExtensionInstance;
34 typedef std::vector<std::string> StringVector;
36 class ExtensionDelegate {
38 virtual void GetRuntimeVariable(const char* key, char* value,
39 size_t value_len) = 0;
42 Extension(const std::string& path, ExtensionDelegate* delegate);
46 ExtensionInstance* CreateInstance();
48 std::string name() const { return name_; }
50 std::string javascript_api() const { return javascript_api_; }
52 const StringVector& entry_points() const {
56 bool use_trampoline() const {
57 return use_trampoline_;
60 void set_name(const std::string& name) {
64 void set_javascript_api(const std::string& javascript_api) {
65 javascript_api_ = javascript_api;
68 void set_use_trampoline(bool use_trampoline) {
69 use_trampoline_ = use_trampoline;
73 friend class ExtensionAdapter;
74 friend class ExtensionInstance;
76 void GetRuntimeVariable(const char* key, char* value, size_t value_len);
77 int CheckAPIAccessControl(const char* api_name);
78 int RegisterPermissions(const char* perm_table);
81 std::string library_path_;
82 XW_Extension xw_extension_;
85 std::string javascript_api_;
86 StringVector entry_points_;
89 ExtensionDelegate* delegate_;
91 XW_CreatedInstanceCallback created_instance_callback_;
92 XW_DestroyedInstanceCallback destroyed_instance_callback_;
93 XW_ShutdownCallback shutdown_callback_;
94 XW_HandleMessageCallback handle_msg_callback_;
95 XW_HandleSyncMessageCallback handle_sync_msg_callback_;
100 #endif // WRT_EXTENSION_EXTENSION_H_