Fixed decryption logic
[platform/framework/web/wrt.git] / src / view / webkit / bundles / wrt-wk2-bundle.h
1 /*
2  * Copyright (c) 2011 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  * @file wrt-wk2-bundle.h
18  * @author Jihoon Chung (jihoon.chung@samsung.com)
19  * @brief declare bundle for WK2
20  */
21 #ifndef WRT_SRC_VIEW_WEBKIT2_WRT_WK2_BUNDLE_H_
22 #define WRT_SRC_VIEW_WEBKIT2_WRT_WK2_BUNDLE_H_
23
24 #include <set>
25 #include <map>
26 #include <list>
27 #include <string>
28 #include <WKBundle.h>
29 #include <WKPageLoadTypes.h>
30 #include <WKBundlePage.h>
31 #include <dpl/string.h>
32 #include <dpl/wrt-dao-ro/widget_dao_read_only.h>
33
34 extern "C" {
35 WK_EXPORT void WKBundleInitialize(WKBundleRef bundle, WKTypeRef);
36 }
37
38 class Bundle
39 {
40   public:
41     Bundle(WKBundleRef bundle);
42     ~Bundle();
43
44     // WKBundleClient callback
45     static void didCreatePageCallback(
46         WKBundleRef bundle,
47         WKBundlePageRef page,
48         const void* clientInfo);
49     static void willDestroyPageCallback(
50         WKBundleRef bundle,
51         WKBundlePageRef page,
52         const void* clientInfo);
53     static void didReceiveMessageCallback(
54         WKBundleRef,
55         WKStringRef messageName,
56         WKTypeRef messageBody,
57         const void *clientInfo);
58
59   private:
60     WKStringRef m_uriChangedMessage;
61     WKBundleRef m_bundle;
62
63     typedef std::list<WKBundlePageRef> PagesList;
64     PagesList m_pagesList;
65     typedef std::set<JSGlobalContextRef> ContextSet;
66     typedef std::map<WKBundlePageRef, ContextSet> PageContextList;
67     typedef std::map<WKBundlePageRef, JSGlobalContextRef> PageGlobalContext;
68     PageContextList m_pageContext;
69     PageGlobalContext m_pageGlobalContext;
70     DPL::String m_widgetTizenId;
71     double m_scale;
72     std::string m_encodedBundle;
73     std::string m_theme;
74     std::set<JSGlobalContextRef> m_loadedContext;
75     JSGlobalContextRef m_willRemoveContext;
76     bool m_encrypted;
77     WrtDB::EncryptedFileList m_encryptedFiles;
78     WrtDB::WidgetType m_widgetType;
79         bool m_initialized;
80
81     // WKBundlePageResourceLoadClient callback
82     static WKURLRequestRef willSendRequestForFrameCallback(
83         WKBundlePageRef,
84         WKBundleFrameRef,
85         uint64_t resourceIdentifier,
86         WKURLRequestRef request,
87         WKURLResponseRef,
88         const void *clientInfo);
89     static void didFinishLoadForResourceCallback(
90         WKBundlePageRef page,
91         WKBundleFrameRef frame,
92         uint64_t resourceIdentifier,
93         const void* clientInfo);
94
95     // WKBundlePageDidStartProvisionalLoadForFrame callback
96     static void didStartProvisionalLoadForFrameCallback(
97         WKBundlePageRef page,
98         WKBundleFrameRef frame,
99         WKTypeRef* userData,
100         const void *clientInfo);
101
102     // WKBundlePageDidRemoveFrameFromHierarchy callback
103     static void didRemoveFrameFromHierarchyCallback(
104         WKBundlePageRef page,
105         WKBundleFrameRef frame,
106         WKTypeRef* userData,
107         const void *clientInfo);
108
109     // WKBundlePageLoaderClient callback
110     static void didCommitLoadForFrameCallback(
111         WKBundlePageRef page,
112         WKBundleFrameRef frame,
113         WKTypeRef*,
114         const void *clientInfo);
115
116     // WKBundlePageDecidePolicyForNavigationActionCallback
117     static WKBundlePagePolicyAction pageDecidePolicyForNavigationActionCallback(
118         WKBundlePageRef page,
119         WKBundleFrameRef frame,
120         WKBundleNavigationActionRef navigationAction,
121         WKURLRequestRef request,
122         WKTypeRef* userData,
123         const void* clientInfo);
124
125     // WKBundlePageDecidePolicyForResponseCallback
126     static WKBundlePagePolicyAction pageDecidePolicyForResponseCallback(
127         WKBundlePageRef page,
128         WKBundleFrameRef frame,
129         WKURLResponseRef response,
130         WKURLRequestRef request,
131         WKTypeRef* userData,
132         const void* clientInfo);
133
134     // WKBundleClient
135     void didCreatePage(WKBundlePageRef page);
136     void willDestroyPage(WKBundlePageRef page);
137     void didReceiveMessage(
138         WKStringRef messageName,
139         WKTypeRef messageBody);
140
141     // WKBundlePageResourceLoadClient
142     WKURLRequestRef willSendRequestForFrame(WKURLRequestRef request);
143     WKBundlePagePolicyAction pageDecidePolicyForNavigationAction(
144         WKBundlePageRef page,
145         WKBundleFrameRef frame,
146         WKBundleNavigationActionRef navigationAction,
147         WKURLRequestRef request,
148         WKTypeRef*                  userData);
149
150     // basic
151     static std::string toString(WKStringRef str);
152     static std::string toString(WKURLRef url);
153     static std::string toString(WKURLRequestRef req);
154     static std::string toString(WKErrorRef err);
155     static std::string getScheme(std::string uri);
156
157     bool isEncryptedResource(std::string Url, int &size);
158     std::string DecryptResource(std::string resource, int size);
159
160     void fixWKMessageArgs(std::string & argScale,
161                           std::string & argEncodedBundle,
162                           std::string & argTheme);
163 };
164
165 #endif /* WRT_SRC_VIEW_WEBKIT2_WRT_WK2_BUNDLE_H_ */