From: Lim DoHyung Date: Wed, 26 Oct 2016 10:55:57 +0000 (+0900) Subject: Implement showing PWA popup when site is visited over 3 times. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a37a3ea5b8c01d86bd3dac00d228800e5eed4619;p=profile%2Fcommon%2Fapps%2Fweb%2Fbrowser.git Implement showing PWA popup when site is visited over 3 times. [Issue] N/A [Problem] For popup could show condition that connecting over 3 count. manifest have not site case, next patch I will update. [Solution] I have extract frequency value in history DB, and when value over 3 count, I could show popup. [Verify] When 3 count connect, popup show and normal create shortcut. Change-Id: I21ab0e32144207fe93c1a35d6dc2381d903c97a0 Signed-off-by: Lim DoHyung --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 5537c0d5..b9b21475 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -120,7 +120,7 @@ if(TIZEN_BUILD) if (${PROFILE} MATCHES "mobile") ADD_DEFINITIONS(-DPROFILE_MOBILE=1) - ADD_DEFINITIONS(-DPWA=1) + ADD_DEFINITIONS(-DPWA=0) ADD_DEFINITIONS(-DDUMMY_BUTTON=1) endif (${PROFILE} MATCHES "mobile") diff --git a/services/HistoryService/HistoryService.cpp b/services/HistoryService/HistoryService.cpp index f33113f1..19a34833 100755 --- a/services/HistoryService/HistoryService.cpp +++ b/services/HistoryService/HistoryService.cpp @@ -151,6 +151,18 @@ std::shared_ptr HistoryService::getHistoryOlder() return getHistoryItems(BP_HISTORY_DATE_OLDER); } +#if PWA +int HistoryService::getHistoryCnt(const int& id) +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + int freq, retVal = 0; + + if (!bp_history_adaptor_get_frequency(id, &freq)) + retVal = freq; + return retVal; +} +#endif + std::shared_ptr HistoryService::getMostVisitedHistoryItems() { std::shared_ptr ret_history_list(new HistoryItemVector); diff --git a/services/HistoryService/HistoryService.h b/services/HistoryService/HistoryService.h index 4fb491aa..59c711cc 100644 --- a/services/HistoryService/HistoryService.h +++ b/services/HistoryService/HistoryService.h @@ -65,6 +65,9 @@ public: void cleanMostVisitedHistoryItems(); std::shared_ptr getHistoryItemsByKeyword(const std::string & keyword, int maxItems); std::shared_ptr getHistoryItemsByURL(const std::string & url, int maxItems); +#if PWA + int getHistoryCnt(const int& id); +#endif /** * @brief Searches for history items matching given pattern. diff --git a/services/SimpleUI/SimpleUI.cpp b/services/SimpleUI/SimpleUI.cpp index 08e460a9..c8ffe31b 100755 --- a/services/SimpleUI/SimpleUI.cpp +++ b/services/SimpleUI/SimpleUI.cpp @@ -284,6 +284,23 @@ int SimpleUI::exec(const std::string& _url, const std::string& _caller, const st return 0; } +#if PWA +void SimpleUI::countCheckUrl() +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + int id, ret = 0; + id = m_historyService->getHistoryId(m_webEngine->getURI()); + + if (id) + ret = m_historyService->getHistoryCnt(id); + + if (ret == CONNECT_COUNT) + pwaPopupRequest(); + else + BROWSER_LOGD("[%s:%d] url count : %d", __PRETTY_FUNCTION__, __LINE__, ret); +} +#endif + void SimpleUI::faviconChanged(tools::BrowserImagePtr favicon) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); @@ -455,10 +472,10 @@ void SimpleUI::connectWebPageSignals() m_webPageUI->addToQuickAccess.connect(boost::bind(&SimpleUI::addQuickAccessItem, this, _1, _2)); m_webPageUI->getTitle.connect(boost::bind(&basic_webengine::AbstractWebEngine::getTitle, m_webEngine.get())); m_webPageUI->getEngineState.connect(boost::bind(&basic_webengine::AbstractWebEngine::getState, m_webEngine.get())); - // WPA m_webPageUI->requestCurrentPageForWebPageUI.connect(boost::bind(&SimpleUI::requestSettingsCurrentPage, this)); #if PWA m_webPageUI->pwaRequestManifest.connect(boost::bind(&basic_webengine::AbstractWebEngine::requestManifest, m_webEngine.get())); + m_webPageUI->getCountCheckSignal.connect(boost::bind(&SimpleUI::countCheckUrl, this)); #endif m_webPageUI->isMostVisited.connect(boost::bind(&QuickAccess::isMostVisitedActive, m_quickAccess.get())); } @@ -1576,6 +1593,38 @@ int SimpleUI::tabsCount() return m_webEngine->tabsCount(); } +#if PWA +void SimpleUI::pwaPopupRequest() +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + TextPopup* popup = TextPopup::createPopup(m_viewManager.getContent()); + popup->addButton(OK); + popup->addButton(CANCEL); + popup->buttonClicked.connect(boost::bind(&SimpleUI::pwaPopupButtonClicked, this, _1)); + popup->setTitle(m_webEngine->getTitle()); + popup->setMessage(_("IDS_BR_OPT_ADD_TO_HOME_SCREEN_ABB")); + popup->popupShown.connect(boost::bind(&SimpleUI::showPopup, this, _1)); + popup->popupDismissed.connect(boost::bind(&SimpleUI::dismissPopup, this, _1)); + popup->show(); +} + +void SimpleUI::pwaPopupButtonClicked(const PopupButtons& button) +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + switch (button) { + case OK: + BROWSER_LOGD("[%s:%d] pwaPopup create !", __PRETTY_FUNCTION__, __LINE__); + m_webEngine->requestManifest(); + break; + case CANCEL: + BROWSER_LOGD("[%s:%d] pwaPopup deny !", __PRETTY_FUNCTION__, __LINE__); + break; + default: + BROWSER_LOGW("[%s:%d] Unknown button type!", __PRETTY_FUNCTION__, __LINE__); + } +} +#endif + void SimpleUI::handleConfirmationRequest(basic_webengine::WebConfirmationPtr webConfirmation) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); diff --git a/services/SimpleUI/SimpleUI.h b/services/SimpleUI/SimpleUI.h index d98e8860..c05684f4 100644 --- a/services/SimpleUI/SimpleUI.h +++ b/services/SimpleUI/SimpleUI.h @@ -71,6 +71,8 @@ #include #include +#define CONNECT_COUNT 2 + namespace tizen_browser{ namespace base_ui{ @@ -105,6 +107,7 @@ private: void prepareServices(); #if PWA std::string preparePWA(const std::string& url); + void countCheckUrl(); #endif void loadUIServices(); void connectUISignals(); @@ -206,6 +209,10 @@ private: void onMenuButtonPressed(); void handleConfirmationRequest(basic_webengine::WebConfirmationPtr webConfirmation); void setwvIMEStatus(bool status); +#if PWA + void pwaPopupRequest(); + void pwaPopupButtonClicked(const PopupButtons& button); +#endif sharedAction m_showBookmarkManagerUI; diff --git a/services/WebPageUI/WebPageUI.cpp b/services/WebPageUI/WebPageUI.cpp index d8cc45a2..fdc44858 100755 --- a/services/WebPageUI/WebPageUI.cpp +++ b/services/WebPageUI/WebPageUI.cpp @@ -213,6 +213,10 @@ void WebPageUI::loadFinished() #if DUMMY_BUTTON elm_object_focus_set(m_dummy_button, EINA_TRUE); #endif + +#if PWA + getCountCheckSignal(); +#endif } void WebPageUI::setMainContent(Evas_Object* content) diff --git a/services/WebPageUI/WebPageUI.h b/services/WebPageUI/WebPageUI.h index 103850ea..cd8389db 100755 --- a/services/WebPageUI/WebPageUI.h +++ b/services/WebPageUI/WebPageUI.h @@ -172,6 +172,7 @@ public: boost::signals2::signal getEngineState; #if PWA boost::signals2::signal pwaRequestManifest; + boost::signals2::signal getCountCheckSignal; #endif private: