Remove ewk_context_favicon_database_directory_set internal API call
[profile/tv/apps/web/browser.git] / services / SimpleUI / SimpleUI.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 /*
18  * SimpleUI.h
19  *
20  *  Created on: Mar 18, 2014
21  *      Author: k.szalilow
22  */
23
24 #ifndef SIMPLEUI_H_
25 #define SIMPLEUI_H_
26
27 #include <Evas.h>
28
29 //#include <EWebKit2.h>
30 //#include <ewk_chromium.h>
31
32 #include "AbstractMainWindow.h"
33 #include "AbstractService.h"
34 #include "AbstractFavoriteService.h"
35 #include "ServiceFactory.h"
36 #include "service_macros.h"
37
38 // components
39 #include "AbstractWebEngine.h"
40 #include "BookmarksUI.h"
41 #include "ButtonBar.h"
42 #include "HistoryService.h"
43 #include "SimpleURI.h"
44 #include "SimpleScroller.h"
45 #include "WebTitleBar.h"
46 #include "PlatformInputManager.h"
47 #include "SessionStorage.h"
48 #include "SqlStorage.h"
49
50 // other
51 #include "Action.h"
52 #include "SimplePopup.h"
53 #include "WebConfirmation.h"
54 #include "ZoomList.h"
55 #include "TabList.h"
56 #include "Settings.h"
57 #include "HistoryList.h"
58 #include "NetworkErrorHandler.h"
59 #include "CustomPopup.h"
60 #include "Config.h"
61
62 namespace tizen_browser{
63 namespace base_ui{
64
65 template <>
66 void AbstractMainWindow<Evas_Object>::setMainWindow(Evas_Object * rawPtr)
67 {
68     m_window = std::shared_ptr<Evas_Object>(rawPtr, evas_object_del);
69 }
70
71
72
73 class BROWSER_EXPORT SimpleUI : public AbstractMainWindow<Evas_Object>
74 {
75 public:
76     SimpleUI(/*Evas_Object *window*/);
77     virtual ~SimpleUI();
78     virtual int exec(const std::string& url);
79     virtual std::string getName();
80
81     void destroyUI();
82 private:
83     void createActions();
84     void connectActions();
85
86     void backEnable(bool enable);
87     void forwardEnable(bool enable);
88     void stopEnable(bool enable);
89     void reloadEnable(bool enable);
90     void addBookmarkEnable(bool enable);
91     void removeBookmarkEnable(bool enable);
92     void zoomEnable(bool enable);
93
94     void settingsButtonEnable(bool enable);
95
96     void loadFinished();
97     void progressChanged(double progress);
98     void loadStarted();
99
100     void loadError();
101     void setErrorButtons();
102     bool isErrorPageActive();
103
104     void bookmarkAdded();
105     void bookmarkDeleted();
106
107     bool isHomePageActive();
108     void switchViewToHomePage();
109     void switchViewToBrowser();
110     void updateBrowserView();
111     void updateView();
112
113     void openNewTab(const std::string &uri);
114     void switchToTab(const tizen_browser::basic_webengine::TabId& tabId);
115     void newTabClicked();
116     void tabClicked(const tizen_browser::basic_webengine::TabId& tabId);
117     void tabCreated();
118     void tabClosed(const tizen_browser::basic_webengine::TabId& id);
119
120     void bookmarkCheck();
121     std::vector<std::shared_ptr<tizen_browser::services::BookmarkItem> > getBookmarks();
122     void onBookmarkAdded(std::shared_ptr<tizen_browser::services::BookmarkItem> bookmarkItem);
123     void onBookmarkClicked(std::shared_ptr<tizen_browser::services::BookmarkItem> bookmarkItem);
124     void onBookmarkDeleteClicked(std::shared_ptr<tizen_browser::services::BookmarkItem> bookmarkItem);
125     void onBookmarkRemoved(const std::string& uri);
126
127     void handleConfirmationRequest(basic_webengine::WebConfirmationPtr webConfirmation);
128     void authPopupButtonClicked(PopupButtons button, std::shared_ptr<PopupData> popupData);
129
130     void onActionTriggered(const Action& action);
131
132     void loadThemes();
133
134     void setwvIMEStatus(bool status);
135
136
137
138     sharedAction m_back;
139     sharedAction m_forward;
140     sharedAction m_stopLoading;
141     sharedAction m_reload;
142     sharedAction m_bookmark;
143     sharedAction m_unbookmark;
144     sharedAction m_tab;
145     sharedAction m_history;
146     sharedAction m_zoom_in;
147     sharedAction m_showSettingsPopup;
148     sharedAction m_settingPointerMode;
149 //    sharedAction m_settingPrivateBrowsing;
150     sharedAction m_settingDeleteHistory;
151     sharedAction m_settingDeleteData;
152     sharedAction m_settingDeleteFavorite;
153
154     /**
155      * \brief filters URL before it is passed to WebEngine.
156      *
157      * This function should be connected with m_simpleURI->uriChanged.
158      * it is a good place to check for special urls (like "about:home"),
159      * filter forbidden addresses and to check set favorite icon.
160      */
161     void filterURL(const std::string& url);
162
163     /**
164      * Checks if correct tab is visible to user, and if not, it update browser view
165      * @param id of tab that should be visible to user
166      */
167     void checkTabId(const tizen_browser::basic_webengine::TabId& id);
168
169     /**
170      * \brief check if url comming back from WebEngine should be passed to URI.
171      *
172      * For filtered addresses we need to hide real URI so the user would be confused.
173      * and this is a back function that checks if address emited from browser should be changed.
174      */
175     void webEngineURLChanged(const std::string& url);
176
177     /**
178      * @brief Adds current page to bookmarks.
179      *
180      */
181     void addToBookmarks(void);
182
183     /**
184      * @brief Remove current page from bookmarks
185      *
186      * @param  ...
187      * @return void
188      */
189     void deleteBookmark(void);
190
191     /**
192      * \brief shows Zoom showZoomMenu
193      */
194     void showZoomMenu();
195
196     void zoomLevelChanged(int zoom_level);
197
198     void showHistory();
199     void hideHistory();
200
201     /**
202     * \brief shows Tab showTabMenu
203     */
204     void showTabMenu();
205
206     void showSettingsMenu();
207     void hideSettingsMenu();
208
209     void showProgressBar();
210     void hideProgressBar();
211
212
213     void showPopup(Evas_Object *content, char* btn1_text, char* btn2_text);
214
215
216     void closeTab();
217     void closeTab(const tizen_browser::basic_webengine::TabId& id);
218
219     void settingsPointerModeSwitch(bool newState);
220     void settingsPrivateModeSwitch(bool newState);
221     void settingsDeleteHistory();
222     void settingsDeleteData();
223     void settingsDeleteFavorite();
224     void onDeleteHistoryButton(PopupButtons button, std::shared_ptr<PopupData> popupData);
225     void onDeleteDataButton(PopupButtons button, std::shared_ptr<PopupData> popupData);
226     void onDeleteFavoriteButton(PopupButtons button, std::shared_ptr<PopupData> popupData);
227     void tabLimitPopupButtonClicked(PopupButtons button, std::shared_ptr< PopupData > /*popupData*/);
228     void openLinkFromPopup(const std::string &);
229     void disableHistoryButton(bool flag);
230
231     void onNetworkError();
232     void onNetworkConnected();
233     void onNetErrorButtonPressed(PopupButtons, std::shared_ptr<PopupData>);
234
235     void onReturnPressed(MenuButton *m);
236     void onBackPressed();
237
238     boost::signals2::signal<void ()> hidePopup;
239
240     std::string edjePath(const std::string &);
241
242     Evas_Object *m_mainLayout;
243     Evas_Object *m_progressBar;
244     Evas_Object *m_popup;
245     Evas_Object *m_errorLayout;
246     CustomPopup *m_ownPopup;
247     SimpleScroller *m_scroller;
248
249     std::shared_ptr<basic_webengine::AbstractWebEngine<Evas_Object>>  m_webEngine;
250     std::shared_ptr<tizen_browser::base_ui::SimpleURI> m_simpleURI;
251     std::shared_ptr<ButtonBar> leftButtonBar;
252     std::shared_ptr<ButtonBar> rightButtonBar;
253     std::shared_ptr<tizen_browser::interfaces::AbstractFavoriteService> m_favoriteService;
254     std::shared_ptr<tizen_browser::services::HistoryService> m_historyService;
255     std::shared_ptr<tizen_browser::base_ui::BookmarksUI> m_bookmarksUI;
256     std::shared_ptr<tizen_browser::base_ui::ZoomList> m_zoomList;
257     std::shared_ptr<tizen_browser::base_ui::TabList> m_tabList;
258     std::shared_ptr<tizen_browser::services::PlatformInputManager> m_platformInputManager;
259     std::shared_ptr<tizen_browser::services::SessionStorage> m_sessionService;
260     tizen_browser::Session::Session m_currentSession;
261     std::shared_ptr<Settings> m_settings;
262     std::shared_ptr<HistoryList> m_historyList;
263     std::shared_ptr<WebTitleBar> webTitleBar;
264     bool m_initialised;
265     zoom_type m_currentZoom;
266     int m_tabLimit;
267     int m_favoritesLimit;
268     bool m_wvIMEStatus;
269     // This context object is used to implicitly init internal ewk data used by opengl to create the first and
270     // consecutive webviews in the application, otherwise we would encounter a crash after creating
271     // the first web view
272     Ewk_Context *m_ewkContext;
273
274     std::vector<std::shared_ptr<tizen_browser::services::HistoryItem>> items_vector;
275     std::unique_ptr<tizen_browser::basic_ui::NetworkErrorHandler> m_netErrorHandler;
276     SimplePopup* m_networkErrorPopup;
277
278     void searchWebPage(std::string &text, int flags);
279     static void favicon_clicked(void *data, Evas_Object *obj, const char *emission, const char *source);
280
281 };
282
283 }
284 }
285
286 #endif /* SIMPLEUI_H_ */