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::WidgetType m_widgetType;
86 WrtDB::WidgetSecurityModelVersion m_securityModelVersion;
89 std::unique_ptr<InjectedBundle::DecryptionSupport> m_decryptionSupport;
90 std::unique_ptr<InjectedBundle::ViewmodesSupport> m_viewmodesSupport;
92 // WKBundlePageResourceLoadClient callback
93 static WKURLRequestRef willSendRequestForFrameCallback(
96 uint64_t resourceIdentifier,
97 WKURLRequestRef request,
99 const void *clientInfo);
100 static void didFinishLoadForResourceCallback(
101 WKBundlePageRef page,
102 WKBundleFrameRef frame,
103 uint64_t resourceIdentifier,
104 const void* clientInfo);
106 // WKBundlePageDidStartProvisionalLoadForFrame callback
107 static void didStartProvisionalLoadForFrameCallback(
108 WKBundlePageRef page,
109 WKBundleFrameRef frame,
111 const void *clientInfo);
113 // WKBundlePageDidRemoveFrameFromHierarchy callback
114 static void didRemoveFrameFromHierarchyCallback(
115 WKBundlePageRef page,
116 WKBundleFrameRef frame,
118 const void *clientInfo);
120 // WKBundlePageLoaderClient callback
121 static void didCommitLoadForFrameCallback(
122 WKBundlePageRef page,
123 WKBundleFrameRef frame,
125 const void *clientInfo);
127 // WKBundlePageDecidePolicyForNavigationActionCallback
128 static WKBundlePagePolicyAction decidePolicyForNavigationActionCallback(
129 WKBundlePageRef page,
130 WKBundleFrameRef frame,
131 WKBundleNavigationActionRef navigationAction,
132 WKURLRequestRef request,
134 const void* clientInfo);
136 // WKBundlePageDecidePolicyForNewWindowActionCallback
137 static WKBundlePagePolicyAction decidePolicyForNewWindowActionCallback(
138 WKBundlePageRef page,
139 WKBundleFrameRef frame,
140 WKBundleNavigationActionRef navigationAction,
141 WKURLRequestRef request,
142 WKStringRef frameName,
144 const void* clientInfo);
146 // WKBundlePageDecidePolicyForResponseCallback
147 static WKBundlePagePolicyAction decidePolicyForResponseCallback(
148 WKBundlePageRef page,
149 WKBundleFrameRef frame,
150 WKURLResponseRef response,
151 WKURLRequestRef request,
153 const void* clientInfo);
156 void didCreatePage(WKBundlePageRef page);
157 void willDestroyPage(WKBundlePageRef page);
158 void didReceiveMessage(
159 WKStringRef messageName,
160 WKTypeRef messageBody);
162 // WKBundlePageResourceLoadClient
163 WKURLRequestRef willSendRequestForFrame(WKURLRequestRef request);
164 WKBundlePagePolicyAction decidePolicyForAction(
166 WKBundlePageRef page,
167 WKBundleFrameRef frame,
168 WKBundleNavigationActionRef navigationAction,
169 WKURLRequestRef request,
170 WKTypeRef* userData);
173 inline static std::string toString(WKStringRef str);
174 inline static std::string toString(WKURLRef url);
175 inline static std::string toString(WKURLRequestRef req);
176 inline static std::string toString(WKErrorRef err);
177 static std::string getScheme(std::string uri);
179 bool isEncryptedResource(std::string Url, int &size);
180 std::string DecryptResource(std::string resource, int size);
182 void fixWKMessageArgs(std::string & argScale,
183 std::string & argEncodedBundle,
184 std::string & argTheme);
187 #ifdef MULTIPROCESS_SERVICE_SUPPORT_INLINE
188 void sendWebProcessPid();
190 #ifdef CORS_WHITELISTING_ENABLED
191 void bypassCORSforWARPAccessList(WrtDB::WidgetDAOReadOnly &dao);
195 #endif // WRT_SRC_VIEW_WEBKIT_WRT_INJECTED_BUNDLE_H_