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 "NetworkErrorHandler.h"
59 #include "CustomPopup.h"
62 namespace tizen_browser{
66 void AbstractMainWindow<Evas_Object>::setMainWindow(Evas_Object * rawPtr)
68 m_window = std::shared_ptr<Evas_Object>(rawPtr, evas_object_del);
73 class BROWSER_EXPORT SimpleUI : public AbstractMainWindow<Evas_Object>
76 SimpleUI(/*Evas_Object *window*/);
78 virtual int exec(const std::string& url);
79 virtual std::string getName();
84 void connectActions();
86 void backEnable(bool enable);
87 void forwardEnable(bool enable);
88 void stopEnable(bool enable);
89 void reloadEnable(bool enable);
90 void addBookmarkEnable(bool enable);
91 void removeBookmarkEnable(bool enable);
92 void zoomEnable(bool enable);
94 void settingsButtonEnable(bool enable);
97 void progressChanged(double progress);
101 void setErrorButtons();
102 bool isErrorPageActive();
104 void bookmarkAdded();
105 void bookmarkDeleted();
107 bool isHomePageActive();
108 void switchViewToHomePage();
109 void switchViewToBrowser();
110 void updateBrowserView();
113 void openNewTab(const std::string &uri);
114 void switchToTab(const tizen_browser::basic_webengine::TabId& tabId);
115 void newTabClicked();
116 void tabClicked(const tizen_browser::basic_webengine::TabId& tabId);
118 void tabClosed(const tizen_browser::basic_webengine::TabId& id);
120 void bookmarkCheck();
121 std::vector<std::shared_ptr<tizen_browser::services::BookmarkItem> > getBookmarks();
122 void onBookmarkAdded(std::shared_ptr<tizen_browser::services::BookmarkItem> bookmarkItem);
123 void onBookmarkClicked(std::shared_ptr<tizen_browser::services::BookmarkItem> bookmarkItem);
124 void onBookmarkDeleteClicked(std::shared_ptr<tizen_browser::services::BookmarkItem> bookmarkItem);
125 void onBookmarkRemoved(const std::string& uri);
127 void handleConfirmationRequest(basic_webengine::WebConfirmationPtr webConfirmation);
128 void authPopupButtonClicked(PopupButtons button, std::shared_ptr<PopupData> popupData);
130 void onActionTriggered(const Action& action);
134 void setwvIMEStatus(bool status);
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 showProgressBar();
210 void hideProgressBar();
213 void showPopup(Evas_Object *content, char* btn1_text, char* btn2_text);
217 void closeTab(const tizen_browser::basic_webengine::TabId& id);
219 void settingsPointerModeSwitch(bool newState);
220 void settingsPrivateModeSwitch(bool newState);
221 void settingsDeleteHistory();
222 void settingsDeleteData();
223 void settingsDeleteFavorite();
224 void onDeleteHistoryButton(PopupButtons button, std::shared_ptr<PopupData> popupData);
225 void onDeleteDataButton(PopupButtons button, std::shared_ptr<PopupData> popupData);
226 void onDeleteFavoriteButton(PopupButtons button, std::shared_ptr<PopupData> popupData);
227 void tabLimitPopupButtonClicked(PopupButtons button, std::shared_ptr< PopupData > /*popupData*/);
228 void openLinkFromPopup(const std::string &);
229 void disableHistoryButton(bool flag);
231 void onNetworkError();
232 void onNetworkConnected();
233 void onNetErrorButtonPressed(PopupButtons, std::shared_ptr<PopupData>);
235 void onReturnPressed(MenuButton *m);
236 void onBackPressed();
238 boost::signals2::signal<void ()> hidePopup;
240 std::string edjePath(const std::string &);
242 Evas_Object *m_mainLayout;
243 Evas_Object *m_progressBar;
244 Evas_Object *m_popup;
245 Evas_Object *m_errorLayout;
246 CustomPopup *m_ownPopup;
247 SimpleScroller *m_scroller;
249 std::shared_ptr<basic_webengine::AbstractWebEngine<Evas_Object>> m_webEngine;
250 std::shared_ptr<tizen_browser::base_ui::SimpleURI> m_simpleURI;
251 std::shared_ptr<ButtonBar> leftButtonBar;
252 std::shared_ptr<ButtonBar> rightButtonBar;
253 std::shared_ptr<tizen_browser::interfaces::AbstractFavoriteService> m_favoriteService;
254 std::shared_ptr<tizen_browser::services::HistoryService> m_historyService;
255 std::shared_ptr<tizen_browser::base_ui::BookmarksUI> m_bookmarksUI;
256 std::shared_ptr<tizen_browser::base_ui::ZoomList> m_zoomList;
257 std::shared_ptr<tizen_browser::base_ui::TabList> m_tabList;
258 std::shared_ptr<tizen_browser::services::PlatformInputManager> m_platformInputManager;
259 std::shared_ptr<tizen_browser::services::SessionStorage> m_sessionService;
260 tizen_browser::Session::Session m_currentSession;
261 std::shared_ptr<Settings> m_settings;
262 std::shared_ptr<HistoryList> m_historyList;
263 std::shared_ptr<WebTitleBar> webTitleBar;
265 zoom_type m_currentZoom;
267 int m_favoritesLimit;
270 std::vector<std::shared_ptr<tizen_browser::services::HistoryItem>> items_vector;
271 std::unique_ptr<tizen_browser::basic_ui::NetworkErrorHandler> m_netErrorHandler;
272 SimplePopup* m_networkErrorPopup;
274 void searchWebPage(std::string &text, int flags);
275 static void favicon_clicked(void *data, Evas_Object *obj, const char *emission, const char *source);
282 #endif /* SIMPLEUI_H_ */