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>
36 #include <system_settings.h>
40 namespace ViewModule {
41 class SecurityOriginSupport;
42 class CertificateSupport;
43 class WebNotificationSupport;
46 class ViewLogic : public ViewModule::IViewModule
53 bool createWebView(Ewk_Context* context,
55 void destroyWebView();
56 void prepareView(WidgetModel* m, const std::string &startUrl);
63 void reloadStartPage();
64 Evas_Object* getCurrentWebview();
65 void fireJavascriptEvent(int event, void* data);
66 void setUserCallbacks(const WRT::UserDelegatesPtr& cbs);
67 void checkSyncMessageFromBundle(
71 void checkAsyncMessageFromBundle(
74 void downloadData(const char* url);
75 void activateVibration(bool on, uint64_t time);
79 void initializeSupport();
80 void initializePluginLoading();
81 void initializeXwindowHandle();
84 void ewkClientInit(Evas_Object *wkView);
85 void ewkClientDeinit(Evas_Object *wkView);
86 bool createEwkView(Evas* canvas);
87 void prepareEwkView(Evas_Object *wkView);
88 void removeEwkView(Evas_Object *wkView);
89 void setEwkViewVisible(Evas_Object *wkView);
90 void setEwkViewInvisible(Evas_Object *wkView);
91 void resumeWebkit(Evas_Object *wkView);
92 void suspendWebkit(Evas_Object *wkView);
95 static void loadStartedCallback(
99 static void loadFinishedCallback(
103 static void loadProgressStartedCallback(
107 static void loadProgressCallback(
111 static void loadProgressFinishedCallback(
115 static void processCrashedCallback(
121 static void createWindowCallback(
125 static void closeWindowCallback(
130 // EWK PolicyDecide Callback
131 static void policyNavigationDecideCallback(
135 static void policyNewWindowDecideCallback(
139 static void pageResponseDecideCallback(
144 // EWK ContextMenu Callback
145 static void contextmenuCustomizeCallback(
150 // EWK Geolocation Callback
151 static void geolocationPermissionRequestCallback(
156 // EWK Notification Callback
157 static void notificationShowCallback(
161 static void notificationCancelCallback(
165 static void notificationPermissionRequestCallback(
170 // EWK Orientation Callback
171 static Eina_Bool orientationLockCallback(
177 // EWK Fullscreen API callbacks
178 static void enterFullscreenCallback(
182 static void exitFullscreenCallback(
187 // EWK IME Change/Show/Hide Callback
188 static void imeChangedCallback(
192 static void imeOpenedCallback(
196 static void imeClosedCallback(
201 // EWK Usermedia Callback
202 static void usermediaPermissionRequestCallback(
207 // custom content/scheme handlers
208 static void protocolHandlerRegistrationCallback(void* data,
211 static void protocolHandlerIsRegisteredCallback(void* data,
214 static void protocolHandlerUnregistrationCallback(void* data,
218 static void contentHandlerRegistrationCallback(void* data,
221 static void contentHandlerIsRegisteredCallback(void* data,
224 static void contentHandlerUnregistrationCallback(void* data,
227 static Eina_Bool exceededDatabaseQuotaCallback(Evas_Object* obj,
228 Ewk_Security_Origin* origin,
229 const char* databaseName,
230 unsigned long long expectedQuota,
232 static Eina_Bool exceededIndexedDatabaseQuotaCallback(Evas_Object* obj,
233 Ewk_Security_Origin* origin,
234 long long expectedQuota,
236 static Eina_Bool exceededLocalFileSystemQuotaCallback(Evas_Object* obj,
237 Ewk_Security_Origin* origin,
238 long long expectedQuota,
240 static void certificateConfirmRequestCallback(
244 static void authenticationChallengeRequestCallback(
249 static void viewFrameRenderedCallback(
254 static void mediacontrolRotateHorizontal(void* data,
257 static void mediacontrolRotateVertical(void* data,
260 static void mediacontrolRotateExit(void* data,
263 static void popupReplyWaitStart(void* data,
266 static void popupReplyWaitFinish(void* data,
270 void attachToCustomHandlersDao();
271 void detachFromCustomHandlersDao();
273 // JS execute callback
274 static void didRunJavaScriptCallback(
280 static void eaKeyCallback(void* data,
285 static Eina_Bool windowCloseIdlerCallback(void *data);
288 static Eina_Bool orientationThresholdTimerCallback(void* data);
291 void requestUrlBlocked(const std::string& blockedUrl);
294 void windowClose(void);
297 static void systemSettingsChangedCallback(system_settings_key_e key, void* data);
299 Ewk_Context* m_ewkContext;
300 bool m_attachedToCustomHandlerDao;
301 std::list<Evas_Object*> m_ewkViewList;
302 Evas_Object* m_currentEwkView;
303 Evas_Object* m_closedEwkView;
304 Evas_Object* m_window;
305 WidgetModel* m_model;
306 std::string m_blockedUri;
308 std::string m_startUrl;
309 WRT::UserDelegatesPtr m_cbs;
312 bool m_isBackgroundReload;
313 bool m_isBackgroundSupport;
315 int m_deferredRotateAngle;
316 Ecore_Timer* m_orientationThresholdTimer;
317 bool m_isPopupReplyWait;
319 std::unique_ptr<ViewModule::AppsSupport> m_appsSupport;
320 std::unique_ptr<ViewModule::VibrationSupport> m_vibrationSupport;
321 std::unique_ptr<ViewModule::SecurityOriginSupport> m_securityOriginSupport;
322 std::unique_ptr<ViewModule::CertificateSupport> m_certificateSupport;
323 std::unique_ptr<ViewModule::WebNotificationSupport> m_webNotificationSupport;
325 static std::map<const std::string, const Evas_Smart_Cb> m_ewkCallbacksMap;
328 #endif //VIEW_LOGIC_H_