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;
44 class ViewLogic : public ViewModule::IViewModule
51 bool createWebView(Ewk_Context* context,
53 void destroyWebView();
54 void prepareView(WidgetModel* m, const std::string &startUrl);
61 void reloadStartPage();
62 Evas_Object* getCurrentWebview();
63 void fireJavascriptEvent(int event, void* data);
64 void setUserCallbacks(const WRT::UserDelegatesPtr& cbs);
65 void checkSyncMessageFromBundle(
69 void downloadData(const char* url);
70 void activateVibration(bool on, uint64_t time);
74 void initializeSupport();
75 void initializePluginLoading();
78 void ewkClientInit(Evas_Object *wkView);
79 void ewkClientDeinit(Evas_Object *wkView);
80 bool createEwkView(Evas* canvas);
82 void prepareEwkView(Evas_Object *wkView);
83 void removeEwkView(Evas_Object *wkView);
84 void resumeEwkView(Evas_Object *wkView);
85 void suspendEwkView(Evas_Object *wkView);
86 void setEwkViewVisible(Evas_Object *wkView);
87 void setEwkViewInvisible(Evas_Object *wkView);
88 void resumeWebkit(Evas_Object *wkView);
89 void suspendWebkit(Evas_Object *wkView);
92 static void loadStartedCallback(
96 static void loadFinishedCallback(
100 static void titleChangedCallback(
104 static void loadProgressCallback(
108 static void loadProgressFinishedCallback(
112 static void processCrashedCallback(
118 static void createWindowCallback(
122 static void closeWindowCallback(
127 // EWK PolicyDecide Callback
128 static void policyNavigationDecideCallback(
132 static void policyNewWindowDecideCallback(
136 static void pageResponseDecideCallback(
141 // EWK ContextMenu Callback
142 static void contextmenuCustomizeCallback(
147 // EWK FormClient Callback
148 static void formSubmitCallback(
153 // EWK Geolocation Callback
154 static void geolocationPermissionRequestCallback(
159 // EWK Notification Callback
160 static void notificationShowCallback(
164 static void notificationCancelCallback(
168 static void notificationPermissionRequestCallback(
173 // EWK Orientation Callback
174 static Eina_Bool orientationLockCallback(
180 // EWK Fullscreen API callbacks
181 static void enterFullscreenCallback(
185 static void exitFullscreenCallback(
190 // EWK IME Change/Show/Hide Callback
191 static void imeChangedCallback(
195 static void imeOpenedCallback(
199 static void imeClosedCallback(
204 // EWK Usermedia Callback
205 static void usermediaPermissionRequestCallback(
210 // custom content/scheme handlers
211 static void protocolHandlerRegistrationCallback(void* data,
214 static void protocolHandlerIsRegisteredCallback(void* data,
217 static void protocolHandlerUnregistrationCallback(void* data,
221 static void contentHandlerRegistrationCallback(void* data,
224 static void contentHandlerIsRegisteredCallback(void* data,
227 static void contentHandlerUnregistrationCallback(void* data,
231 // database usage permission request callback
232 static void databaseUsagePermissionRequestCallback(
236 // file System Permission Request Callback
237 static void fileSystemPermissionRequestCallback(
241 static void certificateConfirmRequestCallback(
245 bool askUserForCertificateConfirm();
247 void attachToCustomHandlersDao();
248 void detachFromCustomHandlersDao();
250 // JS execute callback
251 static void didRunJavaScriptCallback(
257 static Eina_Bool windowCloseIdlerCallback(void *data);
260 std::string requestUrlBlocked(const std::string& blockedUrl);
261 std::string requestUrlChanged(const std::string& changedUrl);
264 void windowClose(void);
266 Ewk_Context* m_ewkContext;
267 std::list<Evas_Object*> m_ewkViewList;
268 Evas_Object* m_currentEwkView;
269 Evas_Object* m_closedEwkView;
270 Evas_Object* m_window;
271 WidgetModel* m_model;
272 std::string m_currentUri;
273 std::string m_blockedUri;
275 std::string m_startUrl;
276 WRT::UserDelegatesPtr m_cbs;
279 bool m_isBackgroundReload;
280 bool m_isBackgroundSupport;
282 std::unique_ptr<SchemeSupport> m_schemeSupport;
283 std::unique_ptr<ViewModule::AppsSupport> m_appsSupport;
284 std::unique_ptr<ViewModule::VibrationSupport> m_vibrationSupport;
285 std::unique_ptr<ViewModule::SecurityOriginSupport> m_securityOriginSupport;
286 bool m_attachedToCustomHandlerDao;
288 static std::map<const std::string, const Evas_Smart_Cb> m_ewkCallbacksMap;
291 #endif //VIEW_LOGIC_H_