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;
43 class ViewmodesSupport;
49 Bundle(WKBundleRef bundle);
52 Bundle(const Bundle&) = delete;
53 Bundle& operator=(const Bundle&) = delete;
55 // WKBundleClient callback
56 static void didCreatePageCallback(
59 const void* clientInfo);
60 static void willDestroyPageCallback(
63 const void* clientInfo);
64 static void didReceiveMessageCallback(
66 WKStringRef messageName,
67 WKTypeRef messageBody,
68 const void *clientInfo);
73 typedef std::list<WKBundlePageRef> PagesList;
74 PagesList m_pagesList;
75 typedef std::set<JSGlobalContextRef> ContextSet;
76 typedef std::map<WKBundlePageRef, ContextSet> PageContextList;
77 PageContextList m_pageContext;
78 PageGlobalContextContainer m_pageGlobalContext;
79 DPL::String m_widgetTizenId;
81 std::string m_encodedBundle;
83 std::set<JSGlobalContextRef> m_loadedContext;
84 JSGlobalContextRef m_willRemoveContext;
85 WrtDB::WidgetSecurityModelVersion m_securityModelVersion;
88 std::unique_ptr<InjectedBundle::DecryptionSupport> m_decryptionSupport;
89 std::unique_ptr<InjectedBundle::ViewmodesSupport> m_viewmodesSupport;
91 // WKBundlePageResourceLoadClient callback
92 static WKURLRequestRef willSendRequestForFrameCallback(
95 uint64_t resourceIdentifier,
96 WKURLRequestRef request,
98 const void *clientInfo);
99 static void didFinishLoadForResourceCallback(
100 WKBundlePageRef page,
101 WKBundleFrameRef frame,
102 uint64_t resourceIdentifier,
103 const void* clientInfo);
105 // WKBundlePageDidStartProvisionalLoadForFrame callback
106 static void didStartProvisionalLoadForFrameCallback(
107 WKBundlePageRef page,
108 WKBundleFrameRef frame,
110 const void *clientInfo);
112 // WKBundlePageDidRemoveFrameFromHierarchy callback
113 static void didRemoveFrameFromHierarchyCallback(
114 WKBundlePageRef page,
115 WKBundleFrameRef frame,
117 const void *clientInfo);
119 // WKBundlePageLoaderClient callback
120 static void didCommitLoadForFrameCallback(
121 WKBundlePageRef page,
122 WKBundleFrameRef frame,
124 const void *clientInfo);
126 // WKBundlePageDecidePolicyForNavigationActionCallback
127 static WKBundlePagePolicyAction decidePolicyForNavigationActionCallback(
128 WKBundlePageRef page,
129 WKBundleFrameRef frame,
130 WKBundleNavigationActionRef navigationAction,
131 WKURLRequestRef request,
133 const void* clientInfo);
135 // WKBundlePageDecidePolicyForNewWindowActionCallback
136 static WKBundlePagePolicyAction decidePolicyForNewWindowActionCallback(
137 WKBundlePageRef page,
138 WKBundleFrameRef frame,
139 WKBundleNavigationActionRef navigationAction,
140 WKURLRequestRef request,
141 WKStringRef frameName,
143 const void* clientInfo);
145 // WKBundlePageDecidePolicyForResponseCallback
146 static WKBundlePagePolicyAction decidePolicyForResponseCallback(
147 WKBundlePageRef page,
148 WKBundleFrameRef frame,
149 WKURLResponseRef response,
150 WKURLRequestRef request,
152 const void* clientInfo);
155 void didCreatePage(WKBundlePageRef page);
156 void willDestroyPage(WKBundlePageRef page);
157 void didReceiveMessage(
158 WKStringRef messageName,
159 WKTypeRef messageBody);
161 // WKBundlePageResourceLoadClient
162 WKURLRequestRef willSendRequestForFrame(WKURLRequestRef request);
163 WKBundlePagePolicyAction decidePolicyForAction(
165 WKBundlePageRef page,
166 WKBundleFrameRef frame,
167 WKBundleNavigationActionRef navigationAction,
168 WKURLRequestRef request,
169 WKTypeRef* userData);
172 inline static std::string toString(WKStringRef str);
173 inline static std::string toString(WKURLRef url);
174 inline static std::string toString(WKURLRequestRef req);
175 inline static std::string toString(WKErrorRef err);
176 static std::string getScheme(std::string uri);
178 bool isEncryptedResource(std::string Url, int &size);
179 std::string DecryptResource(std::string resource, int size);
181 void fixWKMessageArgs(std::string & argScale,
182 std::string & argEncodedBundle,
183 std::string & argTheme);
186 #ifdef MULTIPROCESS_SERVICE_SUPPORT_INLINE
187 void sendWebProcessPid();
189 #ifdef CORS_WHITELISTING_ENABLED
190 void bypassCORSforWARPAccessList(WrtDB::WidgetDAOReadOnly &dao);
194 #endif // WRT_SRC_VIEW_WEBKIT_WRT_INJECTED_BUNDLE_H_