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.
20 * Created on: Mar 18, 2014
29 #include "AbstractMainWindow.h"
30 #include "AbstractService.h"
31 #include "AbstractFavoriteService.h"
32 #include "ServiceFactory.h"
33 #include "service_macros.h"
36 #include "WebPageUI.h"
37 #include "AbstractWebEngine.h"
38 #include "MoreMenuUI.h"
39 #include "HistoryUI.h"
40 #include "SettingsUI.h"
43 #include "HistoryService.h"
44 #include "BookmarkManagerUI.h"
45 #include "PlatformInputManager.h"
46 #include "SessionStorage.h"
47 #include "SqlStorage.h"
51 #include "SimplePopup.h"
52 #include "WebConfirmation.h"
53 #include "BookmarksManager.h"
55 #include "ViewManager.h"
57 namespace tizen_browser{
61 void AbstractMainWindow<Evas_Object>::setMainWindow(Evas_Object * rawPtr)
63 m_window = std::shared_ptr<Evas_Object>(rawPtr, evas_object_del);
66 class BROWSER_EXPORT SimpleUI : public AbstractMainWindow<Evas_Object>
69 SimpleUI(/*Evas_Object *window*/);
71 virtual int exec(const std::string& url);
72 virtual std::string getName();
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);
90 void forwardEnable(bool enable);
91 void stopEnable(bool enable);
92 void reloadEnable(bool enable);
93 void addBookmarkEnable(bool enable);
94 void removeBookmarkEnable(bool enable);
95 void zoomEnable(bool enable);
97 void settingsButtonEnable(bool enable);
100 void progressChanged(double progress);
104 void setErrorButtons();
105 bool isErrorPageActive();
107 void bookmarkAdded();
108 void bookmarkDeleted();
111 void switchViewToQuickAccess();
112 void switchViewToWebPage();
115 void openNewTab(const std::string &uri, bool desktopMode = true);
116 void switchToTab(const tizen_browser::basic_webengine::TabId& tabId);
117 void newTabClicked();
118 void tabClicked(const tizen_browser::basic_webengine::TabId& tabId);
119 void closeTabsClicked(const tizen_browser::basic_webengine::TabId& tabId);
121 void tabClosed(const tizen_browser::basic_webengine::TabId& id);
123 std::vector<std::shared_ptr<tizen_browser::services::BookmarkItem> > getBookmarks(int folder_id = -1);
124 std::shared_ptr<services::HistoryItemVector> getHistory();
125 std::shared_ptr<services::HistoryItemVector> getMostVisitedItems();
127 //UI signal handling functions
128 void onBookmarkAdded(std::shared_ptr<tizen_browser::services::BookmarkItem> bookmarkItem);
130 void onBookmarkClicked(std::shared_ptr<tizen_browser::services::BookmarkItem> bookmarkItem);
131 void onBookmarkRemoved(const std::string& uri);
133 void onHistoryAdded(std::shared_ptr<tizen_browser::services::HistoryItem> historyItem);
134 void onHistoryRemoved(const std::string& uri);
135 void onOpenURLInNewTab(std::shared_ptr<tizen_browser::services::HistoryItem> historyItem, bool desktopMode);
136 void onMostVisitedTileClicked(std::shared_ptr<tizen_browser::services::HistoryItem> historyItem, int itemsNumber);
137 void onClearHistoryClicked();
139 void onMostVisitedClicked();
140 void onBookmarkButtonClicked();
142 void handleConfirmationRequest(basic_webengine::WebConfirmationPtr webConfirmation);
143 void authPopupButtonClicked(PopupButtons button, std::shared_ptr<PopupData> popupData);
145 void onActionTriggered(const Action& action);
146 void setwvIMEStatus(bool status);
148 sharedAction m_share;
149 sharedAction m_zoom_in;
150 sharedAction m_showBookmarkManagerUI;
151 sharedAction m_settingPointerMode;
152 sharedAction m_settingPrivateBrowsing;
153 sharedAction m_settingDeleteHistory;
154 sharedAction m_settingDeleteData;
155 sharedAction m_settingDeleteFavorite;
156 sharedAction m_mostvisited;
157 sharedAction m_bookmarksvisited;
158 sharedAction m_bookmarks_manager_BookmarkBar;
161 * \brief filters URL before it is passed to WebEngine.
163 * This function should be connected with m_simpleURI->uriChanged.
164 * it is a good place to check for special urls (like "about:home"),
165 * filter forbidden addresses and to check set favorite icon.
167 void filterURL(const std::string& url);
170 * Checks if correct tab is visible to user, and if not, it update browser view
171 * @param id of tab that should be visible to user
173 void checkTabId(const tizen_browser::basic_webengine::TabId& id);
176 * \brief check if url comming back from WebEngine should be passed to URI.
178 * For filtered addresses we need to hide real URI so the user would be confused.
179 * and this is a back function that checks if address emited from browser should be changed.
181 void webEngineURLChanged(const std::string url);
182 void onmostHistoryvisitedClicked();
183 void onBookmarkvisitedClicked();
185 * @brief Check if the current page exists as a bookmark.
188 bool checkBookmark();
190 * @brief Adds current page to bookmarks.
193 void addToBookmarks(int);
195 * @brief Remove current page from bookmarks
200 void deleteBookmark(void);
205 void closeMoreMenu();
206 void switchToMobileMode();
207 void switchToDesktopMode();
208 void showHistoryUI();
209 void closeHistoryUI();
212 void hideSettingsMenu();
213 void showSettingsUI();
214 void closeSettingsUI();
215 void closeBookmarkManagerUI();
216 void showBookmarkManagerUI();
218 void showPopup(Evas_Object *content, char* btn1_text, char* btn2_text);
221 void closeTab(const tizen_browser::basic_webengine::TabId& id);
223 void settingsPointerModeSwitch(bool newState);
224 void settingsPrivateModeSwitch(bool newState);
225 void settingsDeleteData();
226 void settingsDeleteFavorite();
227 void settingsDeleteSelectedData(const std::string& str);
228 void settingsResetMostVisited();
229 void settingsResetBrowser();
230 void onDeleteSelectedDataButton(PopupButtons button, std::shared_ptr<PopupData> popupData);
231 void onDeleteMostVisitedButton(PopupButtons button, std::shared_ptr<PopupData> popupData);
232 void onResetBrowserButton(PopupButtons button, std::shared_ptr<PopupData> popupData);
233 void onDeleteDataButton(PopupButtons button, std::shared_ptr<PopupData> popupData);
234 void onDeleteFavoriteButton(PopupButtons button, std::shared_ptr<PopupData> popupData);
235 void tabLimitPopupButtonClicked(PopupButtons button, std::shared_ptr< PopupData > /*popupData*/);
236 void disableHistoryButton(bool flag);
239 void onNetworkError();
240 void onNetErrorButtonPressed(PopupButtons, std::shared_ptr<PopupData>);
242 void onReturnPressed(MenuButton *m);
243 void onBackPressed();
245 std::string edjePath(const std::string &);
247 Evas_Object *m_popup;
248 Evas_Object *m_entry;
249 Evas_Object *m_errorLayout;
251 std::shared_ptr<WebPageUI> m_webPageUI;
252 std::shared_ptr<basic_webengine::AbstractWebEngine<Evas_Object>> m_webEngine;
253 // std::shared_ptr<tizen_browser::base_ui::URIEntry> m_simpleURI;
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::MoreMenuUI> m_moreMenuUI;
257 std::shared_ptr<tizen_browser::base_ui::BookmarkManagerUI> m_bookmarkManagerUI;
258 std::shared_ptr<tizen_browser::base_ui::MainUI> m_mainUI;
259 std::shared_ptr<tizen_browser::base_ui::HistoryUI> m_historyUI;
260 std::shared_ptr<tizen_browser::base_ui::SettingsUI> m_settingsUI;
261 std::shared_ptr<tizen_browser::base_ui::TabUI> m_tabUI;
262 std::shared_ptr<tizen_browser::services::PlatformInputManager> m_platformInputManager;
263 std::shared_ptr<tizen_browser::services::SessionStorage> m_sessionService;
264 tizen_browser::Session::Session m_currentSession;
265 std::shared_ptr<BookmarksManager> m_bookmarks_manager;
268 int m_favoritesLimit;
271 //helper object used to view management
272 ViewManager* m_viewManager;
274 // This context object is used to implicitly init internal ewk data used by opengl to create the first and
275 // consecutive webviews in the application, otherwise we would encounter a crash after creating
276 // the first web view
277 Ewk_Context *m_ewkContext;
279 std::vector<std::shared_ptr<tizen_browser::services::HistoryItem>> items_vector;
280 SimplePopup* m_networkErrorPopup;
282 void searchWebPage(std::string &text, int flags);
288 #endif /* SIMPLEUI_H_ */