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, bool incognitoMode);
44 void init(bool desktopMode, Evas_Object * opener = NULL);
46 void setURI(const std::string &);
47 std::string getURI(void);
49 std::string getTitle(void);
53 bool isSuspended(void) const { return m_suspended; }
55 void stopLoading(void);
61 bool isBackEnabled(void);
62 bool isForwardEnabled(void);
65 bool isLoadError() const;
67 Evas_Object * getLayout();
69 void confirmationResult(WebConfirmationPtr);
72 * @brief Get the state of private mode
74 * @return state of private mode
76 bool isPrivateMode() {return m_private;}
78 std::shared_ptr<tizen_browser::tools::BrowserImage> captureSnapshot(int width, int height);
80 * \brief Sets Focus to URI entry.
85 * @brief Remove focus form URI
90 * @brief check if URI is focused
92 bool hasFocus() const;
95 * @brief get current real zoom factor from webkit
97 double getZoomFactor() const;
100 * @brief set zoom factor of website
102 void setZoomFactor(double zoomFactor);
105 void clearPrivateData();
110 const TabId& getTabId();
113 * @brief Search string on searchOnWebsite
115 * @param string to search on searchOnWebsite
116 * @param flags for search options
118 void searchOnWebsite(const std::string &, int);
121 * @brief Change user agent to desktop type
123 void switchToDesktopMode();
126 * @brief Change user agent to mobile type
128 void switchToMobileMode();
131 * @brief Check if desktop mode is enabled
133 * @return true if desktop mode is enabled
135 bool isDesktopMode() const;
138 * @brief Get favicon of URL
140 std::shared_ptr<tizen_browser::tools::BrowserImage> getFavicon();
143 * Sets an absolute scroll of the given view.
145 * Both values are from zero to the contents size minus the viewport
148 * @param x horizontal position to scroll
149 * @param y vertical position to scroll
151 void scrollView(const int& dx, const int& dy);
154 boost::signals2::signal<void (std::shared_ptr<tizen_browser::tools::BrowserImage>)> favIconChanged;
155 boost::signals2::signal<void (const std::string &)> titleChanged;
156 boost::signals2::signal<void (const std::string)> uriChanged;
158 boost::signals2::signal<void ()> loadFinished;
159 boost::signals2::signal<void ()> loadStarted;
160 boost::signals2::signal<void ()> loadStop;
161 boost::signals2::signal<void ()> loadError;
162 boost::signals2::signal<void (double)> loadProgress;
164 boost::signals2::signal<void (bool)> forwardEnableChanged;
165 boost::signals2::signal<void (bool)> backwardEnableChanged;
167 boost::signals2::signal<void (WebConfirmationPtr)> cofirmationRequest;
169 boost::signals2::signal<void ()> ewkViewClicked;
171 boost::signals2::signal<void (bool)> IMEStateChanged;
173 boost::signals2::signal<void ()> switchToWebPage;
176 void registerCallbacks();
177 void unregisterCallbacks();
178 void setupEwkSettings();
180 #if defined(USE_EWEBKIT)
181 static std::string securityOriginToUri(const Ewk_Security_Origin *);
182 static void __setFocusToEwkView(void * data, Evas * e, Evas_Object * obj, void * event_info);
183 static void __newWindowRequest(void * data, Evas_Object *, void *out);
184 static void __closeWindowRequest(void * data, Evas_Object *, void *);
188 static void __loadStarted(void * data, Evas_Object * obj, void * event_info);
189 static void __loadStop(void * data, Evas_Object * obj, void * event_info);
190 static void __loadFinished(void * data, Evas_Object * obj, void * event_info);
191 static void __loadProgress(void * data, Evas_Object * obj, void * event_info);
192 static void __loadError(void* data, Evas_Object* obj, void *ewkError);
194 static void __titleChanged(void * data, Evas_Object * obj, void * event_info);
195 static void __urlChanged(void * data, Evas_Object * obj, void * event_info);
197 static void __backForwardListChanged(void * data, Evas_Object * obj, void * event_info);
199 // Favicon - from database
200 static void __faviconChanged(void* data, Evas_Object*, void*);
202 static void __IMEClosed(void * data, Evas_Object *obj, void *event_info);
203 static void __IMEOpened(void * data, Evas_Object *obj, void *event_info);
205 // confirmation requests
206 static void __geolocationPermissionRequest(void * data, Evas_Object * obj, void * event_info);
207 static void __usermediaPermissionRequest(void * data, Evas_Object * obj, void * event_info);
208 static void __notificationPermissionRequest(void * data, Evas_Object * obj, void * event_info);
209 static void __authenticationRequest(void * data, Evas_Object * obj, void * event_info);
210 static void __requestCertificationConfirm(void * data, Evas_Object * obj, void * event_info);
212 static void scriptLinkSearchCallback(Evas_Object *o, const char *value, void *data);
214 Evas_Object * m_parent;
216 Evas_Object * m_ewkView;
217 // ewk context of this web view
218 Ewk_Context * m_ewkContext;
220 std::shared_ptr<tizen_browser::tools::BrowserImage> faviconImage;
222 double m_loadProgress;
224 // true if desktop view is enabled, false if mobile
229 config::DefaultConfig config;
231 #if defined(USE_EWEBKIT)
233 std::map<WebConfirmationPtr, Ewk_Geolocation_Permission_Request *> m_confirmationGeolocationMap;
234 std::map<WebConfirmationPtr, Ewk_User_Media_Permission_Request *> m_confirmationUserMediaMap;
235 std::map<WebConfirmationPtr, Ewk_Notification_Permission_Request *> m_confirmationNotificationMap;
236 std::map<CertificateConfirmationPtr, Ewk_Certificate_Policy_Decision *> m_confirmationCertificatenMap;
237 std::map<AuthenticationConfirmationPtr, Ewk_Auth_Request *> m_confirmationAuthenticationMap;
241 static const std::string COOKIES_PATH;
244 } /* namespace webkitengine_service */
245 } /* end of basic_webengine */
246 } /* end of tizen_browser */
247 #endif /* WEBVIEW_H_ */