Fix invalid licenses
[platform/framework/web/crosswalk-tizen.git] / src / extension / extension.h
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #ifndef WRT_EXTENSION_EXTENSION_H_
18 #define WRT_EXTENSION_EXTENSION_H_
19
20 #include <string>
21 #include <vector>
22
23 #include "extension/extension_instance.h"
24 #include "extension/xwalk/XW_Extension.h"
25 #include "extension/xwalk/XW_Extension_SyncMessage.h"
26
27 namespace wrt {
28
29 class ExtensionAdapter;
30 class ExtensionInstance;
31
32 class Extension {
33  public:
34   typedef std::vector<std::string> StringVector;
35
36   class ExtensionDelegate {
37    public:
38     virtual void GetRuntimeVariable(const char* key, char* value,
39         size_t value_len) = 0;
40   };
41
42   Extension(const std::string& path, ExtensionDelegate* delegate);
43   virtual ~Extension();
44
45   bool Initialize();
46   ExtensionInstance* CreateInstance();
47
48   std::string name() const { return name_; }
49
50   std::string javascript_api() const { return javascript_api_; }
51
52   const StringVector& entry_points() const {
53     return entry_points_;
54   }
55
56   bool use_trampoline() const {
57     return use_trampoline_;
58   }
59
60   void set_name(const std::string& name) {
61     name_ = name;
62   }
63
64   void set_javascript_api(const std::string& javascript_api) {
65     javascript_api_ = javascript_api;
66   }
67
68   void set_use_trampoline(bool use_trampoline) {
69     use_trampoline_ = use_trampoline;
70   }
71
72  private:
73   friend class ExtensionAdapter;
74   friend class ExtensionInstance;
75
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);
79
80   bool initialized_;
81   std::string library_path_;
82   XW_Extension xw_extension_;
83
84   std::string name_;
85   std::string javascript_api_;
86   StringVector entry_points_;
87   bool use_trampoline_;
88
89   ExtensionDelegate* delegate_;
90
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_;
96 };
97
98 }  // namespace wrt
99
100 #endif  // WRT_EXTENSION_EXTENSION_H_