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.
17 #ifndef __ABSTRACT_WEBENGINE_H__
18 #define __ABSTRACT_WEBENGINE_H__ 1
20 #include <boost/signals2/signal.hpp>
24 #include "BrowserImage.h"
25 #include "../ServiceManager/Debug/Lifecycle.h"
26 #include "../ServiceManager/AbstractService.h"
29 #include "WebConfirmation.h"
31 namespace tizen_browser {
32 namespace basic_webengine {
34 * AbstractWebEngine defines interface for WebEngine object.
35 * It is designed for multiple tabs operations.
36 * It is designed to be only way for communication with WebEngine. It should NOT return WebEngine object.
40 class AbstractWebEngine : public tizen_browser::core::AbstractService, ShowLifeCycle<AbstractWebEngine<T>>
42 class AbstractWebEngine: public tizen_browser::core::AbstractService
47 * \todo this function should return nonEFL object in future
48 * Remember that there must be at least 1 tab created to return layout
49 * @return pointer Evas_Object for current WebView.
51 virtual T * getLayout() = 0;
54 * Initialize WebEngine.
55 * @param guiParent GUI parent object (now should pass Evas_Object)
56 * \todo make guiParent nonEFL object
58 virtual void init(void * guiParent) = 0;
61 * Set URI address for current tab.
64 virtual void setURI(const std::string & uri) = 0;
67 * @return uri address for current tab.
69 virtual std::string getURI(void) const = 0;
72 * @return title of page opened in current tab.
74 virtual std::string getTitle(void) const = 0;
77 * Stop loading current page.
79 virtual void stopLoading(void) = 0;
82 * Reload current page.
84 virtual void reload(void) = 0;
87 * Go to previous page (if possible)
89 virtual void back(void) = 0;
92 * Go to next page (if possible)
94 virtual void forward(void) = 0;
97 * @return true if it is possible to go back, false otherwise
99 virtual bool isBackEnabled(void) const = 0;
102 * @return true if it is possible to go forward, false otherwise
104 virtual bool isForwardEnabled(void) const = 0;
107 * @return true if page is still loading, false otherwise
109 virtual bool isLoading() const = 0;
112 * @return number of tabs
114 virtual int tabsCount() const = 0;
117 * @return TabId of current tab
119 virtual TabId currentTabId() const = 0;
122 * @return list (RVO) of tabs in most recent order
124 virtual std::list<TabId> listTabs() const = 0;
128 * @return vector of metadata for all opened tabs
130 virtual std::vector<std::shared_ptr<TabContent>> getTabContents() const = 0;
134 * @param uri if not empty opens specified uri
135 * @param desktopMode true if desktop mode, false if mobile mode
136 * @return TabId of created tab
138 virtual TabId addTab(const std::string & uri = std::string(), const TabId * openerId = NULL, bool desktopMode = true) = 0;
142 * @return returns underlaying UI component
144 virtual T* getTabView(TabId id) = 0;
147 * Switch current tab for tab with tabId
148 * @param tabId of tab
149 * @return true if tab changed, false otherwise
151 virtual bool switchToTab(TabId tabId) = 0;
154 * Close current tab. Switch tab to other (not defined which).
155 * Should NOT close last tab (there should be only at least 1 tab)
156 * @return true if tab closed successfully, false otherwise
158 virtual bool closeTab() = 0;
161 * Close tab specified with id parameter. Switch tab to other (not defined which).
162 * Should NOT close last tab (there should be only at least 1 tab)
163 * @return true if tab closed successfully, false otherwise
165 virtual bool closeTab(TabId id) = 0;
169 * @return true if tab changed successfully, false otherwise
171 virtual bool nextTab() = 0;
175 * @return true if tab changed successfully, false otherwise
177 virtual bool prevTab() = 0;
180 * Process confirmation result
181 * \param web confirmation with request and result value
183 virtual void confirmationResult(WebConfirmationPtr) = 0;
186 * Gets snapshot data as void* for current tab
188 virtual std::shared_ptr<tizen_browser::tools::BrowserImage> getSnapshotData(int width = 324, int height = 177) = 0;
191 * Gets snapshot data as void* for tab provided as parameter
193 virtual std::shared_ptr<tizen_browser::tools::BrowserImage> getSnapshotData(TabId id, int width, int height) = 0;
196 * Set private mode on/off
197 * \param private mode on when true, off otherwise
199 virtual void setPrivateMode(bool) = 0;
201 virtual bool isPrivateMode() const = 0;
203 virtual bool isLoadError() const = 0;
206 * \brief Sets Focus to URI entry.
208 virtual void setFocus()=0;
211 * @brief Remove focus form URI
213 virtual void clearFocus()=0;
216 * @brief check if URI is focused
218 virtual bool hasFocus() const = 0;
221 * @brief return current zoom factor in percentage.
223 * @return real zoom, also for "fit to screen" mode
225 virtual int getZoomFactor()const = 0;
229 * @brief Sets zoom factor in percentage
231 * @param zoomFactor in percentage of default zoom, 0 means autofit
233 virtual void setZoomFactor(int zoomFactor) = 0;
236 * @brief Clear private data of WebView
238 virtual void clearPrivateData() = 0;
240 virtual void disconnectCurrentWebViewSignals() = 0;
243 * @brief Search string on searchOnWebsite
245 * @param string to search on searchOnWebsite
246 * @param flags for search options
248 virtual void searchOnWebsite(const std::string &, int flags) = 0;
251 * @brief Get favicon of current page loaded
253 virtual std::shared_ptr<tizen_browser::tools::BrowserImage> getFavicon() = 0;
256 * @brief back or exit when back key is pressed
258 virtual void backButtonClicked() const = 0;
261 * @brief Switch current view to mobile mode
263 virtual void switchToMobileMode() = 0;
266 * @brief Switch current view to desktop mode
268 virtual void switchToDesktopMode() = 0;
271 * @brief Check if desktop mode is enabled for current view
273 * @return true if desktop mode is enabled
275 virtual bool isDesktopMode() const = 0;
278 * FavIcon of current page changed
280 boost::signals2::signal<void (std::shared_ptr<tizen_browser::tools::BrowserImage>)> favIconChanged;
283 * Title of current page changed
286 boost::signals2::signal<void (const std::string &)> titleChanged;
289 * URI of current page changed
292 boost::signals2::signal<void (const std::string &)> uriChanged;
295 * URI on current/other page changed
297 boost::signals2::signal<void (TabId)> uriOnTabChanged;
300 * Possibility of go forward changed
301 * \param bool true if it is possible to go forward, false otherwise
303 boost::signals2::signal<void (bool)> forwardEnableChanged;
306 * Possibility of go back changed
307 * \param bool true if it is possible to go back, false otherwise
309 boost::signals2::signal<void (bool)> backwardEnableChanged;
314 boost::signals2::signal<void ()> loadFinished;
319 boost::signals2::signal<void ()> loadStarted;
322 * Load progress changed
323 * \param double 0..1 of progress
325 boost::signals2::signal<void (double)> loadProgress;
330 boost::signals2::signal<void ()> loadStop;
335 boost::signals2::signal<void ()> loadError;
338 * Current tab changed
339 * \param TabId of new tab
341 boost::signals2::signal<void (TabId)> currentTabChanged;
344 * New tab was creted. It could be explicit call (by user) or tab could be opened from JavaScript.
346 boost::signals2::signal<void ()> tabCreated;
350 * \param TabId of closed tab
352 boost::signals2::signal<void (TabId)> tabClosed;
355 * Confirmation Reuest
357 boost::signals2::signal<void (basic_webengine::WebConfirmationPtr)> confirmationRequest;
360 * Web Engine area clicked
362 boost::signals2::signal<void ()> webViewClicked;
365 * All links to RSS/Atom channels were gathered from webpage.
367 boost::signals2::signal<void (std::vector<std::string>)> gotFeedLinks;
371 * \param bool true if IME is opened, false otherwise
373 boost::signals2::signal<void (bool)> IMEStateChanged;
376 } /* end of basic_webengine */
377 } /* end of tizen_browser */
379 #endif /* __ABSTRACT_WEBENGINE_H__ */