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"
41 #include "QuickAccess.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();
105 void showQuickAccess();
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 bool checkIfCreate();
117 void tabClosed(const tizen_browser::basic_webengine::TabId& id);
119 std::vector<std::shared_ptr<tizen_browser::services::BookmarkItem> > getBookmarks(int folder_id = -1);
120 std::shared_ptr<services::HistoryItemVector> getHistory();
121 std::shared_ptr<services::HistoryItemVector> getMostVisitedItems();
123 //UI signal handling functions
124 void onBookmarkAdded(std::shared_ptr<tizen_browser::services::BookmarkItem> bookmarkItem);
126 void onBookmarkClicked(std::shared_ptr<tizen_browser::services::BookmarkItem> bookmarkItem);
127 void onBookmarkRemoved(const std::string& uri);
129 void onHistoryRemoved(const std::string& uri);
130 void onOpenURLInNewTab(std::shared_ptr<tizen_browser::services::HistoryItem> historyItem, bool desktopMode);
131 void onMostVisitedTileClicked(std::shared_ptr<tizen_browser::services::HistoryItem> historyItem, int itemsNumber);
132 void onClearHistoryClicked();
134 void onMostVisitedClicked();
135 void onBookmarkButtonClicked();
137 void handleConfirmationRequest(basic_webengine::WebConfirmationPtr webConfirmation);
138 void authPopupButtonClicked(PopupButtons button, std::shared_ptr<PopupData> popupData);
140 void onActionTriggered(const Action& action);
141 void setwvIMEStatus(bool status);
143 sharedAction m_showBookmarkManagerUI;
144 sharedAction m_settingPrivateBrowsing;
147 * \brief filters URL before it is passed to WebEngine.
149 * This function should be connected with m_simpleURI->uriChanged.
150 * it is a good place to check for special urls (like "about:home"),
151 * filter forbidden addresses and to check set favorite icon.
153 void filterURL(const std::string& url);
156 * Checks if correct tab is visible to user, and if not, it update browser view
157 * @param id of tab that should be visible to user
159 void checkTabId(const tizen_browser::basic_webengine::TabId& id);
162 * \brief check if url comming back from WebEngine should be passed to URI.
164 * For filtered addresses we need to hide real URI so the user would be confused.
165 * and this is a back function that checks if address emited from browser should be changed.
167 void webEngineURLChanged(const std::string url);
168 void onmostHistoryvisitedClicked();
169 void onBookmarkvisitedClicked();
171 * @brief Check if the current page exists as a bookmark.
174 bool checkBookmark();
176 * @brief Adds current page to bookmarks.
179 void addToBookmarks(int);
181 * @brief Remove current page from bookmarks
186 void deleteBookmark(void);
189 * @brief show Zoom Menu
193 void setZoomFactor(int level);
194 void scrollView(const int& dx, const int& dy);
199 void closeMoreMenu();
200 void switchToMobileMode();
201 void switchToDesktopMode();
202 void showHistoryUI();
203 void closeHistoryUI();
204 void showSettingsUI();
205 void closeSettingsUI();
206 void closeBookmarkManagerUI();
207 void showBookmarkManagerUI();
208 void showPopup(Evas_Object *content, char* btn1_text, char* btn2_text);
211 void closeTab(const tizen_browser::basic_webengine::TabId& id);
213 void settingsPrivateModeSwitch(bool newState);
214 void settingsDeleteSelectedData(const std::string& str);
215 void settingsResetMostVisited();
216 void settingsResetBrowser();
217 void onDeleteSelectedDataButton(const std::string &dataText);
218 void onDeleteMostVisitedButton(std::shared_ptr<PopupData> popupData);
219 void onResetBrowserButton(PopupButtons button, std::shared_ptr<PopupData> popupData);
220 void tabLimitPopupButtonClicked(PopupButtons button, std::shared_ptr< PopupData > /*popupData*/);
223 void onReturnPressed(MenuButton *m);
224 void onBackPressed();
226 void searchWebPage(std::string &text, int flags);
228 std::string edjePath(const std::string &);
230 Evas_Object *m_popup;
232 std::shared_ptr<WebPageUI> m_webPageUI;
233 std::shared_ptr<basic_webengine::AbstractWebEngine<Evas_Object>> m_webEngine;
234 std::shared_ptr<interfaces::AbstractFavoriteService> m_favoriteService;
235 std::shared_ptr<services::HistoryService> m_historyService;
236 std::shared_ptr<MoreMenuUI> m_moreMenuUI;
237 std::shared_ptr<BookmarkManagerUI> m_bookmarkManagerUI;
238 std::shared_ptr<QuickAccess> m_quickAccess;
239 std::shared_ptr<HistoryUI> m_historyUI;
240 std::shared_ptr<SettingsUI> m_settingsUI;
241 std::shared_ptr<TabUI> m_tabUI;
242 std::shared_ptr<services::PlatformInputManager> m_platformInputManager;
243 std::shared_ptr<services::SessionStorage> m_sessionService;
244 Session::Session m_currentSession;
245 std::shared_ptr<tizen_browser::base_ui::ZoomUI> m_zoomUI;
246 std::shared_ptr<BookmarksManager> m_bookmarks_manager;
249 int m_favoritesLimit;
252 //helper object used to view management
253 ViewManager* m_viewManager;
255 // This context object is used to implicitly init internal ewk data used by opengl to create the first and
256 // consecutive webviews in the application, otherwise we would encounter a crash after creating
257 // the first web view
258 Ewk_Context *m_ewkContext;
264 #endif /* SIMPLEUI_H_ */