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"
43 #include "HistoryService.h"
44 #include "BookmarkManagerUI.h"
45 #include "PlatformInputManager.h"
46 #include "SessionStorage.h"
47 #include "SqlStorage.h"
51 #include "SimplePopup.h"
52 #include "WebConfirmation.h"
53 #include "BookmarksManager.h"
55 #include "ViewManager.h"
57 namespace tizen_browser{
61 void AbstractMainWindow<Evas_Object>::setMainWindow(Evas_Object * rawPtr)
63 m_window = std::shared_ptr<Evas_Object>(rawPtr, evas_object_del);
66 class BROWSER_EXPORT SimpleUI : public AbstractMainWindow<Evas_Object>
69 SimpleUI(/*Evas_Object *window*/);
71 virtual int exec(const std::string& url);
72 virtual std::string getName();
78 void connectActions();
79 void loadUIServices();
80 void connectUISignals();
81 void loadModelServices();
82 void initModelServices();
83 void initUIServices();
84 void connectModelSignals();
85 void restoreLastSession();
86 Evas_Object* createWebLayout(Evas_Object* parent);
87 Evas_Object* createErrorLayout(Evas_Object* parent);
89 void forwardEnable(bool enable);
90 void stopEnable(bool enable);
91 void reloadEnable(bool enable);
94 void progressChanged(double progress);
98 void setErrorButtons();
99 bool isErrorPageActive();
101 void bookmarkAdded();
102 void bookmarkDeleted();
105 void switchViewToQuickAccess();
106 void switchViewToWebPage();
109 void openNewTab(const std::string &uri, bool desktopMode = true);
110 void switchToTab(const tizen_browser::basic_webengine::TabId& tabId);
111 void newTabClicked();
112 void tabClicked(const tizen_browser::basic_webengine::TabId& tabId);
113 void closeTabsClicked(const tizen_browser::basic_webengine::TabId& tabId);
115 void tabClosed(const tizen_browser::basic_webengine::TabId& id);
117 std::vector<std::shared_ptr<tizen_browser::services::BookmarkItem> > getBookmarks(int folder_id = -1);
118 std::shared_ptr<services::HistoryItemVector> getHistory();
119 std::shared_ptr<services::HistoryItemVector> getMostVisitedItems();
121 //UI signal handling functions
122 void onBookmarkAdded(std::shared_ptr<tizen_browser::services::BookmarkItem> bookmarkItem);
124 void onBookmarkClicked(std::shared_ptr<tizen_browser::services::BookmarkItem> bookmarkItem);
125 void onBookmarkRemoved(const std::string& uri);
127 void onHistoryRemoved(const std::string& uri);
128 void onOpenURLInNewTab(std::shared_ptr<tizen_browser::services::HistoryItem> historyItem, bool desktopMode);
129 void onMostVisitedTileClicked(std::shared_ptr<tizen_browser::services::HistoryItem> historyItem, int itemsNumber);
130 void onClearHistoryClicked();
132 void onMostVisitedClicked();
133 void onBookmarkButtonClicked();
135 void handleConfirmationRequest(basic_webengine::WebConfirmationPtr webConfirmation);
136 void authPopupButtonClicked(PopupButtons button, std::shared_ptr<PopupData> popupData);
138 void onActionTriggered(const Action& action);
139 void setwvIMEStatus(bool status);
141 sharedAction m_showBookmarkManagerUI;
142 sharedAction m_settingPrivateBrowsing;
145 * \brief filters URL before it is passed to WebEngine.
147 * This function should be connected with m_simpleURI->uriChanged.
148 * it is a good place to check for special urls (like "about:home"),
149 * filter forbidden addresses and to check set favorite icon.
151 void filterURL(const std::string& url);
154 * Checks if correct tab is visible to user, and if not, it update browser view
155 * @param id of tab that should be visible to user
157 void checkTabId(const tizen_browser::basic_webengine::TabId& id);
160 * \brief check if url comming back from WebEngine should be passed to URI.
162 * For filtered addresses we need to hide real URI so the user would be confused.
163 * and this is a back function that checks if address emited from browser should be changed.
165 void webEngineURLChanged(const std::string url);
166 void onmostHistoryvisitedClicked();
167 void onBookmarkvisitedClicked();
169 * @brief Check if the current page exists as a bookmark.
172 bool checkBookmark();
174 * @brief Adds current page to bookmarks.
177 void addToBookmarks(int);
179 * @brief Remove current page from bookmarks
184 void deleteBookmark(void);
189 void closeMoreMenu();
190 void switchToMobileMode();
191 void switchToDesktopMode();
192 void showHistoryUI();
193 void closeHistoryUI();
194 void showSettingsUI();
195 void closeSettingsUI();
196 void closeBookmarkManagerUI();
197 void showBookmarkManagerUI();
198 void showPopup(Evas_Object *content, char* btn1_text, char* btn2_text);
201 void closeTab(const tizen_browser::basic_webengine::TabId& id);
203 void settingsPrivateModeSwitch(bool newState);
204 void settingsDeleteSelectedData(const std::string& str);
205 void settingsResetMostVisited();
206 void settingsResetBrowser();
207 void onDeleteSelectedDataButton(PopupButtons button, std::shared_ptr<PopupData> popupData);
208 void onDeleteMostVisitedButton(PopupButtons button, std::shared_ptr<PopupData> popupData);
209 void onResetBrowserButton(PopupButtons button, std::shared_ptr<PopupData> popupData);
210 void tabLimitPopupButtonClicked(PopupButtons button, std::shared_ptr< PopupData > /*popupData*/);
213 void onReturnPressed(MenuButton *m);
214 void onBackPressed();
216 void searchWebPage(std::string &text, int flags);
218 std::string edjePath(const std::string &);
220 Evas_Object *m_popup;
222 std::shared_ptr<WebPageUI> m_webPageUI;
223 std::shared_ptr<basic_webengine::AbstractWebEngine<Evas_Object>> m_webEngine;
224 std::shared_ptr<interfaces::AbstractFavoriteService> m_favoriteService;
225 std::shared_ptr<services::HistoryService> m_historyService;
226 std::shared_ptr<MoreMenuUI> m_moreMenuUI;
227 std::shared_ptr<BookmarkManagerUI> m_bookmarkManagerUI;
228 std::shared_ptr<MainUI> m_mainUI;
229 std::shared_ptr<HistoryUI> m_historyUI;
230 std::shared_ptr<SettingsUI> m_settingsUI;
231 std::shared_ptr<TabUI> m_tabUI;
232 std::shared_ptr<services::PlatformInputManager> m_platformInputManager;
233 std::shared_ptr<services::SessionStorage> m_sessionService;
234 Session::Session m_currentSession;
235 std::shared_ptr<BookmarksManager> m_bookmarks_manager;
238 int m_favoritesLimit;
241 //helper object used to view management
242 ViewManager* m_viewManager;
244 // This context object is used to implicitly init internal ewk data used by opengl to create the first and
245 // consecutive webviews in the application, otherwise we would encounter a crash after creating
246 // the first web view
247 Ewk_Context *m_ewkContext;
253 #endif /* SIMPLEUI_H_ */