2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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.
20 #include <boost/signals2/signal.hpp>
24 #if defined(USE_EWEBKIT)
25 //#include <EWebKit2.h>
26 #include <ewk_chromium.h>
29 #include "browser_config.h"
30 #include "Config/Config.h"
31 #include "BrowserImage.h"
32 #include "AbstractWebEngine/TabId.h"
33 #include "AbstractWebEngine/WebConfirmation.h"
35 namespace tizen_browser {
36 namespace basic_webengine {
37 namespace webkitengine_service {
42 WebView(Evas_Object *, TabId);
44 void init(bool desktopMode, Evas_Object * opener = NULL);
47 void setURI(const std::string &);
48 std::string getURI(void);
50 std::string getTitle(void);
52 void stopLoading(void);
58 bool isBackEnabled(void);
59 bool isForwardEnabled(void);
62 bool isLoadError() const;
64 Evas_Object * getLayout();
66 void confirmationResult(WebConfirmationPtr);
68 void setPrivateMode(bool);
70 std::shared_ptr<tizen_browser::tools::BrowserImage> captureSnapshot(int width, int height);
72 * \brief Sets Focus to URI entry.
77 * @brief Remove focus form URI
82 * @brief check if URI is focused
84 bool hasFocus() const;
87 * @brief get current real zoom factor from webkit
89 double getZoomFactor() const;
92 * @brief set zoom factor of website
94 void setZoomFactor(double zoomFactor);
97 void clearPrivateData();
102 const TabId& getTabId();
105 * @brief Search string on searchOnWebsite
107 * @param string to search on searchOnWebsite
108 * @param flags for search options
110 void searchOnWebsite(const std::string &, int);
113 * @brief Change user agent to desktop type
115 void switchToDesktopMode();
118 * @brief Change user agent to mobile type
120 void switchToMobileMode();
123 * @brief Check if desktop mode is enabled
125 * @return true if desktop mode is enabled
127 bool isDesktopMode() const;
130 * @brief Get favicon of URL
132 std::shared_ptr<tizen_browser::tools::BrowserImage> getFavicon();
135 boost::signals2::signal<void (std::shared_ptr<tizen_browser::tools::BrowserImage>)> favIconChanged;
136 boost::signals2::signal<void (const std::string &)> titleChanged;
137 boost::signals2::signal<void (const std::string)> uriChanged;
138 boost::signals2::signal<void (TabId)> tabIdChecker;
140 boost::signals2::signal<void ()> loadFinished;
141 boost::signals2::signal<void ()> loadStarted;
142 boost::signals2::signal<void ()> loadStop;
143 boost::signals2::signal<void ()> loadError;
144 boost::signals2::signal<void (double)> loadProgress;
146 boost::signals2::signal<void (bool)> forwardEnableChanged;
147 boost::signals2::signal<void (bool)> backwardEnableChanged;
149 boost::signals2::signal<void (WebConfirmationPtr)> cofirmationRequest;
151 boost::signals2::signal<void ()> ewkViewClicked;
153 boost::signals2::signal<void (bool)> IMEStateChanged;
156 void registerCallbacks();
157 void unregisterCallbacks();
158 void setupEwkSettings();
160 #if defined(USE_EWEBKIT)
161 static std::string securityOriginToUri(const Ewk_Security_Origin *);
162 static void __setFocusToEwkView(void * data, Evas * e, Evas_Object * obj, void * event_info);
163 static void __newWindowRequest(void * data, Evas_Object *, void *out);
164 static void __closeWindowRequest(void * data, Evas_Object *, void *);
168 static void __loadStarted(void * data, Evas_Object * obj, void * event_info);
169 static void __loadStop(void * data, Evas_Object * obj, void * event_info);
170 static void __loadFinished(void * data, Evas_Object * obj, void * event_info);
171 static void __loadProgress(void * data, Evas_Object * obj, void * event_info);
172 static void __loadError(void* data, Evas_Object* obj, void *ewkError);
174 static void __titleChanged(void * data, Evas_Object * obj, void * event_info);
175 static void __urlChanged(void * data, Evas_Object * obj, void * event_info);
177 static void __backForwardListChanged(void * data, Evas_Object * obj, void * event_info);
179 // Favicon - from database
180 static void __faviconChanged(void* data, Evas_Object*, void*);
182 static void __IMEClosed(void * data, Evas_Object *obj, void *event_info);
183 static void __IMEOpened(void * data, Evas_Object *obj, void *event_info);
185 // confirmation requests
186 static void __geolocationPermissionRequest(void * data, Evas_Object * obj, void * event_info);
187 static void __usermediaPermissionRequest(void * data, Evas_Object * obj, void * event_info);
188 static void __notificationPermissionRequest(void * data, Evas_Object * obj, void * event_info);
189 static void __authenticationRequest(void * data, Evas_Object * obj, void * event_info);
190 static void __requestCertificationConfirm(void * data, Evas_Object * obj, void * event_info);
192 static void scriptLinkSearchCallback(Evas_Object *o, const char *value, void *data);
194 Evas_Object * m_parent;
196 Evas_Object * m_ewkView;
197 // ewk context of this web view
198 Ewk_Context * m_ewkContext;
200 std::shared_ptr<tizen_browser::tools::BrowserImage> faviconImage;
202 double m_loadProgress;
204 // true if desktop view is enabled, false if mobile
207 config::DefaultConfig config;
209 #if defined(USE_EWEBKIT)
211 std::map<WebConfirmationPtr, Ewk_Geolocation_Permission_Request *> m_confirmationGeolocationMap;
212 std::map<WebConfirmationPtr, Ewk_User_Media_Permission_Request *> m_confirmationUserMediaMap;
213 std::map<WebConfirmationPtr, Ewk_Notification_Permission_Request *> m_confirmationNotificationMap;
214 std::map<CertificateConfirmationPtr, Ewk_Certificate_Policy_Decision *> m_confirmationCertificatenMap;
215 std::map<AuthenticationConfirmationPtr, Ewk_Auth_Request *> m_confirmationAuthenticationMap;
220 } /* namespace webkitengine_service */
221 } /* end of basic_webengine */
222 } /* end of tizen_browser */
223 #endif /* WEBVIEW_H_ */