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 WEBKITENGINESERVICE_H_
18 #define WEBKITENGINESERVICE_H_
20 #include <boost/noncopyable.hpp>
25 #include "ServiceFactory.h"
26 #include "service_macros.h"
28 #include "AbstractWebEngine/AbstractWebEngine.h"
29 #include "AbstractWebEngine/TabId.h"
30 #include "AbstractWebEngine/WebConfirmation.h"
31 #include "BrowserImage.h"
33 namespace tizen_browser {
34 namespace basic_webengine {
35 namespace webkitengine_service {
39 typedef std::shared_ptr<WebView> WebViewPtr;
41 class BROWSER_EXPORT WebKitEngineService: public AbstractWebEngine<Evas_Object>, boost::noncopyable
44 WebKitEngineService();
45 virtual ~WebKitEngineService();
46 virtual std::string getName();
48 Evas_Object * getLayout();
49 void init(void * guiParent);
51 void setURI(const std::string &);
52 std::string getURI(void) const;
54 std::string getTitle(void) const;
58 bool isSuspended(void) const;
60 void stopLoading(void);
66 bool isBackEnabled(void) const;
67 bool isForwardEnabled(void) const;
69 bool isLoading() const;
71 void clearPrivateData();
73 int tabsCount() const;
74 TabId currentTabId() const;
75 std::list<TabId> listTabs() const;
76 std::vector<std::shared_ptr<TabContent> > getTabContents() const;
79 * Adds new tab. If uri is specified setURI(uri).
80 * If it first tab in WebEngine switch to this tab.
82 * @return TabId of created tab
84 TabId addTab(const std::string & uri = std::string(), const TabId * openerId = NULL, bool desktopMode = true, bool incognitoMode = false);
85 Evas_Object* getTabView(TabId id);
86 bool switchToTab(TabId);
91 * Change tab to next created, dummy implementation.
92 * @return true if changed successfully, false otherwise
96 * Change tab to previous created, dummy implementation.
97 * @return true if changed successfully, false otherwise
101 void confirmationResult(WebConfirmationPtr);
104 * @brief Get snapshot of webpage
106 * @param width of snapshot
107 * @param height of snapshot
108 * @return Shared pointer to BrowserImage
110 std::shared_ptr<tizen_browser::tools::BrowserImage> getSnapshotData(int width, int height);
112 std::shared_ptr<tizen_browser::tools::BrowserImage> getSnapshotData(TabId id, int width, int height);
115 * @brief Get the state of private mode for a specific tab
117 * @param id of snapshot
118 * @return state of private mode where:
123 bool isPrivateMode(const TabId& id);
127 * @brief Check if current tab has load error.
130 bool isLoadError() const;
133 * \brief Sets Focus to URI entry.
138 * @brief Remove focus form URI
143 * @brief check if URI is focused
145 bool hasFocus() const;
147 virtual int getZoomFactor() const;
150 * @brief check if autofit is enabled
153 virtual void setZoomFactor(int zoomFactor);
157 * @brief Search string on searchOnWebsite
159 * @param string to search on searchOnWebsite
160 * @param flags for search options
162 void searchOnWebsite(const std::string &, int flags);
165 * @brief Get favicon of current page loaded
167 std::shared_ptr<tizen_browser::tools::BrowserImage> getFavicon();
170 * @brief back or exit when back key is pressed
172 void backButtonClicked();
174 void switchToMobileMode();
175 void switchToDesktopMode();
176 bool isDesktopMode() const;
178 void scrollView(const int& dx, const int& dy);
181 // callbacks from WebView
182 void _favIconChanged(std::shared_ptr<tizen_browser::tools::BrowserImage> bi);
183 void _titleChanged(const std::string &);
184 void _uriChanged(const std::string &);
185 void _loadFinished();
189 void _forwardEnableChanged(bool);
190 void _backwardEnableChanged(bool);
191 void _loadProgress(double);
192 void _confirmationRequest(WebConfirmationPtr) ;
193 void _IMEStateChanged(bool);
194 void webViewClicked();
197 * disconnect signals from specified WebView
200 void disconnectSignals(WebViewPtr);
202 void disconnectCurrentWebViewSignals();
205 * connect signals of specified WebView
208 void connectSignals(WebViewPtr);
216 TabId m_currentTabId;
218 WebViewPtr m_currentWebView;
220 // map of all tabs (WebViews)
221 std::map<TabId, WebViewPtr > m_tabs;
222 // Most recent tab list
223 std::list<TabId> m_mostRecentTab;
224 // recently added tabs first
225 std::list<TabId> m_chronoTabs;
228 } /* end of webkitengine_service */
229 } /* end of basic_webengine */
230 } /* end of tizen_browser */
232 #endif /* WEBKITENGINESERVICE_H_ */