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-injected-bundle.h
18 * @author Jihoon Chung (jihoon.chung@samsung.com)
19 * @brief declare injected bundle
21 #ifndef WRT_SRC_VIEW_WEBKIT_WRT_INJECTED_BUNDLE_H_
22 #define WRT_SRC_VIEW_WEBKIT_WRT_INJECTED_BUNDLE_H_
30 #include <WKPageLoadTypes.h>
31 #include <WKBundlePage.h>
32 #include <dpl/string.h>
33 #include <dpl/wrt-dao-ro/widget_dao_read_only.h>
34 #include <dpl/wrt-dao-ro/common_dao_types.h>
35 #include "page_global_context_container.h"
38 WK_EXPORT void WKBundleInitialize(WKBundleRef bundle, WKTypeRef);
41 namespace InjectedBundle {
42 class DecryptionSupport;
48 Bundle(WKBundleRef bundle);
51 Bundle(const Bundle&) = delete;
52 Bundle& operator=(const Bundle&) = delete;
54 // WKBundleClient callback
55 static void didCreatePageCallback(
58 const void* clientInfo);
59 static void willDestroyPageCallback(
62 const void* clientInfo);
63 static void didReceiveMessageCallback(
65 WKStringRef messageName,
66 WKTypeRef messageBody,
67 const void *clientInfo);
72 typedef std::list<WKBundlePageRef> PagesList;
73 PagesList m_pagesList;
74 typedef std::set<JSGlobalContextRef> ContextSet;
75 typedef std::map<WKBundlePageRef, ContextSet> PageContextList;
76 PageContextList m_pageContext;
77 PageGlobalContextContainer m_pageGlobalContext;
78 DPL::String m_widgetTizenId;
80 std::string m_encodedBundle;
82 std::set<JSGlobalContextRef> m_loadedContext;
83 JSGlobalContextRef m_willRemoveContext;
84 WrtDB::WidgetType m_widgetType;
85 WrtDB::WidgetSecurityModelVersion m_securityModelVersion;
88 std::unique_ptr<InjectedBundle::DecryptionSupport> m_decryptionSupport;
90 // WKBundlePageResourceLoadClient callback
91 static WKURLRequestRef willSendRequestForFrameCallback(
94 uint64_t resourceIdentifier,
95 WKURLRequestRef request,
97 const void *clientInfo);
98 static void didFinishLoadForResourceCallback(
100 WKBundleFrameRef frame,
101 uint64_t resourceIdentifier,
102 const void* clientInfo);
104 // WKBundlePageDidStartProvisionalLoadForFrame callback
105 static void didStartProvisionalLoadForFrameCallback(
106 WKBundlePageRef page,
107 WKBundleFrameRef frame,
109 const void *clientInfo);
111 // WKBundlePageDidRemoveFrameFromHierarchy callback
112 static void didRemoveFrameFromHierarchyCallback(
113 WKBundlePageRef page,
114 WKBundleFrameRef frame,
116 const void *clientInfo);
118 // WKBundlePageLoaderClient callback
119 static void didCommitLoadForFrameCallback(
120 WKBundlePageRef page,
121 WKBundleFrameRef frame,
123 const void *clientInfo);
125 // WKBundlePageDecidePolicyForNavigationActionCallback
126 static WKBundlePagePolicyAction decidePolicyForNavigationActionCallback(
127 WKBundlePageRef page,
128 WKBundleFrameRef frame,
129 WKBundleNavigationActionRef navigationAction,
130 WKURLRequestRef request,
132 const void* clientInfo);
134 // WKBundlePageDecidePolicyForNewWindowActionCallback
135 static WKBundlePagePolicyAction decidePolicyForNewWindowActionCallback(
136 WKBundlePageRef page,
137 WKBundleFrameRef frame,
138 WKBundleNavigationActionRef navigationAction,
139 WKURLRequestRef request,
140 WKStringRef frameName,
142 const void* clientInfo);
144 // WKBundlePageDecidePolicyForResponseCallback
145 static WKBundlePagePolicyAction decidePolicyForResponseCallback(
146 WKBundlePageRef page,
147 WKBundleFrameRef frame,
148 WKURLResponseRef response,
149 WKURLRequestRef request,
151 const void* clientInfo);
154 void didCreatePage(WKBundlePageRef page);
155 void willDestroyPage(WKBundlePageRef page);
156 void didReceiveMessage(
157 WKStringRef messageName,
158 WKTypeRef messageBody);
160 // WKBundlePageResourceLoadClient
161 WKURLRequestRef willSendRequestForFrame(WKURLRequestRef request);
162 WKBundlePagePolicyAction decidePolicyForAction(
164 WKBundlePageRef page,
165 WKBundleFrameRef frame,
166 WKBundleNavigationActionRef navigationAction,
167 WKURLRequestRef request,
168 WKTypeRef* userData);
171 inline static std::string toString(WKStringRef str);
172 inline static std::string toString(WKURLRef url);
173 inline static std::string toString(WKURLRequestRef req);
174 inline static std::string toString(WKErrorRef err);
175 static std::string getScheme(std::string uri);
177 bool isEncryptedResource(std::string Url, int &size);
178 std::string DecryptResource(std::string resource, int size);
180 void fixWKMessageArgs(std::string & argScale,
181 std::string & argEncodedBundle,
182 std::string & argTheme);
185 #ifdef MULTIPROCESS_SERVICE_SUPPORT_INLINE
186 void sendWebProcessPid();
189 #ifdef CORS_WHITELISTING_ENABLED
190 void bypassCORSforWARPAccessList(WrtDB::WidgetDAOReadOnly &dao);
194 #endif // WRT_SRC_VIEW_WEBKIT_WRT_INJECTED_BUNDLE_H_