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"
44 #include "HistoryService.h"
45 #include "BookmarkManagerUI.h"
46 #include "PlatformInputManager.h"
47 #include "SessionStorage.h"
48 #include "SqlStorage.h"
52 #include "SimplePopup.h"
53 #include "WebConfirmation.h"
54 #include "BookmarksManager.h"
56 #include "ViewManager.h"
58 namespace tizen_browser{
62 void AbstractMainWindow<Evas_Object>::setMainWindow(Evas_Object * rawPtr)
64 m_window = std::shared_ptr<Evas_Object>(rawPtr, evas_object_del);
67 class BROWSER_EXPORT SimpleUI : public AbstractMainWindow<Evas_Object>
70 SimpleUI(/*Evas_Object *window*/);
72 virtual int exec(const std::string& url);
73 virtual std::string getName();
79 void connectActions();
80 void loadUIServices();
81 void connectUISignals();
82 void loadModelServices();
83 void initModelServices();
84 void initUIServices();
85 void connectModelSignals();
86 void restoreLastSession();
87 Evas_Object* createWebLayout(Evas_Object* parent);
88 Evas_Object* createErrorLayout(Evas_Object* parent);
90 void forwardEnable(bool enable);
91 void stopEnable(bool enable);
92 void reloadEnable(bool enable);
95 void progressChanged(double progress);
99 void setErrorButtons();
100 bool isErrorPageActive();
102 void bookmarkAdded();
103 void bookmarkDeleted();
106 void switchViewToQuickAccess();
107 void switchViewToWebPage();
110 void openNewTab(const std::string &uri, bool desktopMode = true);
111 void switchToTab(const tizen_browser::basic_webengine::TabId& tabId);
112 void newTabClicked();
113 void tabClicked(const tizen_browser::basic_webengine::TabId& tabId);
114 void closeTabsClicked(const tizen_browser::basic_webengine::TabId& tabId);
116 void tabClosed(const tizen_browser::basic_webengine::TabId& id);
118 std::vector<std::shared_ptr<tizen_browser::services::BookmarkItem> > getBookmarks(int folder_id = -1);
119 std::shared_ptr<services::HistoryItemVector> getHistory();
120 std::shared_ptr<services::HistoryItemVector> getMostVisitedItems();
122 //UI signal handling functions
123 void onBookmarkAdded(std::shared_ptr<tizen_browser::services::BookmarkItem> bookmarkItem);
125 void onBookmarkClicked(std::shared_ptr<tizen_browser::services::BookmarkItem> bookmarkItem);
126 void onBookmarkRemoved(const std::string& uri);
128 void onHistoryRemoved(const std::string& uri);
129 void onOpenURLInNewTab(std::shared_ptr<tizen_browser::services::HistoryItem> historyItem, bool desktopMode);
130 void onMostVisitedTileClicked(std::shared_ptr<tizen_browser::services::HistoryItem> historyItem, int itemsNumber);
131 void onClearHistoryClicked();
133 void onMostVisitedClicked();
134 void onBookmarkButtonClicked();
136 void handleConfirmationRequest(basic_webengine::WebConfirmationPtr webConfirmation);
137 void authPopupButtonClicked(PopupButtons button, std::shared_ptr<PopupData> popupData);
139 void onActionTriggered(const Action& action);
140 void setwvIMEStatus(bool status);
142 sharedAction m_showBookmarkManagerUI;
143 sharedAction m_settingPrivateBrowsing;
146 * \brief filters URL before it is passed to WebEngine.
148 * This function should be connected with m_simpleURI->uriChanged.
149 * it is a good place to check for special urls (like "about:home"),
150 * filter forbidden addresses and to check set favorite icon.
152 void filterURL(const std::string& url);
155 * Checks if correct tab is visible to user, and if not, it update browser view
156 * @param id of tab that should be visible to user
158 void checkTabId(const tizen_browser::basic_webengine::TabId& id);
161 * \brief check if url comming back from WebEngine should be passed to URI.
163 * For filtered addresses we need to hide real URI so the user would be confused.
164 * and this is a back function that checks if address emited from browser should be changed.
166 void webEngineURLChanged(const std::string url);
167 void onmostHistoryvisitedClicked();
168 void onBookmarkvisitedClicked();
170 * @brief Check if the current page exists as a bookmark.
173 bool checkBookmark();
175 * @brief Adds current page to bookmarks.
178 void addToBookmarks(int);
180 * @brief Remove current page from bookmarks
185 void deleteBookmark(void);
188 * @brief show Zoom Menu
192 void setZoomFactor(int level);
193 void scrollView(const int& dx, const int& dy);
198 void closeMoreMenu();
199 void switchToMobileMode();
200 void switchToDesktopMode();
201 void showHistoryUI();
202 void closeHistoryUI();
203 void showSettingsUI();
204 void closeSettingsUI();
205 void closeBookmarkManagerUI();
206 void showBookmarkManagerUI();
207 void showPopup(Evas_Object *content, char* btn1_text, char* btn2_text);
210 void closeTab(const tizen_browser::basic_webengine::TabId& id);
212 void settingsPrivateModeSwitch(bool newState);
213 void settingsDeleteSelectedData(const std::string& str);
214 void settingsResetMostVisited();
215 void settingsResetBrowser();
216 void onDeleteSelectedDataButton(PopupButtons button, std::shared_ptr<PopupData> popupData);
217 void onDeleteMostVisitedButton(PopupButtons button, std::shared_ptr<PopupData> popupData);
218 void onResetBrowserButton(PopupButtons button, std::shared_ptr<PopupData> popupData);
219 void tabLimitPopupButtonClicked(PopupButtons button, std::shared_ptr< PopupData > /*popupData*/);
222 void onReturnPressed(MenuButton *m);
223 void onBackPressed();
225 void searchWebPage(std::string &text, int flags);
227 std::string edjePath(const std::string &);
229 Evas_Object *m_popup;
231 std::shared_ptr<WebPageUI> m_webPageUI;
232 std::shared_ptr<basic_webengine::AbstractWebEngine<Evas_Object>> m_webEngine;
233 std::shared_ptr<interfaces::AbstractFavoriteService> m_favoriteService;
234 std::shared_ptr<services::HistoryService> m_historyService;
235 std::shared_ptr<MoreMenuUI> m_moreMenuUI;
236 std::shared_ptr<BookmarkManagerUI> m_bookmarkManagerUI;
237 std::shared_ptr<MainUI> m_mainUI;
238 std::shared_ptr<HistoryUI> m_historyUI;
239 std::shared_ptr<SettingsUI> m_settingsUI;
240 std::shared_ptr<TabUI> m_tabUI;
241 std::shared_ptr<services::PlatformInputManager> m_platformInputManager;
242 std::shared_ptr<services::SessionStorage> m_sessionService;
243 Session::Session m_currentSession;
244 std::shared_ptr<tizen_browser::base_ui::ZoomUI> m_zoomUI;
245 std::shared_ptr<BookmarksManager> m_bookmarks_manager;
248 int m_favoritesLimit;
251 //helper object used to view management
252 ViewManager* m_viewManager;
254 // This context object is used to implicitly init internal ewk data used by opengl to create the first and
255 // consecutive webviews in the application, otherwise we would encounter a crash after creating
256 // the first web view
257 Ewk_Context *m_ewkContext;
263 #endif /* SIMPLEUI_H_ */