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 <EWebKit2.h>
30 //#include <ewk_chromium.h>
32 #include "AbstractMainWindow.h"
33 #include "AbstractService.h"
34 #include "AbstractFavoriteService.h"
35 #include "ServiceFactory.h"
36 #include "service_macros.h"
39 #include "AbstractWebEngine.h"
40 #include "BookmarksUI.h"
41 #include "ButtonBar.h"
42 #include "FavoriteService.h"
43 #include "HistoryService.h"
44 #include "SimpleURI.h"
45 #include "SimpleScroller.h"
46 #include "WebTitleBar.h"
47 #include "PlatformInputManager.h"
48 #include "SessionStorage.h"
49 #include "SqlStorage.h"
53 #include "SimplePopup.h"
54 #include "WebConfirmation.h"
58 #include "HistoryList.h"
59 #include "SearchBox.h"
60 #include "NetworkErrorHandler.h"
61 #include "CustomPopup.h"
64 namespace tizen_browser{
68 void AbstractMainWindow<Evas_Object>::setMainWindow(Evas_Object * rawPtr)
70 m_window = std::shared_ptr<Evas_Object>(rawPtr, evas_object_del);
75 class BROWSER_EXPORT SimpleUI : public AbstractMainWindow<Evas_Object>
78 SimpleUI(/*Evas_Object *window*/);
80 virtual int exec(const std::string& url);
81 virtual std::string getName();
86 void connectActions();
88 void backEnable(bool enable);
89 void forwardEnable(bool enable);
90 void stopEnable(bool enable);
91 void reloadEnable(bool enable);
92 void addBookmarkEnable(bool enable);
93 void removeBookmarkEnable(bool enable);
94 void zoomEnable(bool enable);
96 void settingsButtonEnable(bool enable);
99 void progressChanged(double progress);
103 void setErrorButtons();
104 bool isErrorPageActive();
106 void bookmarkAdded();
107 void bookmarkDeleted();
109 bool isHomePageActive();
110 void switchViewToHomePage();
111 void switchViewToBrowser();
112 void updateBrowserView();
115 void openNewTab(const std::string &uri);
116 void switchToTab(const tizen_browser::basic_webengine::TabId& tabId);
117 void newTabClicked();
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();
124 void onBookmarkAdded(std::shared_ptr<tizen_browser::services::BookmarkItem> bookmarkItem);
125 void onBookmarkClicked(std::shared_ptr<tizen_browser::services::BookmarkItem> bookmarkItem);
126 void onBookmarkDeleteClicked(std::shared_ptr<tizen_browser::services::BookmarkItem> bookmarkItem);
127 void onBookmarkRemoved(const std::string& uri);
129 void handleConfirmationRequest(basic_webengine::WebConfirmationPtr webConfirmation);
130 void authPopupButtonClicked(PopupButtons button, std::shared_ptr<PopupData> popupData);
132 void onActionTriggered(const Action& action);
139 sharedAction m_forward;
140 sharedAction m_stopLoading;
141 sharedAction m_reload;
142 sharedAction m_bookmark;
143 sharedAction m_unbookmark;
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;
155 * \brief filters URL before it is passed to WebEngine.
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.
161 void filterURL(const std::string& url);
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
167 void checkTabId(const tizen_browser::basic_webengine::TabId& id);
170 * \brief check if url comming back from WebEngine should be passed to URI.
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.
175 void webEngineURLChanged(const std::string& url);
178 * @brief Adds current page to bookmarks.
181 void addToBookmarks(void);
184 * @brief Remove current page from bookmarks
189 void deleteBookmark(void);
192 * \brief shows Zoom showZoomMenu
196 void zoomLevelChanged(int zoom_level);
202 * \brief shows Tab showTabMenu
206 void showSettingsMenu();
207 void hideSettingsMenu();
209 void showSearchBox();
210 void hideSearchBox();
212 void showProgressBar();
213 void hideProgressBar();
216 void showPopup(Evas_Object *content, char* btn1_text, char* btn2_text);
220 void closeTab(const tizen_browser::basic_webengine::TabId& id);
222 void settingsPointerModeSwitch(bool newState);
223 void settingsPrivateModeSwitch(bool newState);
224 void settingsDeleteHistory();
225 void settingsDeleteData();
226 void settingsDeleteFavorite();
227 void onDeleteHistoryButton(PopupButtons button, std::shared_ptr<PopupData> popupData);
228 void onDeleteDataButton(PopupButtons button, std::shared_ptr<PopupData> popupData);
229 void onDeleteFavoriteButton(PopupButtons button, std::shared_ptr<PopupData> popupData);
230 void tabLimitPopupButtonClicked(PopupButtons button, std::shared_ptr< PopupData > /*popupData*/);
231 void openLinkFromPopup(const std::string &);
232 void disableHistoryButton(bool flag);
234 void onNetworkError();
235 void onNetworkConnected();
236 void onNetErrorButtonPressed(PopupButtons, std::shared_ptr<PopupData>);
238 void onReturnPressed(MenuButton *m);
240 boost::signals2::signal<void ()> hidePopup;
242 std::string edjePath(const std::string &);
244 Evas_Object *m_mainLayout;
245 Evas_Object *m_progressBar;
246 Evas_Object *m_popup;
247 Evas_Object *m_errorLayout;
248 CustomPopup *m_ownPopup;
249 SimpleScroller *m_scroller;
251 std::shared_ptr<basic_webengine::AbstractWebEngine<Evas_Object>> m_webEngine;
252 std::shared_ptr<tizen_browser::base_ui::SimpleURI> m_simpleURI;
253 std::shared_ptr<ButtonBar> leftButtonBar;
254 std::shared_ptr<ButtonBar> rightButtonBar;
255 std::shared_ptr<tizen_browser::interfaces::AbstractFavoriteService> m_favoriteService;
256 std::shared_ptr<tizen_browser::services::HistoryService> m_historyService;
257 std::shared_ptr<tizen_browser::base_ui::BookmarksUI> m_bookmarksUI;
258 std::shared_ptr<tizen_browser::base_ui::ZoomList> m_zoomList;
259 std::shared_ptr<tizen_browser::base_ui::TabList> m_tabList;
260 std::shared_ptr<tizen_browser::base_ui::SearchBox> m_searchBox;
261 std::shared_ptr<tizen_browser::services::PlatformInputManager> m_platformInputManager;
262 std::shared_ptr<tizen_browser::services::SessionStorage> m_sessionService;
263 tizen_browser::Session::Session m_currentSession;
264 std::shared_ptr<Settings> m_settings;
265 std::shared_ptr<HistoryList> m_historyList;
266 std::shared_ptr<WebTitleBar> webTitleBar;
268 zoom_type m_currentZoom;
270 int m_favoritesLimit;
272 std::vector<std::shared_ptr<tizen_browser::services::HistoryItem>> items_vector;
273 std::unique_ptr<tizen_browser::basic_ui::NetworkErrorHandler> m_netErrorHandler;
274 SimplePopup* m_networkErrorPopup;
276 void searchWebPage(std::string &text, int flags);
277 static void favicon_clicked(void *data, Evas_Object *obj, const char *emission, const char *source);
284 #endif /* SIMPLEUI_H_ */