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 "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"
52 #include "SimplePopup.h"
53 #include "WebConfirmation.h"
57 #include "HistoryList.h"
58 #include "SearchBox.h"
59 #include "NetworkErrorHandler.h"
60 #include "CustomPopup.h"
63 namespace tizen_browser{
67 void AbstractMainWindow<Evas_Object>::setMainWindow(Evas_Object * rawPtr)
69 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 switchViewToBrowser();
111 void updateBrowserView();
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);
119 void tabClosed(const tizen_browser::basic_webengine::TabId& id);
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);
128 void handleConfirmationRequest(basic_webengine::WebConfirmationPtr webConfirmation);
129 void authPopupButtonClicked(PopupButtons button, std::shared_ptr<PopupData> popupData);
131 void onActionTriggered(const Action& action);
138 sharedAction m_forward;
139 sharedAction m_stopLoading;
140 sharedAction m_reload;
141 sharedAction m_bookmark;
142 sharedAction m_unbookmark;
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;
154 * \brief filters URL before it is passed to WebEngine.
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.
160 void filterURL(const std::string& url);
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
166 void checkTabId(const tizen_browser::basic_webengine::TabId& id);
169 * \brief check if url comming back from WebEngine should be passed to URI.
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.
174 void webEngineURLChanged(const std::string& url);
177 * @brief Adds current page to bookmarks.
180 void addToBookmarks(void);
183 * @brief Remove current page from bookmarks
188 void deleteBookmark(void);
191 * \brief shows Zoom showZoomMenu
195 void zoomLevelChanged(int zoom_level);
201 * \brief shows Tab showTabMenu
205 void showSettingsMenu();
206 void hideSettingsMenu();
208 void showSearchBox();
209 void hideSearchBox();
211 void showProgressBar();
212 void hideProgressBar();
215 void showPopup(Evas_Object *content, char* btn1_text, char* btn2_text);
219 void closeTab(const tizen_browser::basic_webengine::TabId& id);
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);
233 void onNetworkError();
234 void onNetworkConnected();
235 void onNetErrorButtonPressed(PopupButtons, std::shared_ptr<PopupData>);
237 void onReturnPressed(MenuButton *m);
239 boost::signals2::signal<void ()> hidePopup;
241 std::string edjePath(const std::string &);
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;
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;
267 zoom_type m_currentZoom;
269 int m_favoritesLimit;
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;
275 void searchWebPage(std::string &text, int flags);
276 static void favicon_clicked(void *data, Evas_Object *obj, const char *emission, const char *source);
283 #endif /* SIMPLEUI_H_ */