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.
18 * @author Lukasz Wrzosek (l.wrzosek@samsung.com)
19 * @brief Declaration file for view logic for Webkit2
25 #include <i_view_module.h>
29 #include <dpl/log/log.h>
30 #include <dpl/assert.h>
32 #include <widget_model.h>
33 #include <i_runnable_widget_object.h>
34 #include <common/view_logic_apps_support.h>
35 #include <common/view_logic_vibration_support.h>
40 namespace ViewModule {
41 class SecurityOriginSupport;
42 class CertificateSupport;
45 class ViewLogic : public ViewModule::IViewModule
52 bool createWebView(Ewk_Context* context,
54 void destroyWebView();
55 void prepareView(WidgetModel* m, const std::string &startUrl);
62 void reloadStartPage();
63 Evas_Object* getCurrentWebview();
64 void fireJavascriptEvent(int event, void* data);
65 void setUserCallbacks(const WRT::UserDelegatesPtr& cbs);
66 void checkSyncMessageFromBundle(
70 void downloadData(const char* url);
71 void activateVibration(bool on, uint64_t time);
75 void initializeSupport();
76 void initializePluginLoading();
79 void ewkClientInit(Evas_Object *wkView);
80 void ewkClientDeinit(Evas_Object *wkView);
81 bool createEwkView(Evas* canvas);
83 void prepareEwkView(Evas_Object *wkView);
84 void removeEwkView(Evas_Object *wkView);
85 void resumeEwkView(Evas_Object *wkView);
86 void suspendEwkView(Evas_Object *wkView);
87 void setEwkViewVisible(Evas_Object *wkView);
88 void setEwkViewInvisible(Evas_Object *wkView);
89 void resumeWebkit(Evas_Object *wkView);
90 void suspendWebkit(Evas_Object *wkView);
93 static void loadStartedCallback(
97 static void loadFinishedCallback(
101 static void titleChangedCallback(
105 static void loadProgressCallback(
109 static void loadProgressFinishedCallback(
113 static void processCrashedCallback(
119 static void createWindowCallback(
123 static void closeWindowCallback(
128 // EWK PolicyDecide Callback
129 static void policyNavigationDecideCallback(
133 static void policyNewWindowDecideCallback(
137 static void pageResponseDecideCallback(
142 // EWK ContextMenu Callback
143 static void contextmenuCustomizeCallback(
148 // EWK FormClient Callback
149 static void formSubmitCallback(
154 // EWK Geolocation Callback
155 static void geolocationPermissionRequestCallback(
160 // EWK Notification Callback
161 static void notificationShowCallback(
165 static void notificationCancelCallback(
169 static void notificationPermissionRequestCallback(
174 // EWK Orientation Callback
175 static Eina_Bool orientationLockCallback(
181 // EWK Fullscreen API callbacks
182 static void enterFullscreenCallback(
186 static void exitFullscreenCallback(
191 // EWK IME Change/Show/Hide Callback
192 static void imeChangedCallback(
196 static void imeOpenedCallback(
200 static void imeClosedCallback(
205 // EWK Usermedia Callback
206 static void usermediaPermissionRequestCallback(
211 // custom content/scheme handlers
212 static void protocolHandlerRegistrationCallback(void* data,
215 static void protocolHandlerIsRegisteredCallback(void* data,
218 static void protocolHandlerUnregistrationCallback(void* data,
222 static void contentHandlerRegistrationCallback(void* data,
225 static void contentHandlerIsRegisteredCallback(void* data,
228 static void contentHandlerUnregistrationCallback(void* data,
232 static void certificateConfirmRequestCallback(
236 bool askUserForCertificateConfirm();
237 static void authenticationChallengeRequestCallback(
242 void attachToCustomHandlersDao();
243 void detachFromCustomHandlersDao();
245 // JS execute callback
246 static void didRunJavaScriptCallback(
252 static Eina_Bool windowCloseIdlerCallback(void *data);
255 std::string requestUrlBlocked(const std::string& blockedUrl);
256 std::string requestUrlChanged(const std::string& changedUrl);
259 void windowClose(void);
261 Ewk_Context* m_ewkContext;
262 bool m_attachedToCustomHandlerDao;
263 std::list<Evas_Object*> m_ewkViewList;
264 Evas_Object* m_currentEwkView;
265 Evas_Object* m_closedEwkView;
266 Evas_Object* m_window;
267 WidgetModel* m_model;
268 std::string m_currentUri;
269 std::string m_blockedUri;
271 std::string m_startUrl;
272 WRT::UserDelegatesPtr m_cbs;
275 bool m_isBackgroundReload;
276 bool m_isBackgroundSupport;
278 std::unique_ptr<SchemeSupport> m_schemeSupport;
279 std::unique_ptr<ViewModule::AppsSupport> m_appsSupport;
280 std::unique_ptr<ViewModule::VibrationSupport> m_vibrationSupport;
281 std::unique_ptr<ViewModule::SecurityOriginSupport> m_securityOriginSupport;
282 std::unique_ptr<ViewModule::CertificateSupport> m_certificateSupport;
284 static std::map<const std::string, const Evas_Smart_Cb> m_ewkCallbacksMap;
287 #endif //VIEW_LOGIC_H_