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