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 * Suspend current webview.
79 virtual void suspend(void) = 0;
82 * Resume current webview.
84 virtual void resume(void) = 0;
87 * @return true if current webview is suspended, false otherwise
89 virtual bool isSuspended(void) const = 0;
92 * Stop loading current page.
94 virtual void stopLoading(void) = 0;
97 * Reload current page.
99 virtual void reload(void) = 0;
102 * Go to previous page (if possible)
104 virtual void back(void) = 0;
107 * Go to next page (if possible)
109 virtual void forward(void) = 0;
112 * @return true if it is possible to go back, false otherwise
114 virtual bool isBackEnabled(void) const = 0;
117 * @return true if it is possible to go forward, false otherwise
119 virtual bool isForwardEnabled(void) const = 0;
122 * @return true if page is still loading, false otherwise
124 virtual bool isLoading() const = 0;
127 * @return number of tabs
129 virtual int tabsCount() const = 0;
132 * @return TabId of current tab
134 virtual TabId currentTabId() const = 0;
137 * @return list (RVO) of tabs in most recent order
139 virtual std::list<TabId> listTabs() const = 0;
143 * @return vector of metadata for all opened tabs
145 virtual std::vector<std::shared_ptr<TabContent>> getTabContents() const = 0;
149 * @param uri if not empty opens specified uri
151 * @param desktopMode true if desktop mode, false if mobile mode
152 * @param incognitoMode true if incognito mode, false if not
153 * @return TabId of created tab
155 virtual TabId addTab(
156 const std::string & uri = std::string(),
157 const TabId * openerId = NULL,
158 bool desktopMode = true,
159 bool incognitoMode = false) = 0;
163 * @return returns underlaying UI component
165 virtual T* getTabView(TabId id) = 0;
168 * Switch current tab for tab with tabId
169 * @param tabId of tab
170 * @return true if tab changed, false otherwise
172 virtual bool switchToTab(TabId tabId) = 0;
175 * Close current tab. Switch tab to other (not defined which).
176 * Should NOT close last tab (there should be only at least 1 tab)
177 * @return true if tab closed successfully, false otherwise
179 virtual bool closeTab() = 0;
182 * Close tab specified with id parameter. Switch tab to other (not defined which).
183 * Should NOT close last tab (there should be only at least 1 tab)
184 * @return true if tab closed successfully, false otherwise
186 virtual bool closeTab(TabId id) = 0;
190 * @return true if tab changed successfully, false otherwise
192 virtual bool nextTab() = 0;
196 * @return true if tab changed successfully, false otherwise
198 virtual bool prevTab() = 0;
201 * Process confirmation result
202 * \param web confirmation with request and result value
204 virtual void confirmationResult(WebConfirmationPtr) = 0;
207 * Gets snapshot data as void* for current tab
209 virtual std::shared_ptr<tizen_browser::tools::BrowserImage> getSnapshotData(int width = 324, int height = 177) = 0;
212 * Gets snapshot data as void* for tab provided as parameter
214 virtual std::shared_ptr<tizen_browser::tools::BrowserImage> getSnapshotData(TabId id, int width, int height) = 0;
217 * Get the state of private mode for a specific tab
219 * /param id of snapshot
220 * /return state of private mode
222 virtual bool isPrivateMode(const TabId&) = 0;
224 virtual bool isLoadError() const = 0;
227 * \brief Sets Focus to URI entry.
229 virtual void setFocus()=0;
232 * @brief Remove focus form URI
234 virtual void clearFocus()=0;
237 * @brief check if URI is focused
239 virtual bool hasFocus() const = 0;
242 * @brief return current zoom factor in percentage.
244 * @return real zoom, also for "fit to screen" mode
246 virtual int getZoomFactor()const = 0;
250 * @brief Sets zoom factor in percentage
252 * @param zoomFactor in percentage of default zoom, 0 means autofit
254 virtual void setZoomFactor(int zoomFactor) = 0;
257 * @brief Clear private data of WebView
259 virtual void clearPrivateData() = 0;
261 virtual void disconnectCurrentWebViewSignals() = 0;
264 * @brief Search string on searchOnWebsite
266 * @param string to search on searchOnWebsite
267 * @param flags for search options
269 virtual void searchOnWebsite(const std::string &, int flags) = 0;
272 * @brief Get favicon of current page loaded
274 virtual std::shared_ptr<tizen_browser::tools::BrowserImage> getFavicon() = 0;
277 * @brief back or exit when back key is pressed
279 virtual void backButtonClicked() const = 0;
282 * @brief Switch current view to mobile mode
284 virtual void switchToMobileMode() = 0;
287 * @brief Switch current view to desktop mode
289 virtual void switchToDesktopMode() = 0;
292 * @brief Check if desktop mode is enabled for current view
294 * @return true if desktop mode is enabled
296 virtual bool isDesktopMode() const = 0;
299 * Sets an absolute scroll of the given view.
301 * Both values are from zero to the contents size minus the viewport
304 * @param x horizontal position to scroll
305 * @param y vertical position to scroll
307 virtual void scrollView(const int& dx, const int& dy) = 0;
310 * FavIcon of current page changed
312 boost::signals2::signal<void (std::shared_ptr<tizen_browser::tools::BrowserImage>)> favIconChanged;
315 * Title of current page changed
318 boost::signals2::signal<void (const std::string &)> titleChanged;
321 * URI of current page changed
324 boost::signals2::signal<void (const std::string &)> uriChanged;
327 * Possibility of go forward changed
328 * \param bool true if it is possible to go forward, false otherwise
330 boost::signals2::signal<void (bool)> forwardEnableChanged;
333 * Possibility of go back changed
334 * \param bool true if it is possible to go back, false otherwise
336 boost::signals2::signal<void (bool)> backwardEnableChanged;
341 boost::signals2::signal<void ()> loadFinished;
346 boost::signals2::signal<void ()> loadStarted;
349 * Load progress changed
350 * \param double 0..1 of progress
352 boost::signals2::signal<void (double)> loadProgress;
357 boost::signals2::signal<void ()> loadStop;
362 boost::signals2::signal<void ()> loadError;
365 * Current tab changed
366 * \param TabId of new tab
368 boost::signals2::signal<void (TabId)> currentTabChanged;
371 * New tab was created. It could be explicit call (by user) or tab could be opened from JavaScript.
373 boost::signals2::signal<void ()> tabCreated;
376 * Checks if tab can be created.
378 boost::signals2::signal<bool ()> checkIfCreate;
382 * \param TabId of closed tab
384 boost::signals2::signal<void (TabId)> tabClosed;
387 * Confirmation Reuest
389 boost::signals2::signal<void (basic_webengine::WebConfirmationPtr)> confirmationRequest;
392 * Web Engine area clicked
394 boost::signals2::signal<void ()> webViewClicked;
397 * All links to RSS/Atom channels were gathered from webpage.
399 boost::signals2::signal<void (std::vector<std::string>)> gotFeedLinks;
403 * \param bool true if IME is opened, false otherwise
405 boost::signals2::signal<void (bool)> IMEStateChanged;
408 } /* end of basic_webengine */
409 } /* end of tizen_browser */
411 #endif /* __ABSTRACT_WEBENGINE_H__ */