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();
74 void suspend() {m_webEngine->suspend();}
75 void resume() {m_webEngine->resume();}
81 void connectActions();
82 void loadUIServices();
83 void connectUISignals();
84 void loadModelServices();
85 void initModelServices();
86 void initUIServices();
87 void connectModelSignals();
88 void restoreLastSession();
89 Evas_Object* createWebLayout(Evas_Object* parent);
90 Evas_Object* createErrorLayout(Evas_Object* parent);
92 void forwardEnable(bool enable);
93 void stopEnable(bool enable);
94 void reloadEnable(bool enable);
97 void progressChanged(double progress);
101 void setErrorButtons();
102 bool isErrorPageActive();
104 void bookmarkAdded();
105 void bookmarkDeleted();
107 void showQuickAccess();
108 void switchViewToQuickAccess();
109 void switchViewToIncognitoPage();
110 void switchViewToWebPage();
113 void openNewTab(const std::string &uri, bool desktopMode = true);
114 void switchToTab(const tizen_browser::basic_webengine::TabId& tabId);
115 void newTabClicked();
116 void tabClicked(const tizen_browser::basic_webengine::TabId& tabId);
117 void closeTabsClicked(const tizen_browser::basic_webengine::TabId& tabId);
119 bool checkIfCreate();
120 void tabClosed(const tizen_browser::basic_webengine::TabId& id);
122 std::vector<std::shared_ptr<tizen_browser::services::BookmarkItem> > getBookmarks(int folder_id = -1);
123 std::shared_ptr<services::HistoryItemVector> getHistory();
124 std::shared_ptr<services::HistoryItemVector> getMostVisitedItems();
126 //UI signal handling functions
127 void onBookmarkAdded(std::shared_ptr<tizen_browser::services::BookmarkItem> bookmarkItem);
129 void onBookmarkClicked(std::shared_ptr<tizen_browser::services::BookmarkItem> bookmarkItem);
130 void onBookmarkRemoved(const std::string& uri);
132 void onHistoryRemoved(const std::string& uri);
133 void onOpenURLInNewTab(std::shared_ptr<tizen_browser::services::HistoryItem> historyItem, bool desktopMode);
134 void onMostVisitedTileClicked(std::shared_ptr<tizen_browser::services::HistoryItem> historyItem, int itemsNumber);
135 void onClearHistoryClicked();
137 void onMostVisitedClicked();
138 void onBookmarkButtonClicked();
140 void handleConfirmationRequest(basic_webengine::WebConfirmationPtr webConfirmation);
141 void authPopupButtonClicked(PopupButtons button, std::shared_ptr<PopupData> popupData);
143 void onActionTriggered(const Action& action);
145 void setwvIMEStatus(bool status);
147 sharedAction m_showBookmarkManagerUI;
148 sharedAction m_settingPrivateBrowsing;
151 * \brief filters URL before it is passed to WebEngine.
153 * This function should be connected with m_simpleURI->uriChanged.
154 * it is a good place to check for special urls (like "about:home"),
155 * filter forbidden addresses and to check set favorite icon.
157 void filterURL(const std::string& url);
159 // // on uri entry widget "changed,user" signal
160 void onURLEntryEditedByUser(const std::shared_ptr<std::string> editedUrlPtr);
161 // on uri entry widget "changed" signal
162 void onURLEntryEdited();
165 * \brief check if url comming back from WebEngine should be passed to URI.
167 * For filtered addresses we need to hide real URI so the user would be confused.
168 * and this is a back function that checks if address emited from browser should be changed.
170 void webEngineURLChanged(const std::string url);
171 void onmostHistoryvisitedClicked();
172 void onBookmarkvisitedClicked();
174 * @brief Check if the current page exists as a bookmark.
177 bool checkBookmark();
179 * @brief Adds current page to bookmarks.
182 void addToBookmarks(int);
184 * @brief Remove current page from bookmarks
189 void deleteBookmark(void);
192 * @brief show Zoom Menu
196 void setZoomFactor(int level);
198 void scrollView(const int& dx, const int& dy);
203 void closeMoreMenu();
204 void switchToMobileMode();
205 void switchToDesktopMode();
206 void showHistoryUI();
207 void closeHistoryUI();
208 void showSettingsUI();
209 void closeSettingsUI();
210 void closeBookmarkManagerUI();
211 void showBookmarkManagerUI();
212 void showPopup(Evas_Object *content, char* btn1_text, char* btn2_text);
215 void closeTab(const tizen_browser::basic_webengine::TabId& id);
217 void settingsPrivateModeSwitch(bool newState);
218 void applyPrivateModeToTab(const tizen_browser::basic_webengine::TabId& id);
219 void settingsDeleteSelectedData(const std::string& str);
220 void settingsResetMostVisited();
221 void settingsResetBrowser();
222 void onDeleteSelectedDataButton(const std::string &dataText);
223 void onDeleteMostVisitedButton(std::shared_ptr<PopupData> popupData);
224 void onResetBrowserButton(PopupButtons button, std::shared_ptr<PopupData> popupData);
225 void tabLimitPopupButtonClicked(PopupButtons button, std::shared_ptr< PopupData > /*popupData*/);
228 void onReturnPressed(MenuButton *m);
229 void onBackPressed();
230 void onEscapePressed();
232 void searchWebPage(std::string &text, int flags);
234 std::string edjePath(const std::string &);
236 Evas_Object *m_popup;
238 std::shared_ptr<WebPageUI> m_webPageUI;
239 std::shared_ptr<basic_webengine::AbstractWebEngine<Evas_Object>> m_webEngine;
240 std::shared_ptr<interfaces::AbstractFavoriteService> m_favoriteService;
241 std::shared_ptr<services::HistoryService> m_historyService;
242 std::shared_ptr<MoreMenuUI> m_moreMenuUI;
243 std::shared_ptr<BookmarkManagerUI> m_bookmarkManagerUI;
244 std::shared_ptr<QuickAccess> m_quickAccess;
245 std::shared_ptr<HistoryUI> m_historyUI;
246 std::shared_ptr<SettingsUI> m_settingsUI;
247 std::shared_ptr<TabUI> m_tabUI;
248 std::shared_ptr<services::PlatformInputManager> m_platformInputManager;
249 std::shared_ptr<services::SessionStorage> m_sessionService;
250 Session::Session m_currentSession;
251 std::shared_ptr<tizen_browser::base_ui::ZoomUI> m_zoomUI;
252 std::shared_ptr<BookmarksManager> m_bookmarks_manager;
255 int m_favoritesLimit;
259 //helper object used to view management
260 ViewManager* m_viewManager;
262 // This context object is used to implicitly init internal ewk data used by opengl to create the first and
263 // consecutive webviews in the application, otherwise we would encounter a crash after creating
264 // the first web view
265 Ewk_Context *m_ewkContext;
271 #endif /* SIMPLEUI_H_ */