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.
17 #include "browser_config.h"
19 #if defined(USE_EWEBKIT)
20 #include <ewk_chromium.h>
23 #include <boost/any.hpp>
26 #include <Elementary.h>
28 #include <Ecore_Wayland.h>
33 #include "BrowserLogger.h"
34 #include "ServiceManager.h"
35 #include "AbstractWebEngine.h"
37 #include "Tools/EflTools.h"
38 #include "BrowserImage.h"
40 #include "BookmarkItem.h"
41 #include "Tools/EflTools.h"
42 #include "BrowserImage.h"
43 #include "HistoryItem.h"
44 #include "BookmarkItem.h"
45 #include "boost/date_time/gregorian/gregorian.hpp"
46 #include "boost/date_time/posix_time/posix_time.hpp"
47 #include "SqlStorage.h"
48 #include "DetailPopup.h"
49 #include "UrlHistoryList/UrlHistoryList.h"
50 #include "NotificationPopup.h"
53 namespace tizen_browser{
56 EXPORT_SERVICE(SimpleUI, "org.tizen.browser.simpleui")
58 const std::string HomePageURL = "about:home";
59 const int ROOT_FOLDER = 0;
63 : AbstractMainWindow()
67 , m_bookmarkManagerUI()
72 , m_initialised(false)
73 , m_wvIMEStatus(false)
75 , m_ewkContext(ewk_context_new())
77 BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
79 Evas_Object *main_window = elm_win_util_standard_add("browserApp", "browserApp");
80 if (main_window == nullptr)
81 BROWSER_LOGE("Failed to create main window");
83 setMainWindow(main_window);
84 m_viewManager = new ViewManager(main_window);
85 evas_object_size_hint_weight_set(main_window, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
86 evas_object_size_hint_align_set (main_window, EVAS_HINT_FILL, EVAS_HINT_FILL);
88 elm_win_resize_object_add(main_window, m_viewManager->getContent());
89 evas_object_show(main_window);
92 SimpleUI::~SimpleUI() {
93 BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
94 m_sessionService->getStorage()->deleteSession(m_currentSession);
95 evas_object_del(m_window.get());
96 ewk_context_delete(m_ewkContext);
99 void SimpleUI::destroyUI()
101 BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
102 evas_object_del(m_window.get());
105 std::string SimpleUI::edjePath(const std::string &file)
107 return std::string(EDJE_DIR) + file;
110 std::vector<std::shared_ptr<tizen_browser::services::BookmarkItem> > SimpleUI::getBookmarks(int folder_id)
112 return m_favoriteService->getBookmarks(folder_id);
115 std::shared_ptr<services::HistoryItemVector> SimpleUI::getMostVisitedItems()
117 return m_historyService->getMostVisitedHistoryItems();
120 std::shared_ptr<services::HistoryItemVector> SimpleUI::getHistory()
122 return m_historyService->getHistoryToday();
125 int SimpleUI::exec(const std::string& _url)
127 BROWSER_LOGD("[%s] _url=%s, initialised=%d", __func__, _url.c_str(), m_initialised);
128 std::string url = _url;
131 if (m_window.get()) {
132 config::DefaultConfig config;
134 m_tabLimit = boost::any_cast <int> (config.get("TAB_LIMIT"));
135 m_favoritesLimit = boost::any_cast <int> (config.get("FAVORITES_LIMIT"));
142 // initModelServices() needs to be called after initUIServices()
147 connectModelSignals();
151 //Push first view to stack.
152 m_viewManager->pushViewToStack(m_webPageUI.get());
154 m_initialised = true;
157 m_currentSession = std::move(m_sessionService->getStorage()->createSession());
161 BROWSER_LOGD("[%s]: changing to homeUrl", __func__);
162 switchViewToQuickAccess();
163 restoreLastSession();
168 BROWSER_LOGD("[%s]:%d url=%s", __func__, __LINE__, url.c_str());
172 void SimpleUI::restoreLastSession()
174 BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
175 M_ASSERT(m_sessionService);
176 Session::Session lastSession = std::move(m_sessionService->getStorage()->getLastSession());
177 if(lastSession.items().size() >= 1)
179 for(auto iter=lastSession.items().begin(), end=lastSession.items().end(); iter != end; ++iter)
181 openNewTab(iter->second);
183 m_sessionService->getStorage()->deleteSession(lastSession);
188 //TODO: Move all service creation here:
189 void SimpleUI::loadUIServices()
191 BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
194 std::dynamic_pointer_cast
195 <tizen_browser::base_ui::WebPageUI,tizen_browser::core::AbstractService>
196 (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.webpageui"));
199 std::dynamic_pointer_cast
200 <tizen_browser::base_ui::QuickAccess,tizen_browser::core::AbstractService>
201 (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.quickaccess"));
204 std::dynamic_pointer_cast
205 <tizen_browser::base_ui::TabUI,tizen_browser::core::AbstractService>
206 (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.tabui"));
209 std::dynamic_pointer_cast
210 <tizen_browser::base_ui::HistoryUI,tizen_browser::core::AbstractService>
211 (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.historyui"));
214 std::dynamic_pointer_cast
215 <tizen_browser::base_ui::SettingsUI,tizen_browser::core::AbstractService>
216 (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.settingsui"));
219 std::dynamic_pointer_cast
220 <tizen_browser::base_ui::MoreMenuUI,tizen_browser::core::AbstractService>
221 (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.moremenuui"));
223 m_bookmarkManagerUI =
224 std::dynamic_pointer_cast
225 <tizen_browser::base_ui::BookmarkManagerUI,tizen_browser::core::AbstractService>
226 (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.bookmarkmanagerui"));
229 std::dynamic_pointer_cast
230 <tizen_browser::base_ui::ZoomUI, tizen_browser::core::AbstractService>
231 (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.zoomui"));
234 void SimpleUI::connectUISignals()
236 BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
238 M_ASSERT(m_webPageUI.get());
239 m_webPageUI->getURIEntry().uriChanged.connect(boost::bind(&SimpleUI::filterURL, this, _1));
240 m_webPageUI->getURIEntry().uriEntryEditingChangedByUser.connect(boost::bind(&SimpleUI::onURLEntryEditedByUser, this, _1));
241 m_webPageUI->getURIEntry().uriEntryEditingChanged.connect(boost::bind(&SimpleUI::onURLEntryEdited, this));
242 m_webPageUI->backPage.connect(boost::bind(&SimpleUI::switchViewToWebPage, this));
243 m_webPageUI->backPage.connect(boost::bind(&tizen_browser::basic_webengine::AbstractWebEngine<Evas_Object>::back, m_webEngine.get()));
244 m_webPageUI->backPage.connect(boost::bind(&ZoomUI::showNavigation, m_zoomUI.get()));
245 m_webPageUI->reloadPage.connect(boost::bind(&SimpleUI::switchViewToWebPage, this));
246 m_webPageUI->showTabUI.connect(boost::bind(&SimpleUI::showTabUI, this));
247 m_webPageUI->showMoreMenu.connect(boost::bind(&SimpleUI::showMoreMenu, this));
248 m_webPageUI->forwardPage.connect(boost::bind(&tizen_browser::basic_webengine::AbstractWebEngine<Evas_Object>::forward, m_webEngine.get()));
249 m_webPageUI->forwardPage.connect(boost::bind(&ZoomUI::showNavigation, m_zoomUI.get()));
250 m_webPageUI->stopLoadingPage.connect(boost::bind(&tizen_browser::basic_webengine::AbstractWebEngine<Evas_Object>::stopLoading, m_webEngine.get()));
251 m_webPageUI->stopLoadingPage.connect(boost::bind(&ZoomUI::showNavigation, m_zoomUI.get()));
252 m_webPageUI->reloadPage.connect(boost::bind(&tizen_browser::basic_webengine::AbstractWebEngine<Evas_Object>::reload, m_webEngine.get()));
253 m_webPageUI->reloadPage.connect(boost::bind(&ZoomUI::showNavigation, m_zoomUI.get()));
254 m_webPageUI->showQuickAccess.connect(boost::bind(&SimpleUI::showQuickAccess, this));
255 m_webPageUI->hideQuickAccess.connect(boost::bind(&QuickAccess::hideUI, m_quickAccess));
256 m_webPageUI->bookmarkManagerClicked.connect(boost::bind(&SimpleUI::showBookmarkManagerUI, this));
257 m_webPageUI->showZoomNavigation.connect(boost::bind(&ZoomUI::showNavigation, m_zoomUI.get()));
259 M_ASSERT(m_quickAccess.get());
260 m_quickAccess->getDetailPopup().openURLInNewTab.connect(boost::bind(&SimpleUI::onOpenURLInNewTab, this, _1, _2));
261 m_quickAccess->getUrlHistoryList()->openURLInNewTab.connect(boost::bind(&SimpleUI::onOpenURLInNewTab, this, _1, _2));
262 m_quickAccess->openURLInNewTab.connect(boost::bind(&SimpleUI::onOpenURLInNewTab, this, _1, _2));
263 m_quickAccess->mostVisitedTileClicked.connect(boost::bind(&SimpleUI::onMostVisitedTileClicked, this, _1, _2));
264 m_quickAccess->mostVisitedClicked.connect(boost::bind(&SimpleUI::onMostVisitedClicked, this));
265 m_quickAccess->bookmarkClicked.connect(boost::bind(&SimpleUI::onBookmarkButtonClicked, this));
266 m_quickAccess->bookmarkManagerClicked.connect(boost::bind(&SimpleUI::showBookmarkManagerUI, this));
268 M_ASSERT(m_tabUI.get());
269 m_tabUI->closeTabUIClicked.connect(boost::bind(&SimpleUI::closeTabUI, this));
270 m_tabUI->closeTabUIClicked.connect(boost::bind(&ZoomUI::showNavigation, m_zoomUI.get()));
271 m_tabUI->newTabClicked.connect(boost::bind(&SimpleUI::newTabClicked, this));
272 m_tabUI->newTabClicked.connect(boost::bind(&SimpleUI::settingsPrivateModeSwitch, this, false));
273 m_tabUI->tabClicked.connect(boost::bind(&SimpleUI::tabClicked, this,_1));
274 m_tabUI->closeTabsClicked.connect(boost::bind(&SimpleUI::closeTabsClicked, this,_1));
275 m_tabUI->newIncognitoTabClicked.connect(boost::bind(&SimpleUI::settingsPrivateModeSwitch, this, true));
276 m_tabUI->newIncognitoTabClicked.connect(boost::bind(&SimpleUI::switchViewToIncognitoPage, this));
277 m_tabUI->tabsCount.connect(boost::bind(&SimpleUI::tabsCount, this));
279 M_ASSERT(m_historyUI.get());
280 m_historyUI->clearHistoryClicked.connect(boost::bind(&SimpleUI::onClearHistoryClicked, this));
281 m_historyUI->closeHistoryUIClicked.connect(boost::bind(&SimpleUI::closeHistoryUI, this));
282 m_historyUI->closeHistoryUIClicked.connect(boost::bind(&ZoomUI::showNavigation, m_zoomUI.get()));
283 // desktop mode as default
284 m_historyUI->historyItemClicked.connect(boost::bind(&SimpleUI::onOpenURLInNewTab, this, _1, true));
286 M_ASSERT(m_settingsUI.get());
287 m_settingsUI->closeSettingsUIClicked.connect(boost::bind(&SimpleUI::closeSettingsUI, this));
288 m_settingsUI->deleteSelectedDataClicked.connect(boost::bind(&SimpleUI::settingsDeleteSelectedData, this,_1));
289 m_settingsUI->resetMostVisitedClicked.connect(boost::bind(&SimpleUI::settingsResetMostVisited, this));
290 m_settingsUI->resetBrowserClicked.connect(boost::bind(&SimpleUI::settingsResetBrowser, this));
292 M_ASSERT(m_moreMenuUI.get());
293 m_moreMenuUI->bookmarkManagerClicked.connect(boost::bind(&SimpleUI::showBookmarkManagerUI, this));
294 m_moreMenuUI->historyUIClicked.connect(boost::bind(&SimpleUI::showHistoryUI, this));
295 m_moreMenuUI->settingsClicked.connect(boost::bind(&SimpleUI::showSettingsUI, this));
296 m_moreMenuUI->closeMoreMenuClicked.connect(boost::bind(&SimpleUI::closeMoreMenu, this));
297 m_moreMenuUI->closeMoreMenuClicked.connect(boost::bind(&ZoomUI::showNavigation, m_zoomUI.get()));
298 m_moreMenuUI->switchToMobileMode.connect(boost::bind(&SimpleUI::switchToMobileMode, this));
299 m_moreMenuUI->switchToDesktopMode.connect(boost::bind(&SimpleUI::switchToDesktopMode, this));
300 m_moreMenuUI->addToBookmarkClicked.connect(boost::bind(&SimpleUI::addToBookmarks, this, _1));
301 m_moreMenuUI->isBookmark.connect(boost::bind(&SimpleUI::checkBookmark, this));
302 m_moreMenuUI->deleteBookmark.connect(boost::bind(&SimpleUI::deleteBookmark, this));
303 m_moreMenuUI->zoomUIClicked.connect(boost::bind(&SimpleUI::showZoomUI, this));
305 M_ASSERT(m_bookmarkManagerUI.get());
306 m_bookmarkManagerUI->closeBookmarkManagerClicked.connect(boost::bind(&SimpleUI::closeBookmarkManagerUI, this));
307 m_bookmarkManagerUI->closeBookmarkManagerClicked.connect(boost::bind(&ZoomUI::showNavigation, m_zoomUI.get()));
308 m_bookmarkManagerUI->bookmarkItemClicked.connect(boost::bind(&SimpleUI::onBookmarkClicked, this, _1));
310 M_ASSERT(m_zoomUI.get());
311 m_zoomUI->setZoom.connect(boost::bind(&SimpleUI::setZoomFactor, this, _1));
312 m_zoomUI->getZoom.connect(boost::bind(&SimpleUI::getZoomFactor, this));
313 m_zoomUI->scrollView.connect(boost::bind(&SimpleUI::scrollView, this, _1, _2));
316 void SimpleUI::loadModelServices()
318 BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
321 std::dynamic_pointer_cast
322 <basic_webengine::AbstractWebEngine<Evas_Object>,tizen_browser::core::AbstractService>
323 (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.webkitengineservice"));
326 std::dynamic_pointer_cast
327 <tizen_browser::interfaces::AbstractFavoriteService,tizen_browser::core::AbstractService>
328 (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.favoriteservice"));
331 std::dynamic_pointer_cast
332 <tizen_browser::services::HistoryService,tizen_browser::core::AbstractService>
333 (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.historyservice"));
335 m_platformInputManager =
336 std::dynamic_pointer_cast
337 <tizen_browser::services::PlatformInputManager,tizen_browser::core::AbstractService>
338 (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.platforminputmanager"));
341 std::dynamic_pointer_cast
342 <tizen_browser::services::SessionStorage,tizen_browser::core::AbstractService>
343 (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.sessionStorageService"));
346 void SimpleUI::initUIServices()
348 BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
349 M_ASSERT (m_viewManager);
351 M_ASSERT(m_webPageUI.get());
352 m_webPageUI->init(m_viewManager->getContent());
354 M_ASSERT(m_quickAccess.get());
355 m_quickAccess->init(m_webPageUI->getContent());
357 M_ASSERT(m_tabUI.get());
358 m_tabUI->init(m_viewManager->getContent());
360 M_ASSERT(m_historyUI.get());
361 m_historyUI->init(m_viewManager->getContent());
363 M_ASSERT(m_moreMenuUI.get());
364 m_moreMenuUI->init(m_viewManager->getContent());
366 M_ASSERT(m_settingsUI.get());
367 m_settingsUI->init(m_viewManager->getContent());
369 M_ASSERT(m_bookmarkManagerUI.get());
370 m_bookmarkManagerUI->init(m_viewManager->getContent());
372 M_ASSERT(m_zoomUI.get());
373 m_zoomUI->init(m_viewManager->getContent());
376 void SimpleUI::initModelServices()
378 BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
380 M_ASSERT(m_webEngine);
381 M_ASSERT(m_webPageUI->getContent());
382 m_webEngine->init(m_webPageUI->getContent());
384 M_ASSERT(m_favoriteService);
385 m_favoriteService->synchronizeBookmarks();
386 m_favoriteService->getBookmarks();
388 M_ASSERT(m_platformInputManager);
389 m_platformInputManager->init(m_window.get());
392 void SimpleUI::connectModelSignals()
394 BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
396 m_webEngine->uriChanged.connect(boost::bind(&SimpleUI::webEngineURLChanged, this, _1));
397 m_webEngine->uriChanged.connect(boost::bind(&URIEntry::changeUri, &m_webPageUI->getURIEntry(), _1));
398 m_webEngine->uriChanged.connect(boost::bind(&MoreMenuUI::setURL, m_moreMenuUI.get(), _1));
399 m_webEngine->webViewClicked.connect(boost::bind(&URIEntry::clearFocus, &m_webPageUI->getURIEntry()));
400 m_webEngine->backwardEnableChanged.connect(boost::bind(&WebPageUI::setBackButtonEnabled, m_webPageUI.get(), _1));
401 m_webEngine->forwardEnableChanged.connect(boost::bind(&WebPageUI::setForwardButtonEnabled, m_webPageUI.get(), _1));
402 m_webEngine->loadStarted.connect(boost::bind(&SimpleUI::loadStarted, this));
403 m_webEngine->loadProgress.connect(boost::bind(&SimpleUI::progressChanged,this,_1));
404 m_webEngine->loadFinished.connect(boost::bind(&SimpleUI::loadFinished, this));
405 m_webEngine->loadStop.connect(boost::bind(&SimpleUI::loadFinished, this));
406 m_webEngine->loadError.connect(boost::bind(&SimpleUI::loadError, this));
407 m_webEngine->confirmationRequest.connect(boost::bind(&SimpleUI::handleConfirmationRequest, this, _1));
408 m_webEngine->tabCreated.connect(boost::bind(&SimpleUI::tabCreated, this));
409 m_webEngine->checkIfCreate.connect(boost::bind(&SimpleUI::checkIfCreate, this));
410 m_webEngine->tabClosed.connect(boost::bind(&SimpleUI::tabClosed,this,_1));
411 m_webEngine->IMEStateChanged.connect(boost::bind(&SimpleUI::setwvIMEStatus, this, _1));
412 m_webEngine->favIconChanged.connect(boost::bind(&MoreMenuUI::setFavIcon, m_moreMenuUI.get(), _1));
413 m_webEngine->titleChanged.connect(boost::bind(&MoreMenuUI::setWebTitle, m_moreMenuUI.get(), _1));
414 m_webEngine->titleChanged.connect(boost::bind(&WebPageUI::setPageTitle, m_webPageUI.get(), _1));
416 m_favoriteService->bookmarkAdded.connect(boost::bind(&SimpleUI::onBookmarkAdded, this,_1));
417 m_favoriteService->bookmarkDeleted.connect(boost::bind(&SimpleUI::onBookmarkRemoved, this, _1));
419 m_historyService->historyDeleted.connect(boost::bind(&SimpleUI::onHistoryRemoved, this,_1));
421 m_platformInputManager->returnPressed.connect(boost::bind(&elm_exit));
422 m_platformInputManager->backPressed.connect(boost::bind(&SimpleUI::onBackPressed, this));
423 m_platformInputManager->escapePressed.connect(boost::bind(&SimpleUI::onEscapePressed, this));
424 m_platformInputManager->mouseClicked.connect(
425 boost::bind(&SimpleUI::onMouseClick, this));
429 void SimpleUI::createActions()
431 BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
432 ///\todo Add MulitStateAction. and convert m_stopLoading and m_reload actons to it?
434 m_settingPrivateBrowsing = sharedAction(new Action("Private browsing"));
435 m_settingPrivateBrowsing->setToolTip("On exit from private mode all cookies, history, and stored data will be deleted");
436 m_settingPrivateBrowsing->setCheckable(true);
437 m_settingPrivateBrowsing->setChecked(m_webEngine->isPrivateMode());
438 m_settingPrivateBrowsing->setEnabled(true);
441 void SimpleUI::connectActions()
443 BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
444 m_settingPrivateBrowsing->toggled.connect(boost::bind(&SimpleUI::settingsPrivateModeSwitch, this, _1));
447 void SimpleUI::switchViewToWebPage()
449 BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
450 M_ASSERT(m_viewManager);
451 if(m_webEngine->isSuspended())
452 m_webEngine->resume();
453 m_webPageUI->switchViewToWebPage(m_webEngine->getLayout(), m_webEngine->getURI(), m_webEngine->getTitle());
456 void SimpleUI::switchToTab(const tizen_browser::basic_webengine::TabId& tabId)
458 BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
459 if(m_webEngine->currentTabId() != tabId) {
460 BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
461 m_webEngine->switchToTab(tabId);
463 if(m_webEngine->isLoadError()){
464 BROWSER_LOGD("[%s:%d] LOAD ERROR!", __PRETTY_FUNCTION__, __LINE__);
468 BROWSER_LOGD("[%s:%d] swiching to web_view ", __PRETTY_FUNCTION__, __LINE__);
469 switchViewToWebPage();
470 m_zoomUI->showNavigation();
473 bool SimpleUI::isErrorPageActive()
475 return m_webPageUI->isErrorPageActive();
478 void SimpleUI::showQuickAccess()
480 BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
481 m_quickAccess->showMostVisited(getMostVisitedItems());
482 m_quickAccess->showUI();
485 void SimpleUI::switchViewToQuickAccess()
487 BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
488 M_ASSERT(m_viewManager);
490 m_webPageUI->switchViewToQuickAccess(m_quickAccess->getContent());
491 m_webEngine->disconnectCurrentWebViewSignals();
492 m_viewManager->popStackTo(m_webPageUI.get());
495 void SimpleUI::switchViewToIncognitoPage()
497 BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
498 M_ASSERT(m_viewManager);
500 m_webPageUI->switchViewToIncognitoPage();
501 m_viewManager->popStackTo(m_webPageUI.get());
504 void SimpleUI::openNewTab(const std::string &uri, bool desktopMode)
506 BROWSER_LOGD("[%s:%d] uri =%s", __PRETTY_FUNCTION__, __LINE__, uri.c_str());
507 tizen_browser::basic_webengine::TabId tab = m_webEngine->addTab(uri, nullptr, desktopMode);
508 applyPrivateModeToTab(tab);
512 void SimpleUI::closeTab()
514 BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
515 auto tabId = m_webEngine->currentTabId();
519 void SimpleUI::closeTab(const tizen_browser::basic_webengine::TabId& id)
521 BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
522 m_currentSession.removeItem(id.toString());
523 m_webEngine->closeTab(id);
527 bool SimpleUI::checkBookmark()
529 BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
530 if (m_webPageUI->isHomePageActive())
533 if(m_favoriteService->bookmarkExists(m_webEngine->getURI())) {
534 BROWSER_LOGD("[%s] There is bookmark for this site [%s], set indicator on!", __func__, m_webEngine->getURI().c_str());
538 BROWSER_LOGD("[%s] There is no bookmark for this site [%s], set indicator off", __func__, m_webEngine->getURI().c_str());
542 // Consider removing these functions
543 void SimpleUI::onBookmarkAdded(std::shared_ptr<tizen_browser::services::BookmarkItem>)
546 m_moreMenuUI->changeBookmarkStatus(true);
547 m_moreMenuUI->createToastPopup( (std::string(m_webEngine->getTitle()) + std::string(" added to bookmark")).c_str() );
551 void SimpleUI::onBookmarkRemoved(const std::string& uri)
553 BROWSER_LOGD("[%s] deleted %s", __func__, uri.c_str());
555 m_moreMenuUI->changeBookmarkStatus(false);
556 m_moreMenuUI->createToastPopup( (std::string(m_webEngine->getTitle()) + std::string(" removed from bookmark")).c_str() );
560 void SimpleUI::onOpenURLInNewTab(std::shared_ptr<tizen_browser::services::HistoryItem> historyItem, bool desktopMode)
562 BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__);
563 m_viewManager->popStackTo(m_webPageUI.get());
564 std::string historyAddress = historyItem->getUrl();
565 openNewTab(historyAddress, desktopMode);
568 void SimpleUI::onMostVisitedTileClicked(std::shared_ptr< services::HistoryItem > historyItem, int itemsNumber)
570 BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__);
571 m_quickAccess->openDetailPopup(historyItem, m_historyService->getHistoryItemsByURL(historyItem->getUrl(), itemsNumber));
574 void SimpleUI::onClearHistoryClicked()
576 BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__);
577 m_historyService->clearAllHistory();
580 void SimpleUI::onMostVisitedClicked()
582 BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__);
583 m_quickAccess->showMostVisited(getMostVisitedItems());
586 void SimpleUI::onBookmarkButtonClicked()
588 BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__);
589 m_quickAccess->showBookmarks(getBookmarks());
592 void SimpleUI::onBookmarkClicked(std::shared_ptr<tizen_browser::services::BookmarkItem> bookmarkItem)
594 BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
595 M_ASSERT(m_viewManager);
596 std::string bookmarkAddress = bookmarkItem->getAddress();
597 m_viewManager->popStackTo(m_webPageUI.get());
599 openNewTab(bookmarkAddress);
601 std::string bookmarkTitle = bookmarkItem->getTittle();
602 m_webPageUI->switchViewToWebPage(m_webEngine->getLayout(), bookmarkAddress, bookmarkTitle);
603 m_webEngine->setURI(bookmarkAddress);
604 m_webPageUI->setPageTitle(bookmarkTitle);
605 m_webPageUI->getURIEntry().clearFocus();
606 closeBookmarkManagerUI();
610 void SimpleUI::onHistoryRemoved(const std::string& uri)
612 BROWSER_LOGD("[%s] deleted %s", __func__, uri.c_str());
615 void SimpleUI::onReturnPressed(MenuButton *m)
617 BROWSER_LOGD("[%s]", __func__);
618 m_platformInputManager->returnPressed.disconnect_all_slots();
619 m_platformInputManager->returnPressed.connect(boost::bind(&elm_exit));
623 void SimpleUI::setwvIMEStatus(bool status)
625 BROWSER_LOGD("[%s]", __func__);
626 m_wvIMEStatus = status;
629 void SimpleUI::onBackPressed()
631 BROWSER_LOGD("[%s]", __func__);
632 if (m_zoomUI->isVisible()) {
633 m_zoomUI->escapeZoom();
634 } else if (m_webPageUI->isHomePageActive()) {
635 m_quickAccess->backButtonClicked();
637 if (!m_webPageUI->getURIEntry().hasFocus() && !m_wvIMEStatus)
638 m_webEngine->backButtonClicked();
642 void SimpleUI::onEscapePressed()
644 BROWSER_LOGD("[%s]", __func__);
645 m_zoomUI->escapeZoom();
648 void SimpleUI::reloadEnable(bool enable)
650 m_webPageUI->setReloadButtonEnabled(enable);
653 void SimpleUI::stopEnable(bool enable)
655 m_webPageUI->setStopButtonEnabled(enable);
658 void SimpleUI::loadStarted()
660 BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
661 if(!m_webEngine->isPrivateMode()){
662 m_currentSession.updateItem(m_webEngine->currentTabId().toString(), m_webEngine->getURI());
664 m_webPageUI->loadStarted();
667 void SimpleUI::progressChanged(double progress)
669 m_webPageUI->progressChanged(progress);
672 void SimpleUI::loadFinished()
674 BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
676 if(!m_webEngine->isPrivateMode()){
677 m_historyService->addHistoryItem(std::make_shared<tizen_browser::services::HistoryItem> (m_webEngine->getURI(),
678 m_webEngine->getTitle(),
679 m_webEngine->getFavicon()), m_webEngine->getSnapshotData(QuickAccess::MAX_THUMBNAIL_WIDTH, QuickAccess::MAX_THUMBNAIL_HEIGHT));
681 m_webPageUI->loadFinished();
684 void SimpleUI::loadError()
686 BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
687 m_webPageUI->switchViewToErrorPage();
690 void SimpleUI::filterURL(const std::string& url)
692 BROWSER_LOGD("[%s:%d] url=%s", __PRETTY_FUNCTION__, __LINE__, url.c_str());
693 //check for special urls (like: 'about:home')
694 //if there will be more addresses may be we should
695 //create some kind of std::man<std::string url, bool *(doSomethingWithUrl)()>
696 //and then just map[url]() ? m_webEngine->setURI(url) : /*do nothing*/;;
697 if(/*url.empty() ||*/ url == HomePageURL){
698 m_webPageUI->getURIEntry().changeUri("");
699 } else if (!url.empty()){
701 //check if url is in favorites
703 //check if url is in blocked
707 if (m_webPageUI->isHomePageActive())
710 m_webEngine->setURI(url);
713 switchViewToWebPage();
715 m_webPageUI->getURIEntry().clearFocus();
718 void SimpleUI::onURLEntryEditedByUser(const std::shared_ptr<std::string> editedUrlPtr)
720 string editedUrl(*editedUrlPtr);
721 int historyItemsVisibleMax =
722 m_quickAccess->getUrlHistoryList()->getVisibleItemsMax();
723 int minKeywordLength =
724 m_quickAccess->getUrlHistoryList()->getMinKeywordLength();
725 std::shared_ptr<services::HistoryItemVector> result =
726 m_historyService->getHistoryItemsByKeywordsString(editedUrl,
727 historyItemsVisibleMax, minKeywordLength);
728 m_quickAccess->getUrlHistoryList()->onURLEntryEditedByUser(editedUrl, result);
731 void SimpleUI::onURLEntryEdited()
733 m_quickAccess->getUrlHistoryList()->onURLEntryEdited();
736 void SimpleUI::onMouseClick()
738 m_quickAccess->getUrlHistoryList()->onMouseClick();
741 void SimpleUI::webEngineURLChanged(const std::string url)
743 BROWSER_LOGD("webEngineURLChanged:%s", url.c_str());
744 m_webPageUI->getURIEntry().clearFocus();
747 void SimpleUI::showZoomUI()
749 BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
750 if(! m_webPageUI->isHomePageActive()) {
751 M_ASSERT(m_viewManager);
752 m_viewManager->popStackTo(m_webPageUI.get());
753 m_webPageUI->showTabUI.connect(boost::bind(&SimpleUI::closeZoomUI, this));
754 m_webPageUI->showMoreMenu.connect(boost::bind(&SimpleUI::closeZoomUI, this));
755 m_zoomUI->show(m_window.get());
759 void SimpleUI::closeZoomUI()
761 BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
766 void SimpleUI::setZoomFactor(int level)
768 BROWSER_LOGD("[%s:%d]", __PRETTY_FUNCTION__, __LINE__);
769 m_webEngine->setZoomFactor(level);
772 int SimpleUI::getZoomFactor()
774 BROWSER_LOGD("[%s:%d] %d", __PRETTY_FUNCTION__, __LINE__, m_webEngine->getZoomFactor());
775 return m_webEngine->getZoomFactor();
778 void SimpleUI::scrollView(const int& dx, const int& dy)
780 m_webEngine->scrollView(dx, dy);
783 void SimpleUI::showTabUI()
785 BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
786 M_ASSERT(m_viewManager);
787 m_viewManager->pushViewToStack(m_tabUI.get());
788 m_tabUI->addTabItems(m_webEngine->getTabContents());
791 void SimpleUI::closeTabUI()
793 BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
794 M_ASSERT(m_viewManager);
795 if (m_viewManager->topOfStack() == m_tabUI.get())
796 m_viewManager->popTheStack();
799 void SimpleUI::newTabClicked()
801 if (!checkIfCreate())
804 BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
805 switchViewToQuickAccess();
808 void SimpleUI::tabClicked(const tizen_browser::basic_webengine::TabId& tabId)
810 BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
811 m_viewManager->popStackTo(m_webPageUI.get());
812 applyPrivateModeToTab(tabId);
816 void SimpleUI::closeTabsClicked(const tizen_browser::basic_webengine::TabId& tabId)
818 BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
819 m_webEngine->closeTab(tabId);
822 int SimpleUI::tabsCount()
824 return m_webEngine->tabsCount();
827 void SimpleUI::handleConfirmationRequest(basic_webengine::WebConfirmationPtr webConfirmation)
829 BROWSER_LOGD("%s", __func__);
830 switch(webConfirmation->getConfirmationType())
832 case basic_webengine::WebConfirmation::ConfirmationType::Authentication:
834 basic_webengine::AuthenticationConfirmationPtr auth = std::dynamic_pointer_cast<basic_webengine::AuthenticationConfirmation, basic_webengine::WebConfirmation>(webConfirmation);
836 Evas_Object *popup_content = elm_layout_add(m_webPageUI->getContent());
837 std::string edjFilePath = EDJE_DIR;
838 edjFilePath.append("SimpleUI/AuthenticationPopup.edj");
839 Eina_Bool layoutSetResult = elm_layout_file_set(popup_content, edjFilePath.c_str(), "authentication_popup");
840 if (!layoutSetResult)
841 throw std::runtime_error("Layout file not found: " + edjFilePath);
844 elm_object_translatable_part_text_set(popup_content, "login_label", "Login");
845 elm_object_translatable_part_text_set(popup_content, "password_label", "Password");
847 elm_object_part_text_set(popup_content, "login_label", "Login");
848 elm_object_part_text_set(popup_content, "password_label", "Password");
851 Evas_Object *loginEntry = elm_entry_add(popup_content);
852 elm_object_part_content_set(popup_content, "login", loginEntry);
854 Evas_Object *passwordEntry = elm_entry_add(popup_content);
855 elm_object_part_content_set(popup_content, "password", passwordEntry);
857 SimplePopup *popup = SimplePopup::createPopup();
858 popup->setTitle("Authentication request");
859 popup->addButton(OK);
860 popup->addButton(CANCEL);
861 popup->setContent(popup_content);
862 std::shared_ptr<AuthenticationPopupData> popupData = std::make_shared<AuthenticationPopupData>();
863 popupData->loginEntry = loginEntry;
864 popupData->passwordEntry = passwordEntry;
865 popupData->auth = auth;
866 popup->setData(popupData);
867 popup->buttonClicked.connect(boost::bind(&SimpleUI::authPopupButtonClicked, this, _1, _2));
871 case basic_webengine::WebConfirmation::ConfirmationType::CertificateConfirmation:
872 case basic_webengine::WebConfirmation::ConfirmationType::Geolocation:
873 case basic_webengine::WebConfirmation::ConfirmationType::UserMedia:
874 case basic_webengine::WebConfirmation::ConfirmationType::Notification:
876 // Implicitly accepted
877 BROWSER_LOGE("NOT IMPLEMENTED: popups to confirm Ceritificate, Geolocation, UserMedia, Notification");
878 webConfirmation->setResult(tizen_browser::basic_webengine::WebConfirmation::ConfirmationResult::Confirmed);
879 m_webEngine->confirmationResult(webConfirmation);
888 void SimpleUI::authPopupButtonClicked(PopupButtons button, std::shared_ptr<PopupData> popupData)
890 std::shared_ptr<AuthenticationPopupData> authPopupData = std::dynamic_pointer_cast<AuthenticationPopupData, PopupData>(popupData);
893 authPopupData->auth->setLogin(elm_entry_entry_get(authPopupData->loginEntry) ? elm_entry_entry_get(authPopupData->loginEntry) : "");
894 authPopupData->auth->setPassword(elm_entry_entry_get(authPopupData->passwordEntry) ? elm_entry_entry_get(authPopupData->passwordEntry) : "");
895 authPopupData->auth->setResult(basic_webengine::WebConfirmation::ConfirmationResult::Confirmed);
896 m_webEngine->confirmationResult(authPopupData->auth);
899 authPopupData->auth->setResult(basic_webengine::WebConfirmation::ConfirmationResult::Rejected);
900 m_webEngine->confirmationResult(authPopupData->auth);
912 void SimpleUI::showHistoryUI()
914 BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
915 M_ASSERT(m_viewManager);
916 m_viewManager->pushViewToStack(m_historyUI.get());
917 m_historyUI->addHistoryItems(getHistory());
920 void SimpleUI::closeHistoryUI()
922 BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
923 M_ASSERT(m_viewManager);
924 if (m_viewManager->topOfStack() == m_historyUI.get())
925 m_viewManager->popTheStack();
928 void SimpleUI::showSettingsUI()
930 BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
931 M_ASSERT(m_viewManager);
932 m_viewManager->pushViewToStack(m_settingsUI.get());
935 void SimpleUI::closeSettingsUI()
937 BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
938 M_ASSERT(m_viewManager);
939 if (m_viewManager->topOfStack() == m_settingsUI.get())
940 m_viewManager->popTheStack();
943 void SimpleUI::showMoreMenu()
945 BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
946 M_ASSERT(m_viewManager);
948 bool desktopMode = m_webPageUI->isHomePageActive() ? m_quickAccess->isDesktopMode() : m_webEngine->isDesktopMode();
949 m_moreMenuUI->setDesktopMode(desktopMode);
950 m_viewManager->pushViewToStack(m_moreMenuUI.get());
951 m_moreMenuUI->showCurrentTab();
953 if(!m_webPageUI->isHomePageActive()) {
954 m_moreMenuUI->setFavIcon(m_webEngine->getFavicon());
955 m_moreMenuUI->setWebTitle(m_webEngine->getTitle());
956 m_moreMenuUI->setURL(m_webEngine->getURI());
959 m_moreMenuUI->setHomePageInfo();
963 void SimpleUI::closeMoreMenu()
965 BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
966 M_ASSERT(m_viewManager);
967 if (m_viewManager->topOfStack() == m_moreMenuUI.get())
968 m_viewManager->popTheStack();
970 BROWSER_LOGD("[%s:%d] WARNING!!! closeMoreMenu is not topOfStack", __PRETTY_FUNCTION__, __LINE__);
973 void SimpleUI::switchToMobileMode()
975 BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
976 if (!m_webPageUI->isHomePageActive()) {
977 m_webEngine->switchToMobileMode();
978 m_viewManager->popStackTo(m_webPageUI.get());
979 m_webEngine->reload();
981 m_quickAccess->setDesktopMode(false);
985 void SimpleUI::switchToDesktopMode()
987 BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
988 if (!m_webPageUI->isHomePageActive()) {
989 m_webEngine->switchToDesktopMode();
990 m_webEngine->reload();
992 m_quickAccess->setDesktopMode(true);
996 void SimpleUI::showBookmarkManagerUI()
998 BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
999 M_ASSERT(m_viewManager);
1000 m_viewManager->pushViewToStack(m_bookmarkManagerUI.get());
1001 m_bookmarkManagerUI->addBookmarkItems(getBookmarks(ROOT_FOLDER));
1004 void SimpleUI::closeBookmarkManagerUI()
1006 BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
1007 M_ASSERT(m_viewManager);
1008 if (m_viewManager->topOfStack() == m_bookmarkManagerUI.get())
1009 m_viewManager->popTheStack();
1012 void SimpleUI::settingsPrivateModeSwitch(bool newState)
1014 BROWSER_LOGD("%s: Setting Private mode to: %s", __func__, (newState ? "true" : "false"));
1015 m_incognito = newState;
1018 void SimpleUI::applyPrivateModeToTab(const tizen_browser::basic_webengine::TabId& tabId)
1020 if (m_webEngine->isPrivateMode(tabId) < 0) {
1021 m_webEngine->setPrivateMode(tabId, m_incognito);
1022 m_webPageUI->toIncognito(m_incognito);
1024 m_webEngine->setPrivateMode(tabId, m_webEngine->isPrivateMode(tabId));
1025 m_webPageUI->toIncognito(m_webEngine->isPrivateMode(tabId));
1029 void SimpleUI::settingsDeleteSelectedData(const std::string& str)
1031 BROWSER_LOGD("[%s]: Deleting selected data", __func__);
1032 M_ASSERT(m_viewManager);
1033 NotificationPopup *popup = NotificationPopup::createNotificationPopup(m_viewManager->getContent());
1034 popup->show("Delete Web Browsing Data");
1035 onDeleteSelectedDataButton(str);
1039 void SimpleUI::onDeleteSelectedDataButton(const std::string& dataText)
1041 BROWSER_LOGD("[%s]: TYPE : %s", __func__, dataText.c_str());
1042 if (dataText.find("CACHE") != std::string::npos)
1043 m_webEngine->clearPrivateData();
1044 if (dataText.find("COOKIES") != std::string::npos)
1045 m_webEngine->clearPrivateData();
1046 if (dataText.find("HISTORY") != std::string::npos)
1047 m_historyService->clearAllHistory();
1050 void SimpleUI::settingsResetMostVisited()
1052 BROWSER_LOGD("[%s]: Deleting most visited sites", __func__);
1053 M_ASSERT(m_viewManager);
1054 NotificationPopup *popup = NotificationPopup::createNotificationPopup(m_viewManager->getContent());
1055 popup->show("Reset Most Visited Sites");
1056 onDeleteMostVisitedButton(nullptr);
1060 void SimpleUI::onDeleteMostVisitedButton(std::shared_ptr< PopupData > /*popupData*/)
1062 BROWSER_LOGD("[%s]: Deleting most visited", __func__);
1063 m_historyService->cleanMostVisitedHistoryItems();
1066 void SimpleUI::settingsResetBrowser()
1068 BROWSER_LOGD("[%s]: Resetting browser", __func__);
1069 SimplePopup *popup = SimplePopup::createPopup();
1070 popup->setTitle("Reset browser");
1071 popup->addButton(OK);
1072 popup->addButton(CANCEL);
1073 popup->setMessage("Are you sure you want to reset browser?");
1074 popup->buttonClicked.connect(boost::bind(&SimpleUI::onResetBrowserButton, this, _1, _2));
1078 void SimpleUI::onResetBrowserButton(PopupButtons button, std::shared_ptr< PopupData > /*popupData*/)
1081 BROWSER_LOGD("[%s]: OK", __func__);
1082 BROWSER_LOGD("[%s]: Resetting browser", __func__);
1083 M_ASSERT(m_viewManager);
1085 NotificationPopup *popup = NotificationPopup::createNotificationPopup(m_viewManager->getContent());
1086 popup->show("Reset Browser");
1088 m_webEngine->clearPrivateData();
1089 m_historyService->clearAllHistory();
1090 m_favoriteService->deleteAllBookmarks();
1092 // Close all openend tabs
1093 std::vector<std::shared_ptr<tizen_browser::basic_webengine::TabContent>> openedTabs = m_webEngine->getTabContents();
1094 for (auto it = openedTabs.begin(); it < openedTabs.end(); ++it) {
1095 tizen_browser::basic_webengine::TabId id = it->get()->getId();
1096 m_currentSession.removeItem(id.toString());
1097 m_webEngine->closeTab(id);
1099 //TODO: add here any missing functionality that should be cleaned.
1105 void SimpleUI::tabLimitPopupButtonClicked(PopupButtons button, std::shared_ptr< PopupData > /*popupData*/)
1107 if (button == CLOSE_TAB) {
1108 BROWSER_LOGD("[%s]: CLOSE TAB", __func__);
1113 void SimpleUI::tabCreated()
1115 int tabs = m_webEngine->tabsCount();
1116 m_webPageUI->setTabsNumber(tabs);
1119 bool SimpleUI::checkIfCreate()
1121 int tabs = m_webEngine->tabsCount();
1123 if (tabs >= m_tabLimit) {
1124 SimplePopup *popup = SimplePopup::createPopup();
1125 popup->setTitle("Maximum tab count reached.");
1126 popup->addButton(OK);
1127 popup->setMessage("Close other tabs to open another new tab");
1128 popup->buttonClicked.connect(boost::bind(&SimpleUI::tabLimitPopupButtonClicked, this, _1, _2));
1136 void SimpleUI::updateView() {
1137 int tabs = m_webEngine->tabsCount();
1138 BROWSER_LOGD("[%s] Opened tabs: %d", __func__, tabs);
1140 switchViewToQuickAccess();
1141 } else if (!m_webPageUI->isHomePageActive()) {
1142 switchViewToWebPage();
1144 m_webPageUI->setTabsNumber(tabs);
1147 void SimpleUI::tabClosed(const tizen_browser::basic_webengine::TabId& id) {
1148 m_currentSession.removeItem(id.toString());
1152 void SimpleUI::searchWebPage(std::string &text, int flags)
1154 m_webEngine->searchOnWebsite(text, flags);
1157 void SimpleUI::addToBookmarks(int folder_id)
1159 BROWSER_LOGD("[%s,%d],", __func__, __LINE__);
1160 if (m_favoriteService)
1162 if (m_webEngine && !m_webEngine->getURI().empty())
1164 m_favoriteService->addToBookmarks(m_webEngine->getURI(), m_webEngine->getTitle(), std::string(),
1165 m_webEngine->getSnapshotData(373, 240),
1166 m_webEngine->getFavicon(),(unsigned int)folder_id);
1171 //TODO: Replace by direct call.
1172 void SimpleUI::deleteBookmark()
1174 if (m_favoriteService)
1175 m_favoriteService->deleteBookmark(m_webEngine->getURI());