2 * Copyright (c) 2011 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 * @file wrt-wk2-bundle.h
18 * @author Jihoon Chung (jihoon.chung@samsung.com)
19 * @brief declare bundle for WK2
21 #ifndef WRT_SRC_VIEW_WEBKIT2_WRT_WK2_BUNDLE_H_
22 #define WRT_SRC_VIEW_WEBKIT2_WRT_WK2_BUNDLE_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>
35 WK_EXPORT void WKBundleInitialize(WKBundleRef bundle, WKTypeRef);
41 Bundle(WKBundleRef bundle);
44 // WKBundleClient callback
45 static void didCreatePageCallback(
48 const void* clientInfo);
49 static void willDestroyPageCallback(
52 const void* clientInfo);
53 static void didReceiveMessageCallback(
55 WKStringRef messageName,
56 WKTypeRef messageBody,
57 const void *clientInfo);
60 WKStringRef m_uriChangedMessage;
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;
72 std::string m_encodedBundle;
74 std::set<JSGlobalContextRef> m_loadedContext;
75 JSGlobalContextRef m_willRemoveContext;
77 WrtDB::EncryptedFileList m_encryptedFiles;
78 WrtDB::WidgetType m_widgetType;
81 // WKBundlePageResourceLoadClient callback
82 static WKURLRequestRef willSendRequestForFrameCallback(
85 uint64_t resourceIdentifier,
86 WKURLRequestRef request,
88 const void *clientInfo);
89 static void didFinishLoadForResourceCallback(
91 WKBundleFrameRef frame,
92 uint64_t resourceIdentifier,
93 const void* clientInfo);
95 // WKBundlePageDidStartProvisionalLoadForFrame callback
96 static void didStartProvisionalLoadForFrameCallback(
98 WKBundleFrameRef frame,
100 const void *clientInfo);
102 // WKBundlePageDidRemoveFrameFromHierarchy callback
103 static void didRemoveFrameFromHierarchyCallback(
104 WKBundlePageRef page,
105 WKBundleFrameRef frame,
107 const void *clientInfo);
109 // WKBundlePageLoaderClient callback
110 static void didCommitLoadForFrameCallback(
111 WKBundlePageRef page,
112 WKBundleFrameRef frame,
114 const void *clientInfo);
116 // WKBundlePageDecidePolicyForNavigationActionCallback
117 static WKBundlePagePolicyAction pageDecidePolicyForNavigationActionCallback(
118 WKBundlePageRef page,
119 WKBundleFrameRef frame,
120 WKBundleNavigationActionRef navigationAction,
121 WKURLRequestRef request,
123 const void* clientInfo);
125 // WKBundlePageDecidePolicyForResponseCallback
126 static WKBundlePagePolicyAction pageDecidePolicyForResponseCallback(
127 WKBundlePageRef page,
128 WKBundleFrameRef frame,
129 WKURLResponseRef response,
130 WKURLRequestRef request,
132 const void* clientInfo);
135 void didCreatePage(WKBundlePageRef page);
136 void willDestroyPage(WKBundlePageRef page);
137 void didReceiveMessage(
138 WKStringRef messageName,
139 WKTypeRef messageBody);
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);
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);
157 bool isEncryptedResource(std::string Url, int &size);
158 std::string DecryptResource(std::string resource, int size);
160 void fixWKMessageArgs(std::string & argScale,
161 std::string & argEncodedBundle,
162 std::string & argTheme);
165 #endif /* WRT_SRC_VIEW_WEBKIT2_WRT_WK2_BUNDLE_H_ */