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 "AbstractWebEngine.h"
37 #include "MoreMenuUI.h"
38 #include "HistoryUI.h"
39 #include "SettingsUI.h"
42 #include "ButtonBar.h"
43 #include "HistoryService.h"
44 #include "BookmarkManagerUI.h"
45 #include "SimpleURI.h"
46 #include "SimpleScroller.h"
47 #include "WebTitleBar.h"
48 #include "PlatformInputManager.h"
49 #include "SessionStorage.h"
50 #include "SqlStorage.h"
54 #include "SimplePopup.h"
55 #include "WebConfirmation.h"
58 #include "BookmarksManager.h"
60 #include "HistoryList.h"
61 #include "NetworkErrorHandler.h"
62 #include "CustomPopup.h"
65 namespace tizen_browser{
69 void AbstractMainWindow<Evas_Object>::setMainWindow(Evas_Object * rawPtr)
71 m_window = std::shared_ptr<Evas_Object>(rawPtr, evas_object_del);
74 class BROWSER_EXPORT SimpleUI : public AbstractMainWindow<Evas_Object>
77 SimpleUI(/*Evas_Object *window*/);
79 virtual int exec(const std::string& url);
80 virtual std::string getName();
85 void connectActions();
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);
95 void settingsButtonEnable(bool enable);
98 void progressChanged(double progress);
102 void setErrorButtons();
103 bool isErrorPageActive();
105 void bookmarkAdded();
106 void bookmarkDeleted();
108 bool isHomePageActive();
109 void switchViewToHomePage();
110 void updateBrowserView();
111 void updateWebView();
112 void updateURIBarView();
115 void openNewTab(const std::string &uri);
116 void switchToTab(const tizen_browser::basic_webengine::TabId& tabId);
117 void newTabClicked(const std::string &);
118 void tabClicked(const tizen_browser::basic_webengine::TabId& tabId);
120 void tabClosed(const tizen_browser::basic_webengine::TabId& id);
122 void bookmarkCheck();
123 std::vector<std::shared_ptr<tizen_browser::services::BookmarkItem> > getBookmarks(int folder_id = -1);
124 std::vector<std::shared_ptr<tizen_browser::services::BookmarkItem> > getBookmarkFolders();
125 std::vector<std::shared_ptr<tizen_browser::services::HistoryItem> > getHistory();
126 void onBookmarkAdded(std::shared_ptr<tizen_browser::services::BookmarkItem> bookmarkItem);
128 void onBookmarkClicked(std::shared_ptr<tizen_browser::services::BookmarkItem> bookmarkItem);
129 void onBookmarkDeleteClicked(std::shared_ptr<tizen_browser::services::BookmarkItem> bookmarkItem);
130 void onBookmarkRemoved(const std::string& uri);
132 void onHistoryAdded(std::shared_ptr<tizen_browser::services::HistoryItem> historyItem);
133 void onHistoryRemoved(const std::string& uri);
134 void onHistoryClicked(std::shared_ptr<tizen_browser::services::HistoryItem> historyItem);
135 void onClearHistoryClicked(const std::string&);
137 void onMostVisitedClicked(const std::string&);
138 void onBookmarkButtonClicked(const std::string&);
139 void onBookmarkManagerButtonClicked(const std::string&);
141 void handleConfirmationRequest(basic_webengine::WebConfirmationPtr webConfirmation);
142 void authPopupButtonClicked(PopupButtons button, std::shared_ptr<PopupData> popupData);
144 void onActionTriggered(const Action& action);
148 void setwvIMEStatus(bool status);
151 sharedAction m_forward;
152 sharedAction m_stopLoading;
153 sharedAction m_reload;
154 sharedAction m_bookmark;
155 sharedAction m_unbookmark;
157 sharedAction m_share;
158 sharedAction m_zoom_in;
159 sharedAction m_showMoreMenu;
160 sharedAction m_showBookmarkManagerUI;
161 sharedAction m_settingPointerMode;
162 sharedAction m_settingPrivateBrowsing;
163 sharedAction m_settingDeleteHistory;
164 sharedAction m_settingDeleteData;
165 sharedAction m_settingDeleteFavorite;
166 sharedAction m_mostvisited;
167 sharedAction m_bookmarksvisited;
168 sharedAction m_bookmarks_manager_Add_NewFolder;
169 sharedAction m_bookmarks_manager_BookmarkBar;
170 sharedAction m_bookmarks_manager_Folder1;
171 sharedAction m_bookmarks_manager_Folder2;
172 sharedAction m_bookmarks_manager_Folder3;
175 * \brief filters URL before it is passed to WebEngine.
177 * This function should be connected with m_simpleURI->uriChanged.
178 * it is a good place to check for special urls (like "about:home"),
179 * filter forbidden addresses and to check set favorite icon.
181 void filterURL(const std::string& url);
184 * Checks if correct tab is visible to user, and if not, it update browser view
185 * @param id of tab that should be visible to user
187 void checkTabId(const tizen_browser::basic_webengine::TabId& id);
190 * \brief check if url comming back from WebEngine should be passed to URI.
192 * For filtered addresses we need to hide real URI so the user would be confused.
193 * and this is a back function that checks if address emited from browser should be changed.
195 void webEngineURLChanged(const std::string& url);
196 void onmostHistoryvisitedClicked();
197 void onBookmarkvisitedClicked();
199 * @brief Adds current page to bookmarks.
202 void addToBookmarks(int);
204 * @brief Remove current page from bookmarks
209 void deleteBookmark(void);
212 * \brief shows Zoom showZoomMenu
216 void zoomLevelChanged(int zoom_level);
220 void AddBookmarkPopup(std::string& str);
221 void AddNewFolderPopup(std::string& str);
223 void saveFolder(const char* title, int folder_id, int by_user);
224 void NewFolder(const char* title, int folder_id, int by_user);
226 void closeTabUI(const std::string& str);
228 void closeMoreMenu(const std::string& str);
229 void showHistoryUI(const std::string& str);
230 void closeHistoryUI(const std::string&);
236 void hideSettingsMenu();
237 void showSettingsUI(const std::string&);
238 void closeSettingsUI(const std::string&);
240 void showProgressBar();
241 void hideProgressBar();
243 void closeBookmarkManagerMenu(std::string& str);
244 void updateBookmakMangaerGenGrid(int folder_id);
245 void showBookmarkManagerMenu();
247 void showPopup(Evas_Object *content, char* btn1_text, char* btn2_text);
250 void closeTab(const tizen_browser::basic_webengine::TabId& id);
252 void settingsPointerModeSwitch(bool newState);
253 void settingsPrivateModeSwitch(bool newState);
254 void settingsDeleteData();
255 void settingsDeleteFavorite();
256 void settingsDeleteSelectedData(const std::string& str);
257 void settingsResetMostVisited(const std::string& str);
258 void settingsResetBrowser(const std::string& str);
259 void onDeleteSelectedDataButton(PopupButtons button, std::shared_ptr<PopupData> popupData);
260 void onDeleteMostVisitedButton(PopupButtons button, std::shared_ptr<PopupData> popupData);
261 void onResetBrowserButton(PopupButtons button, std::shared_ptr<PopupData> popupData);
262 void onDeleteDataButton(PopupButtons button, std::shared_ptr<PopupData> popupData);
263 void onDeleteFavoriteButton(PopupButtons button, std::shared_ptr<PopupData> popupData);
264 void tabLimitPopupButtonClicked(PopupButtons button, std::shared_ptr< PopupData > /*popupData*/);
265 void openLinkFromPopup(const std::string &);
266 void disableHistoryButton(bool flag);
268 void onNetworkError();
269 void onNetworkConnected();
270 void onNetErrorButtonPressed(PopupButtons, std::shared_ptr<PopupData>);
272 void onReturnPressed(MenuButton *m);
273 void onBackPressed();
275 boost::signals2::signal<void ()> hidePopup;
277 std::string edjePath(const std::string &);
279 Evas_Object *m_mainLayout;
280 Evas_Object *m_progressBar;
281 Evas_Object *m_popup;
282 Evas_Object *m_entry;
283 Evas_Object *m_errorLayout;
284 CustomPopup *m_ownPopup;
285 SimpleScroller *m_scroller;
287 std::shared_ptr<basic_webengine::AbstractWebEngine<Evas_Object>> m_webEngine;
288 std::shared_ptr<tizen_browser::base_ui::SimpleURI> m_simpleURI;
289 std::shared_ptr<ButtonBar> leftButtonBar;
290 std::shared_ptr<ButtonBar> webviewbar;
292 std::shared_ptr<ButtonBar> rightButtonBar;
293 std::shared_ptr<tizen_browser::interfaces::AbstractFavoriteService> m_favoriteService;
294 std::shared_ptr<tizen_browser::services::HistoryService> m_historyService;
295 std::shared_ptr<tizen_browser::base_ui::MoreMenuUI> m_moreMenuUI;
296 std::shared_ptr<tizen_browser::base_ui::BookmarkManagerUI> m_bookmarkManagerUI;
297 std::shared_ptr<tizen_browser::base_ui::MainUI> m_mainUI;
298 std::shared_ptr<tizen_browser::base_ui::HistoryUI> m_historyUI;
299 std::shared_ptr<tizen_browser::base_ui::SettingsUI> m_settingsUI;
300 std::shared_ptr<tizen_browser::base_ui::TabUI> m_tabUI;
301 std::shared_ptr<tizen_browser::base_ui::ZoomList> m_zoomList;
302 std::shared_ptr<tizen_browser::base_ui::TabList> m_tabList;
303 std::shared_ptr<tizen_browser::services::PlatformInputManager> m_platformInputManager;
304 std::shared_ptr<tizen_browser::services::SessionStorage> m_sessionService;
305 tizen_browser::Session::Session m_currentSession;
306 std::shared_ptr<BookmarksManager> m_bookmarks_manager;
307 std::shared_ptr<Settings> m_settings;
308 std::shared_ptr<HistoryList> m_historyList;
309 std::shared_ptr<WebTitleBar> webTitleBar;
311 bool m_isHomePageActive;
312 zoom_type m_currentZoom;
314 int m_favoritesLimit;
316 // This context object is used to implicitly init internal ewk data used by opengl to create the first and
317 // consecutive webviews in the application, otherwise we would encounter a crash after creating
318 // the first web view
319 Ewk_Context *m_ewkContext;
321 std::vector<std::shared_ptr<tizen_browser::services::HistoryItem>> items_vector;
322 std::unique_ptr<tizen_browser::basic_ui::NetworkErrorHandler> m_netErrorHandler;
323 SimplePopup* m_networkErrorPopup;
325 void searchWebPage(std::string &text, int flags);
326 static void favicon_clicked(void *data, Evas_Object *obj, const char *emission, const char *source);
333 #endif /* SIMPLEUI_H_ */