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/encryption/resource_decryption.h>
33 #include <dpl/wrt-dao-ro/widget_dao_read_only.h>
36 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;
76 WRTDecryptor::ResourceDecryptor *m_resDec;
77 WrtDB::EncryptedFileList m_encryptedFiles;
78 WrtDB::WidgetType m_widgetType;
80 // WKBundlePageResourceLoadClient callback
81 static WKURLRequestRef willSendRequestForFrameCallback(
84 uint64_t resourceIdentifier,
85 WKURLRequestRef request,
87 const void *clientInfo);
88 static void didFinishLoadForResourceCallback(
90 WKBundleFrameRef frame,
91 uint64_t resourceIdentifier,
92 const void* clientInfo);
94 // WKBundlePageDidStartProvisionalLoadForFrame callback
95 static void didStartProvisionalLoadForFrameCallback(
97 WKBundleFrameRef frame,
99 const void *clientInfo);
101 // WKBundlePageDidRemoveFrameFromHierarchy callback
102 static void didRemoveFrameFromHierarchyCallback(
103 WKBundlePageRef page,
104 WKBundleFrameRef frame,
106 const void *clientInfo);
108 // WKBundlePageLoaderClient callback
109 static void didCommitLoadForFrameCallback(
110 WKBundlePageRef page,
111 WKBundleFrameRef frame,
113 const void *clientInfo);
115 // WKBundlePageDecidePolicyForNavigationActionCallback
116 static WKBundlePagePolicyAction pageDecidePolicyForNavigationActionCallback(
117 WKBundlePageRef page,
118 WKBundleFrameRef frame,
119 WKBundleNavigationActionRef navigationAction,
120 WKURLRequestRef request,
122 const void* clientInfo);
124 // WKBundlePageDecidePolicyForResponseCallback
125 static WKBundlePagePolicyAction pageDecidePolicyForResponseCallback(
126 WKBundlePageRef page,
127 WKBundleFrameRef frame,
128 WKURLResponseRef response,
129 WKURLRequestRef request,
131 const void* clientInfo);
134 void didCreatePage(WKBundlePageRef page);
135 void willDestroyPage(WKBundlePageRef page);
136 void didReceiveMessage(
137 WKStringRef messageName,
138 WKTypeRef messageBody);
140 // WKBundlePageResourceLoadClient
141 WKURLRequestRef willSendRequestForFrame(WKURLRequestRef request);
142 WKBundlePagePolicyAction pageDecidePolicyForNavigationAction(
143 WKBundlePageRef page,
144 WKBundleFrameRef frame,
145 WKBundleNavigationActionRef navigationAction,
146 WKURLRequestRef request,
147 WKTypeRef* userData);
150 static std::string toString(WKStringRef str);
151 static std::string toString(WKURLRef url);
152 static std::string toString(WKURLRequestRef req);
153 static std::string toString(WKErrorRef err);
154 static std::string getScheme(std::string uri);
156 bool isEncryptedResource(std::string Url, int &size);
157 std::string DecryptResource(std::string resource, int size);
159 void fixWKMessageArgs(std::string & argScale,
160 std::string & argEncodedBundle, std::string & argTheme);
162 void requestSuspend();
163 void requestResume();
165 void connectLoaderClientCallbacksToPage(WKBundlePageRef page);
170 #endif /* WRT_SRC_VIEW_WEBKIT2_WRT_WK2_BUNDLE_H_ */