Revert "Resolving memory leak issue in Reply function of AppControl"
[platform/framework/web/crosswalk-tizen.git] / common / application_data.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 XWALK_COMMON_APPLICATION_DATA_H_
18 #define XWALK_COMMON_APPLICATION_DATA_H_
19
20 #include <wgt_manifest_handlers/application_icons_handler.h>
21 #include <wgt_manifest_handlers/appwidget_handler.h>
22 #include <wgt_manifest_handlers/app_control_handler.h>
23 #include <wgt_manifest_handlers/category_handler.h>
24 #include <wgt_manifest_handlers/content_handler.h>
25 #include <wgt_manifest_handlers/csp_handler.h>
26 #include <wgt_manifest_handlers/ime_handler.h>
27 #include <wgt_manifest_handlers/launch_screen_handler.h>
28 #include <wgt_manifest_handlers/metadata_handler.h>
29 #include <wgt_manifest_handlers/navigation_handler.h>
30 #include <wgt_manifest_handlers/permissions_handler.h>
31 #include <wgt_manifest_handlers/profile_tag_handler.h>
32 #include <wgt_manifest_handlers/service_handler.h>
33 #include <wgt_manifest_handlers/setting_handler.h>
34 #include <wgt_manifest_handlers/tizen_application_handler.h>
35 #include <wgt_manifest_handlers/warp_handler.h>
36 #include <wgt_manifest_handlers/widget_handler.h>
37
38 #include <memory>
39 #include <string>
40
41 namespace common {
42
43 class ApplicationData {
44  public:
45   enum AppType {
46     UI = 0
47     ,IME
48     ,WATCH
49   };
50
51   explicit ApplicationData(const std::string& appid);
52   ~ApplicationData();
53
54   bool LoadManifestData();
55
56   std::shared_ptr<const wgt::parse::AppControlInfoList>
57     app_control_info_list() const;
58   std::shared_ptr<const wgt::parse::CategoryInfoList>
59     category_info_list() const;
60   std::shared_ptr<const wgt::parse::MetaDataInfo>
61     meta_data_info() const;
62   std::shared_ptr<const wgt::parse::AllowedNavigationInfo>
63     allowed_navigation_info() const;
64   std::shared_ptr<const wgt::parse::PermissionsInfo>
65     permissions_info() const;
66   std::shared_ptr<const wgt::parse::SettingInfo>
67     setting_info() const;
68   std::shared_ptr<const wgt::parse::LaunchScreenInfo>
69     splash_screen_info() const;
70   std::shared_ptr<const wgt::parse::TizenApplicationInfo>
71     tizen_application_info() const;
72   std::shared_ptr<const wgt::parse::WidgetInfo>
73     widget_info() const;
74   std::shared_ptr<const wgt::parse::ContentInfo>
75     content_info() const;
76   std::shared_ptr<const wgt::parse::WarpInfo>
77     warp_info() const;
78   std::shared_ptr<const wgt::parse::CSPInfo>
79     csp_info() const;
80   std::shared_ptr<const wgt::parse::CSPInfo>
81     csp_report_info() const;
82   std::shared_ptr<const wgt::parse::ProfileTagInfo>
83     profile_tag_info() const;
84
85   const std::string application_path() const { return application_path_; }
86   const std::string pkg_id() const;
87   const std::string app_id() const { return app_id_; }
88   ApplicationData::AppType app_type() { return app_type_; }
89
90  private:
91   std::shared_ptr<const wgt::parse::AppControlInfoList>
92     app_control_info_list_;
93   std::shared_ptr<const wgt::parse::CategoryInfoList>
94     category_info_list_;
95   std::shared_ptr<const wgt::parse::MetaDataInfo>
96     meta_data_info_;
97   std::shared_ptr<const wgt::parse::AllowedNavigationInfo>
98     allowed_navigation_info_;
99   std::shared_ptr<const wgt::parse::PermissionsInfo>
100     permissions_info_;
101   std::shared_ptr<const wgt::parse::SettingInfo>
102     setting_info_;
103   std::shared_ptr<const wgt::parse::LaunchScreenInfo>
104     splash_screen_info_;
105   std::shared_ptr<const wgt::parse::TizenApplicationInfo>
106     tizen_application_info_;
107   std::shared_ptr<const wgt::parse::WidgetInfo>
108     widget_info_;
109   std::shared_ptr<const wgt::parse::ContentInfo>
110     content_info_;
111   std::shared_ptr<const wgt::parse::WarpInfo>
112     warp_info_;
113   std::shared_ptr<const wgt::parse::CSPInfo>
114     csp_info_;
115   std::shared_ptr<const wgt::parse::CSPInfo>
116     csp_report_info_;
117
118   std::shared_ptr<const wgt::parse::ProfileTagInfo>
119     profile_tag_info_;
120
121   ApplicationData::AppType GetAppType();
122
123   std::string application_path_;
124   mutable std::string pkg_id_;
125   std::string app_id_;
126   ApplicationData::AppType app_type_;
127   bool loaded_;
128 };
129
130
131 class ApplicationDataManager {
132  public:
133   static ApplicationDataManager* GetInstance();
134
135   ApplicationData* GetApplicationData(const std::string& appid);
136
137  private:
138   ApplicationDataManager();
139   virtual ~ApplicationDataManager();
140
141   std::map<std::string, std::unique_ptr<ApplicationData>> cache_;
142 };
143
144
145 }  // namespace common
146
147 #endif  // XWALK_COMMON_APPLICATION_DATA_H_