Removed dead code from SimpleUI
[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 "AbstractMainWindow.h"
30 #include "AbstractService.h"
31 #include "AbstractFavoriteService.h"
32 #include "ServiceFactory.h"
33 #include "service_macros.h"
34
35 // components
36 #include "WebPageUI.h"
37 #include "AbstractWebEngine.h"
38 #include "MoreMenuUI.h"
39 #include "HistoryUI.h"
40 #include "SettingsUI.h"
41 #include "MainUI.h"
42 #include "TabUI.h"
43 #include "HistoryService.h"
44 #include "BookmarkManagerUI.h"
45 #include "PlatformInputManager.h"
46 #include "SessionStorage.h"
47 #include "SqlStorage.h"
48
49 // other
50 #include "Action.h"
51 #include "SimplePopup.h"
52 #include "WebConfirmation.h"
53 #include "BookmarksManager.h"
54 #include "Config.h"
55 #include "ViewManager.h"
56
57 namespace tizen_browser{
58 namespace base_ui{
59
60 template <>
61 void AbstractMainWindow<Evas_Object>::setMainWindow(Evas_Object * rawPtr)
62 {
63     m_window = std::shared_ptr<Evas_Object>(rawPtr, evas_object_del);
64 }
65
66 class BROWSER_EXPORT SimpleUI : public AbstractMainWindow<Evas_Object>
67 {
68 public:
69     SimpleUI(/*Evas_Object *window*/);
70     virtual ~SimpleUI();
71     virtual int exec(const std::string& url);
72     virtual std::string getName();
73
74     void destroyUI();
75 private:
76     // setup functions
77     void createActions();
78     void connectActions();
79     void loadUIServices();
80     void connectUISignals();
81     void loadModelServices();
82     void initModelServices();
83     void initUIServices();
84     void connectModelSignals();
85     void restoreLastSession();
86     Evas_Object* createWebLayout(Evas_Object* parent);
87     Evas_Object* createErrorLayout(Evas_Object* parent);
88
89     void forwardEnable(bool enable);
90     void stopEnable(bool enable);
91     void reloadEnable(bool enable);
92
93     void loadFinished();
94     void progressChanged(double progress);
95     void loadStarted();
96
97     void loadError();
98     void setErrorButtons();
99     bool isErrorPageActive();
100
101     void bookmarkAdded();
102     void bookmarkDeleted();
103
104     void showMainUI();
105     void switchViewToQuickAccess();
106     void switchViewToWebPage();
107     void updateView();
108
109     void openNewTab(const std::string &uri, bool desktopMode = true);
110     void switchToTab(const tizen_browser::basic_webengine::TabId& tabId);
111     void newTabClicked();
112     void tabClicked(const tizen_browser::basic_webengine::TabId& tabId);
113     void closeTabsClicked(const tizen_browser::basic_webengine::TabId& tabId);
114     void tabCreated();
115     void tabClosed(const tizen_browser::basic_webengine::TabId& id);
116
117     std::vector<std::shared_ptr<tizen_browser::services::BookmarkItem> > getBookmarks(int folder_id = -1);
118     std::shared_ptr<services::HistoryItemVector> getHistory();
119     std::shared_ptr<services::HistoryItemVector> getMostVisitedItems();
120
121     //UI signal handling functions
122     void onBookmarkAdded(std::shared_ptr<tizen_browser::services::BookmarkItem> bookmarkItem);
123
124     void onBookmarkClicked(std::shared_ptr<tizen_browser::services::BookmarkItem> bookmarkItem);
125     void onBookmarkRemoved(const std::string& uri);
126
127     void onHistoryRemoved(const std::string& uri);
128     void onOpenURLInNewTab(std::shared_ptr<tizen_browser::services::HistoryItem> historyItem, bool desktopMode);
129     void onMostVisitedTileClicked(std::shared_ptr<tizen_browser::services::HistoryItem> historyItem, int itemsNumber);
130     void onClearHistoryClicked();
131
132     void onMostVisitedClicked();
133     void onBookmarkButtonClicked();
134
135     void handleConfirmationRequest(basic_webengine::WebConfirmationPtr webConfirmation);
136     void authPopupButtonClicked(PopupButtons button, std::shared_ptr<PopupData> popupData);
137
138     void onActionTriggered(const Action& action);
139     void setwvIMEStatus(bool status);
140
141     sharedAction m_showBookmarkManagerUI;
142     sharedAction m_settingPrivateBrowsing;
143
144     /**
145      * \brief filters URL before it is passed to WebEngine.
146      *
147      * This function should be connected with m_simpleURI->uriChanged.
148      * it is a good place to check for special urls (like "about:home"),
149      * filter forbidden addresses and to check set favorite icon.
150      */
151     void filterURL(const std::string& url);
152
153     /**
154      * Checks if correct tab is visible to user, and if not, it update browser view
155      * @param id of tab that should be visible to user
156      */
157     void checkTabId(const tizen_browser::basic_webengine::TabId& id);
158
159     /**
160      * \brief check if url comming back from WebEngine should be passed to URI.
161      *
162      * For filtered addresses we need to hide real URI so the user would be confused.
163      * and this is a back function that checks if address emited from browser should be changed.
164      */
165     void webEngineURLChanged(const std::string url);
166     void onmostHistoryvisitedClicked();
167     void onBookmarkvisitedClicked();
168     /**
169      * @brief Check if the current page exists as a bookmark.
170      *
171      */
172     bool checkBookmark();
173     /**
174      * @brief Adds current page to bookmarks.
175      *
176      */
177     void addToBookmarks(int);
178     /**
179      * @brief Remove current page from bookmarks
180      *
181      * @param  ...
182      * @return void
183      */
184     void deleteBookmark(void);
185
186     void showTabUI();
187     void closeTabUI();
188     void showMoreMenu();
189     void closeMoreMenu();
190     void switchToMobileMode();
191     void switchToDesktopMode();
192     void showHistoryUI();
193     void closeHistoryUI();
194     void showSettingsUI();
195     void closeSettingsUI();
196     void closeBookmarkManagerUI();
197     void showBookmarkManagerUI();
198     void showPopup(Evas_Object *content, char* btn1_text, char* btn2_text);
199
200     void closeTab();
201     void closeTab(const tizen_browser::basic_webengine::TabId& id);
202
203     void settingsPointerModeSwitch(bool newState);
204     void settingsPrivateModeSwitch(bool newState);
205     void settingsDeleteSelectedData(const std::string& str);
206     void settingsResetMostVisited();
207     void settingsResetBrowser();
208     void onDeleteSelectedDataButton(PopupButtons button, std::shared_ptr<PopupData> popupData);
209     void onDeleteMostVisitedButton(PopupButtons button, std::shared_ptr<PopupData> popupData);
210     void onResetBrowserButton(PopupButtons button, std::shared_ptr<PopupData> popupData);
211     void tabLimitPopupButtonClicked(PopupButtons button, std::shared_ptr< PopupData > /*popupData*/);
212     int tabsCount();
213
214     void onReturnPressed(MenuButton *m);
215     void onBackPressed();
216
217     void searchWebPage(std::string &text, int flags);
218
219     std::string edjePath(const std::string &);
220
221     Evas_Object *m_popup;
222
223     std::shared_ptr<WebPageUI> m_webPageUI;
224     std::shared_ptr<basic_webengine::AbstractWebEngine<Evas_Object>>  m_webEngine;
225     std::shared_ptr<interfaces::AbstractFavoriteService> m_favoriteService;
226     std::shared_ptr<services::HistoryService> m_historyService;
227     std::shared_ptr<MoreMenuUI> m_moreMenuUI;
228     std::shared_ptr<BookmarkManagerUI> m_bookmarkManagerUI;
229     std::shared_ptr<MainUI> m_mainUI;
230     std::shared_ptr<HistoryUI> m_historyUI;
231     std::shared_ptr<SettingsUI> m_settingsUI;
232     std::shared_ptr<TabUI> m_tabUI;
233     std::shared_ptr<services::PlatformInputManager> m_platformInputManager;
234     std::shared_ptr<services::SessionStorage> m_sessionService;
235     Session::Session m_currentSession;
236     std::shared_ptr<BookmarksManager> m_bookmarks_manager;
237     bool m_initialised;
238     int m_tabLimit;
239     int m_favoritesLimit;
240     bool m_wvIMEStatus;
241
242     //helper object used to view management
243     ViewManager* m_viewManager;
244
245     // This context object is used to implicitly init internal ewk data used by opengl to create the first and
246     // consecutive webviews in the application, otherwise we would encounter a crash after creating
247     // the first web view
248     Ewk_Context *m_ewkContext;
249 };
250
251 }
252 }
253
254 #endif /* SIMPLEUI_H_ */