Implemented ZoomUI service
[profile/tv/apps/web/browser.git] / services / WebKitEngineService / WebKitEngineService.h
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #ifndef WEBKITENGINESERVICE_H_
18 #define WEBKITENGINESERVICE_H_
19
20 #include <boost/noncopyable.hpp>
21 #include <string>
22 #include <Evas.h>
23 #include <memory>
24
25 #include "ServiceFactory.h"
26 #include "service_macros.h"
27
28 #include "AbstractWebEngine/AbstractWebEngine.h"
29 #include "AbstractWebEngine/TabId.h"
30 #include "AbstractWebEngine/WebConfirmation.h"
31 #include "BrowserImage.h"
32
33 namespace tizen_browser {
34 namespace basic_webengine {
35 namespace webkitengine_service {
36
37 class WebView;
38
39 typedef std::shared_ptr<WebView> WebViewPtr;
40
41 class BROWSER_EXPORT WebKitEngineService: public AbstractWebEngine<Evas_Object>, boost::noncopyable
42 {
43 public:
44     WebKitEngineService();
45     virtual ~WebKitEngineService();
46     virtual std::string getName();
47
48     Evas_Object * getLayout();
49     void init(void * guiParent);
50
51     void setURI(const std::string &);
52     std::string getURI(void) const;
53
54     std::string getTitle(void) const;
55
56     void stopLoading(void);
57     void reload(void);
58
59     void back(void);
60     void forward(void);
61
62     bool isBackEnabled(void) const;
63     bool isForwardEnabled(void) const;
64
65     bool isLoading() const;
66
67     void clearPrivateData();
68
69     int tabsCount() const;
70     TabId currentTabId() const;
71     std::list<TabId> listTabs() const;
72     std::vector<std::shared_ptr<TabContent> > getTabContents() const;
73
74     /**
75      * Adds new tab. If uri is specified setURI(uri).
76      * If it first tab in WebEngine switch to this tab.
77      * @param uri
78      * @return TabId of created tab
79      */
80     TabId addTab(const std::string & uri = std::string(), const TabId * openerId = NULL, bool desktopMode = true);
81     Evas_Object* getTabView(TabId id);
82     bool switchToTab(TabId);
83     bool closeTab();
84     bool closeTab(TabId);
85
86     /**
87      * Change tab to next created, dummy implementation.
88      * @return true if changed successfully, false otherwise
89      */
90     bool nextTab();
91     /**
92      * Change tab to previous created, dummy implementation.
93      * @return true if changed successfully, false otherwise
94      */
95     bool prevTab();
96
97     void confirmationResult(WebConfirmationPtr);
98
99     /**
100      * @brief Get snapshot of webpage
101      *
102      * @param width of snapshot
103      * @param height of snapshot
104      * @return Shared pointer to BrowserImage
105      */
106     std::shared_ptr<tizen_browser::tools::BrowserImage> getSnapshotData(int width, int height);
107
108     std::shared_ptr<tizen_browser::tools::BrowserImage> getSnapshotData(TabId id, int width, int height);
109
110     void setPrivateMode(bool);
111     bool isPrivateMode() const;
112
113
114     /**
115      * @brief Check if current tab has load error.
116      *
117      */
118     bool isLoadError() const;
119
120      /**
121      * \brief Sets Focus to URI entry.
122      */
123     void setFocus();
124
125     /**
126      * @brief Remove focus form URI
127      */
128     void clearFocus();
129
130     /**
131      * @brief check if URI is focused
132      */
133     bool hasFocus() const;
134
135     virtual int getZoomFactor() const;
136
137     /**
138      * @brief check if autofit is enabled
139      */
140
141     virtual void setZoomFactor(int zoomFactor);
142
143
144     /**
145      * @brief Search string on searchOnWebsite
146      *
147      * @param string to search on searchOnWebsite
148      * @param flags for search options
149      */
150     void searchOnWebsite(const std::string &, int flags);
151
152     /**
153      * @brief Get favicon of current page loaded
154      */
155     std::shared_ptr<tizen_browser::tools::BrowserImage> getFavicon();
156
157     /**
158      * @brief back or exit when back key is pressed
159      */
160     void backButtonClicked() const;
161
162     void switchToMobileMode();
163     void switchToDesktopMode();
164     bool isDesktopMode() const;
165
166     void scrollView(const int& dx, const int& dy);
167
168 private:
169     // callbacks from WebView
170     void _favIconChanged(std::shared_ptr<tizen_browser::tools::BrowserImage> bi);
171     void _titleChanged(const std::string &);
172     void _uriChanged(const std::string &);
173     void _uriChangedOnTab(TabId);
174     void _loadFinished();
175     void _loadStarted();
176     void _loadStop();
177     void _loadError();
178     void _forwardEnableChanged(bool);
179     void _backwardEnableChanged(bool);
180     void _loadProgress(double);
181     void _confirmationRequest(WebConfirmationPtr) ;
182     void _IMEStateChanged(bool);
183     void webViewClicked();
184
185     /**
186      * disconnect signals from specified WebView
187      * \param WebView
188      */
189     void disconnectSignals(WebViewPtr);
190
191     void disconnectCurrentWebViewSignals();
192
193     /**
194      * connect signals of specified WebView
195      * \param WebView
196      */
197     void connectSignals(WebViewPtr);
198
199 private:
200     bool m_initialised;
201     bool m_privateMode;
202     void * m_guiParent;
203
204     // current TabId
205     TabId m_currentTabId;
206     // current WebView
207     WebViewPtr m_currentWebView;
208
209     // map of all tabs (WebViews)
210     std::map<TabId, WebViewPtr > m_tabs;
211     // Most recent tab list
212     std::list<TabId> m_mostRecentTab;
213     // recently added tabs first
214     std::list<TabId> m_chronoTabs;
215 };
216
217 } /* end of webkitengine_service */
218 } /* end of basic_webengine */
219 } /* end of tizen_browser */
220
221 #endif /* WEBKITENGINESERVICE_H_ */