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 static void certificateConfirmRequestCallback(
240 bool askUserForCertificateConfirm();
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;
283 static std::map<const std::string, const Evas_Smart_Cb> m_ewkCallbacksMap;
286 #endif //VIEW_LOGIC_H_