diff options
author | m.kawonczyk <m.kawonczyk@samsung.com> | 2017-01-11 16:08:02 +0100 |
---|---|---|
committer | Hye Kyoung Hwang <cookie@samsung.com> | 2017-01-19 17:10:39 -0800 |
commit | 2f380b90203213e918f1b901d43c2a067d865c01 (patch) | |
tree | 2600bb832f7e0bf90ca83882ea455c0a54e64af9 | |
parent | e2e3cc58aa0ad390f3dec5aeaea84405718a12a9 (diff) | |
download | browser-2f380b90203213e918f1b901d43c2a067d865c01.tar.gz browser-2f380b90203213e918f1b901d43c2a067d865c01.tar.bz2 browser-2f380b90203213e918f1b901d43c2a067d865c01.zip |
Revert with updates "Minimal browser for PWA"
Change-Id: I066ab87d42028a5d225a064bd5a3966863d7fc50
28 files changed, 567 insertions, 376 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 6941d2d..ea9f7fa 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -121,7 +121,6 @@ if(TIZEN_BUILD) if (${PROFILE} MATCHES "mobile") ADD_DEFINITIONS(-DPROFILE_MOBILE=1) - ADD_DEFINITIONS(-DPWA=0) endif (${PROFILE} MATCHES "mobile") if (${DUMMY_BUTTON} MATCHES "ON") diff --git a/core/AbstractInterfaces/AbstractFavoriteService.h b/core/AbstractInterfaces/AbstractFavoriteService.h deleted file mode 100755 index 79d2fbc..0000000 --- a/core/AbstractInterfaces/AbstractFavoriteService.h +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * - * Created on: Apr, 2014 - * Author: m.kielak - */ - -#ifndef ABSTRACTFAVORITESERVICE_H -#define ABSTRACTFAVORITESERVICE_H - -#include "browser_config.h" - -#include "AbstractService.h" -#include "service_macros.h" -#include "BookmarkItem.h" -#include "BrowserImage.h" -#include "StorageService.h" - -namespace tizen_browser{ -namespace interfaces{ - -class AbstractFavoriteService - : public tizen_browser::core::AbstractService -{ -public: - - /** - * @brief Add page to bookmarks - * - * @param address Webpage url. - * @param title Title of bookmark. - * @param note Bookmark note, default is empty . - * @param dirId Directory numeric ID, default is 0. - * @param thumbnail Page thumbnail, default is empty image. - * @param favicon Page favicon image, default is empty image. - * - * @return BookmarkItem class - */ - virtual std::shared_ptr<tizen_browser::services::BookmarkItem> addBookmark(const std::string & address, - const std::string & title, - const std::string & note = std::string(), - std::shared_ptr<tizen_browser::tools::BrowserImage> thumbnail=std::shared_ptr<tizen_browser::tools::BrowserImage>(), - std::shared_ptr<tizen_browser::tools::BrowserImage> favicon = std::shared_ptr<tizen_browser::tools::BrowserImage>(), - unsigned int dirId = 0) = 0; - - /** - * @brief Update bookmark snapshot by given url - * - * @param url of bookmark to delete - */ - virtual void updateBookmarkItemSnapshot(const std::string & url, - std::shared_ptr<tizen_browser::tools::BrowserImage> snapshot) = 0; - - /** \todo Need to change this callback function for finding stored bookmark, check getBookmarkId function - * @brief Check if bookmark exists - * - * @param url url to find - * @return true if exists, false if not - */ - virtual bool bookmarkExists(const std::string & url)= 0; - - /** - * @brief Get bookmarks in a folder from platform service and store it in private m_bookmarksList - * - * @return list of bookmark items in folder with id, folder_id - */ - virtual std::vector<std::shared_ptr<tizen_browser::services::BookmarkItem>> getBookmarks(int folder_id = -1) = 0; - - /** - * @brief Delete all bookmarks - * - * @return true if success, false on error - */ - virtual bool deleteAllBookmarks() = 0; - - /** - * @brief Edit bookmark title and folder by given url - * - * @return true if success, false on error - */ - virtual bool editBookmark(const std::string & url, const std::string & title, unsigned int folder_id = 0) = 0; - - /** - * @brief Delete bookmark by given url - * - * @param url of bookmark to delete - * @return true if success, false on error of not found bookmark - */ - virtual bool deleteBookmark(const std::string & url) = 0; - - virtual std::shared_ptr<tizen_browser::services::BookmarkItem> addFolder(const std::string & title, - int parent = tizen_browser::services::ROOT_FOLDER_ID) = 0; - - virtual std::vector<std::shared_ptr<tizen_browser::services::BookmarkItem>> getFolders( - int parent = tizen_browser::services::ROOT_FOLDER_ID) = 0; - virtual bool folderExists(const std::string & title, int parent = tizen_browser::services::ROOT_FOLDER_ID) = 0; - virtual std::vector<std::shared_ptr<tizen_browser::services::BookmarkItem>> getAllBookmarkItems( - int parent = tizen_browser::services::ROOT_FOLDER_ID) = 0; - virtual std::shared_ptr<tizen_browser::services::BookmarkItem> getRoot() = 0; - virtual std::shared_ptr<tizen_browser::services::BookmarkItem> getBookmarkItem(int id) = 0; - virtual void editBookmark(int id, const std::string & url, const std::string & title, int parent = -1, - int order = -1) = 0; - virtual bool deleteBookmark(int id) = 0; - /** - * @brief Gets bookmark item - * - * @param url of bookmark, pointer to item - * @return true if success, false on error of not found bookmark - */ - virtual bool getItem(const std::string & url, tizen_browser::services::BookmarkItem *item) = 0; - virtual int getFolderId(const std::string & title, int parent = tizen_browser::services::ROOT_FOLDER_ID) = 0; - - boost::signals2::signal<void (std::shared_ptr<tizen_browser::services::BookmarkItem>)> bookmarkAdded; - boost::signals2::signal<void (const std::string& uri)> bookmarkDeleted; - boost::signals2::signal<void ()> bookmarksDeleted; - -}; - -} -} - -#endif // FAVORITESERVICE_H diff --git a/core/AbstractInterfaces/AbstractUIComponent.h b/core/AbstractInterfaces/AbstractUIComponent.h index dfe961c..5aa49d6 100755 --- a/core/AbstractInterfaces/AbstractUIComponent.h +++ b/core/AbstractInterfaces/AbstractUIComponent.h @@ -17,6 +17,7 @@ #ifndef __ABSTRACT_UI_COMPONENT_H__ #define __ABSTRACT_UI_COMPONENT_H__ 1 +#include <Evas.h> #include <boost/signals2/signal.hpp> namespace tizen_browser diff --git a/core/AbstractWebEngine/AbstractWebEngine.h b/core/AbstractWebEngine/AbstractWebEngine.h index 6185e6a..af687a4 100755 --- a/core/AbstractWebEngine/AbstractWebEngine.h +++ b/core/AbstractWebEngine/AbstractWebEngine.h @@ -84,12 +84,10 @@ public: */ virtual void requestManifest(void) = 0; -#if PWA /** * Prepare data for PWA. */ virtual void setPWAData() = 0; -#endif /** * @return title of page opened in current tab. diff --git a/core/ServiceManager/ServiceManager.cpp b/core/ServiceManager/ServiceManager.cpp index 9f47bf5..b412533 100755 --- a/core/ServiceManager/ServiceManager.cpp +++ b/core/ServiceManager/ServiceManager.cpp @@ -26,53 +26,7 @@ namespace tizen_browser namespace core { -ServiceManagerPrivate::ServiceManagerPrivate() -{ - findServiceLibs(); - loadServiceLibs(); -} - -ServiceManagerPrivate::~ServiceManagerPrivate() -{} - -void ServiceManagerPrivate::findServiceLibs() try -{ - boost::filesystem::path servicesDir( - boost::any_cast<std::string>(tizen_browser::config::Config::getInstance().get("services/dir"))); - for (boost::filesystem::directory_iterator it(servicesDir); - it != boost::filesystem::directory_iterator(); - ++it) { - boost::filesystem::path item(*it); - if (boost::filesystem::is_regular_file(item)) { - if ((item.extension().string() == ".so" ) && - (item.filename().string().find("lib") != std::string::npos)) { - try { - servicesLoaderMap[item.string()] = std::make_shared<ServiceLoader>(item.string()); - } catch (std::runtime_error & e) { - BROWSER_LOGD(e.what() ); - } - } - } - } -} catch (const boost::filesystem::filesystem_error& ex) { - BROWSER_LOGD(ex.what()); -} - -void ServiceManagerPrivate::loadServiceLibs() -{ - /// TODO make sure that librareis are founded. - for (auto slm : servicesLoaderMap) { - try { - auto factory = slm.second->getFactory(); - servicesMap[factory->serviceName()] = factory;//do not write to map if there's an error. - } catch (const std::runtime_error& e) { - BROWSER_LOGD(e.what() ); - } - } -} - ServiceManager::ServiceManager() - :d(new ServiceManagerPrivate) {} ServiceManager& ServiceManager::getInstance(void) @@ -81,17 +35,21 @@ ServiceManager& ServiceManager::getInstance(void) return instance; } -std::shared_ptr< AbstractService > ServiceManager::getService(const std::string& service) +std::shared_ptr< AbstractService > ServiceManager::getService(const std::string& service, const std::string& fileName) { static std::unordered_map<std::string, std::shared_ptr<AbstractService>> cache; static std::mutex mut; - std::lock_guard<std::mutex> hold(mut); auto sp = cache[service]; - if (!sp) - cache[service] = sp = std::shared_ptr<AbstractService>(d->servicesMap[service]->create()); + if (!sp) { + boost::filesystem::path servicePath( + boost::any_cast<std::string>(config::Config::getInstance().get("services/dir"))); + servicePath /= fileName; + auto factory = std::make_unique<ServiceLoader>(servicePath.string())->getFactory(); + cache[service] = sp = std::shared_ptr<AbstractService>(factory->create()); + } return sp; } diff --git a/core/ServiceManager/ServiceManager.h b/core/ServiceManager/ServiceManager.h index b9e6106..fbb2081 100755 --- a/core/ServiceManager/ServiceManager.h +++ b/core/ServiceManager/ServiceManager.h @@ -82,9 +82,6 @@ namespace tizen_browser namespace core { - -class ServiceManagerPrivate; - /** * \brief Managing services. * @@ -114,7 +111,7 @@ public: * @param args Currently no used, may by omitted. * @return std::shared_ptr< tizen_browser::core::AbstractService > */ - std::shared_ptr<AbstractService> getService(const std::string& service); + std::shared_ptr<AbstractService> getService(const std::string& service, const std::string& fileName); private: /** @@ -122,8 +119,6 @@ private: * cretate this object by calling ServiceManager::getInstance!!! */ ServiceManager(); - - std::unique_ptr<ServiceManagerPrivate> d; }; } /* end of namespace core */ diff --git a/core/main.cpp b/core/main.cpp index 34e2ad4..041fc80 100755 --- a/core/main.cpp +++ b/core/main.cpp @@ -96,7 +96,7 @@ static bool app_create(void* app_data) tizen_browser::base_ui::AbstractMainWindow<Evas_Object>, tizen_browser::core::AbstractService > - (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.simpleui")); + (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.simpleui", "libSimpleUI.so")); elm_app_base_scale_set(boost::any_cast<double>(tizen_browser::config::Config::getInstance().get("scale"))); return true; } diff --git a/services/BookmarkService/BookmarkService.h b/services/BookmarkService/BookmarkService.h index 9e61e6c..12c6383 100755 --- a/services/BookmarkService/BookmarkService.h +++ b/services/BookmarkService/BookmarkService.h @@ -32,13 +32,13 @@ #include "service_macros.h" #include "BookmarkItem.h" #include "BrowserImage.h" -#include "AbstractFavoriteService.h" +#include "StorageService.h" namespace tizen_browser{ namespace services{ class BROWSER_EXPORT BookmarkService - : public tizen_browser::interfaces::AbstractFavoriteService + : public core::AbstractService { public: BookmarkService(); @@ -140,6 +140,10 @@ public: int get_count(void); int getFolderId(const std::string & title, int parent); + boost::signals2::signal<void (std::shared_ptr<services::BookmarkItem>)> bookmarkAdded; + boost::signals2::signal<void (const std::string& uri)> bookmarkDeleted; + boost::signals2::signal<void ()> bookmarksDeleted; + private: /** * Help method printing last bp_bookmark_error_defs error. diff --git a/services/CMakeLists.txt b/services/CMakeLists.txt index 03b6cd6..76f789d 100755 --- a/services/CMakeLists.txt +++ b/services/CMakeLists.txt @@ -1,12 +1,14 @@ project(services) add_subdirectory(WebEngineService) +add_subdirectory(WebEngineMin) add_subdirectory(QuickAccess) add_subdirectory(HistoryUI) add_subdirectory(TabUI) add_subdirectory(SimpleUI) add_subdirectory(SettingsUI) add_subdirectory(WebPageUI) +add_subdirectory(WebPageMin) add_subdirectory(BookmarkFlowUI) add_subdirectory(BookmarkManagerUI) add_subdirectory(StorageService) diff --git a/services/HistoryService/HistoryService.cpp b/services/HistoryService/HistoryService.cpp index 5dbd3fb..8bca3c4 100755 --- a/services/HistoryService/HistoryService.cpp +++ b/services/HistoryService/HistoryService.cpp @@ -121,7 +121,6 @@ std::shared_ptr<HistoryItemVector> HistoryService::getHistoryOlder() return getHistoryItems(BP_HISTORY_DATE_OLDER); } -#if PWA int HistoryService::getHistoryCnt(const int& id) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); @@ -131,7 +130,6 @@ int HistoryService::getHistoryCnt(const int& id) retVal = freq; return retVal; } -#endif std::shared_ptr<HistoryItemVector> HistoryService::getMostVisitedHistoryItems() { diff --git a/services/HistoryService/HistoryService.h b/services/HistoryService/HistoryService.h index 0831d2a..5251970 100755 --- a/services/HistoryService/HistoryService.h +++ b/services/HistoryService/HistoryService.h @@ -70,9 +70,7 @@ public: std::shared_ptr<HistoryItemVector> getHistoryOlder(); std::shared_ptr<HistoryItemVector> getMostVisitedHistoryItems(); std::shared_ptr<HistoryItemVector> getHistoryItemsByKeyword(const std::string & keyword, int maxItems); -#if PWA int getHistoryCnt(const int& id); -#endif /** * @brief Searches for history items matching given pattern. diff --git a/services/SimpleUI/CMakeLists.txt b/services/SimpleUI/CMakeLists.txt index 3d1a9ad..2375ffa 100755 --- a/services/SimpleUI/CMakeLists.txt +++ b/services/SimpleUI/CMakeLists.txt @@ -19,12 +19,13 @@ include_directories(${CMAKE_BINARY_DIR}) include_directories(${CMAKE_SOURCE_DIR}) include_directories(${CMAKE_SOURCE_DIR}/services) include_directories(${CMAKE_SOURCE_DIR}/services/WebPageUI) +include_directories(${CMAKE_SOURCE_DIR}/services/WebPageMin) include_directories(${CMAKE_SOURCE_DIR}/services/WebEngineService) -include_directories(${CMAKE_SOURCE_DIR}/services/WebEngineService/src) +include_directories(${CMAKE_SOURCE_DIR}/services/WebEngineMin) include_directories(${CMAKE_SOURCE_DIR}/services/StorageService) include_directories(${CMAKE_SOURCE_DIR}/services/BookmarkFlowUI) include_directories(${CMAKE_SOURCE_DIR}/services/BookmarkManagerUI) -include_directories(${CMAKE_SOURCE_DIR}/services/FavoriteService) +include_directories(${CMAKE_SOURCE_DIR}/services/BookmarkService) include_directories(${CMAKE_SOURCE_DIR}/services/HistoryService) include_directories(${CMAKE_SOURCE_DIR}/services/TabService) include_directories(${CMAKE_SOURCE_DIR}/services/HistoryUI) @@ -42,11 +43,14 @@ pkg_check_modules(capi_net QUIET capi-network-connection) add_library(${PROJECT_NAME} SHARED ${SimpleUI_SRCS}) add_dependencies(${PROJECT_NAME} WebPageUI) +add_dependencies(${PROJECT_NAME} WebPageMin) +add_dependencies(${PROJECT_NAME} WebEngineMin) add_dependencies(${PROJECT_NAME} StorageService) add_dependencies(${PROJECT_NAME} HistoryService) add_dependencies(${PROJECT_NAME} TabService) add_dependencies(${PROJECT_NAME} BookmarkFlowUI) add_dependencies(${PROJECT_NAME} BookmarkManagerUI) +add_dependencies(${PROJECT_NAME} BookmarkService) add_dependencies(${PROJECT_NAME} QuickAccess) add_dependencies(${PROJECT_NAME} HistoryUI) add_dependencies(${PROJECT_NAME} TabUI) @@ -56,6 +60,8 @@ add_dependencies(${PROJECT_NAME} CertificateService) add_dependencies(${PROJECT_NAME} FindOnPageUI) target_link_libraries(${PROJECT_NAME} WebPageUI) +target_link_libraries(${PROJECT_NAME} WebPageMin) +target_link_libraries(${PROJECT_NAME} WebEngineMin) target_link_libraries(${PROJECT_NAME} StorageService) target_link_libraries(${PROJECT_NAME} HistoryService) target_link_libraries(${PROJECT_NAME} TabService) @@ -65,6 +71,7 @@ target_link_libraries(${PROJECT_NAME} TabUI) target_link_libraries(${PROJECT_NAME} SettingsUI) target_link_libraries(${PROJECT_NAME} BookmarkFlowUI) target_link_libraries(${PROJECT_NAME} BookmarkManagerUI) +target_link_libraries(${PROJECT_NAME} BookmarkService) target_link_libraries(${PROJECT_NAME} PlatformInputManager) target_link_libraries(${PROJECT_NAME} CertificateService) target_link_libraries(${PROJECT_NAME} FindOnPageUI) diff --git a/services/SimpleUI/ProgressiveWebApp.cpp b/services/SimpleUI/ProgressiveWebApp.cpp index 1ab6403..9682b8e 100755 --- a/services/SimpleUI/ProgressiveWebApp.cpp +++ b/services/SimpleUI/ProgressiveWebApp.cpp @@ -22,7 +22,8 @@ namespace tizen_browser { namespace base_ui { ProgressiveWebApp::ProgressiveWebApp() - : m_pwaInfoStruct() + : m_active(false) + , m_pwaInfoStruct() , m_uriPartsMap() { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); @@ -89,5 +90,19 @@ void ProgressiveWebApp::fillPWAstruct(const std::map<std::string, std::string> & m_pwaInfoStruct.backgroundColor = std::stol(it->second); } -} // namespace tizen_browser +std::string ProgressiveWebApp::preparePWA(const std::string& url) +{ + std::string startUrl; + std::string prefix("browser_shortcut::"); + if (!url.compare(0, prefix.size(), prefix)) { + preparePWAParameters(url); + startUrl = m_pwaInfoStruct.uri; + if (startUrl.empty()) + return startUrl; + m_active = true; + } + return startUrl; +} + } // namespace base_ui +} // namespace tizen_browser diff --git a/services/SimpleUI/ProgressiveWebApp.h b/services/SimpleUI/ProgressiveWebApp.h index 7745027..97d9dec 100755 --- a/services/SimpleUI/ProgressiveWebApp.h +++ b/services/SimpleUI/ProgressiveWebApp.h @@ -43,17 +43,20 @@ public: ~ProgressiveWebApp(); void preparePWAParameters(const std::string& uri); pwaInfo getPWAinfo() const {return m_pwaInfoStruct;} + bool isActive() const { return m_active; } + std::string preparePWA(const std::string& url); private: void parse_uri(const std::string& uri); void fillPWAstruct(const std::map<std::string, std::string> &pwaParametersMap); + bool m_active; pwaInfo m_pwaInfoStruct; std::map<std::string, std::string> m_uriPartsMap; }; -} // namespace tizen_browser } // namespace base_ui +} // namespace tizen_browser #endif // PROGRESSIVEWEBAPP_H diff --git a/services/SimpleUI/SimpleUI.cpp b/services/SimpleUI/SimpleUI.cpp index 76cdd58..ce97135 100755 --- a/services/SimpleUI/SimpleUI.cpp +++ b/services/SimpleUI/SimpleUI.cpp @@ -28,6 +28,7 @@ #include <cassert> #include "WebPageUI.h" +#include "WebPageMin.h" #include "AbstractWebEngine.h" #include "TabOrigin.h" #include "HistoryUI.h" @@ -43,12 +44,11 @@ #include "HistoryService.h" #include "BookmarkFlowUI.h" #include "BookmarkManagerUI.h" +#include "BookmarkService.h" #include "PlatformInputManager.h" #include "StorageService.h" #include "CertificateContents.h" -#if PWA #include "ProgressiveWebApp.h" -#endif #include "Action.h" #include "InputPopup.h" #include "ContentPopup.h" @@ -104,10 +104,7 @@ SimpleUI::SimpleUI() , m_tabLimit(0) , m_qaLimit(0) , m_wvIMEStatus(false) -#if PWA , m_pwa() - , m_alreadyOpenedPWA(false) -#endif , m_manualRotation(false) , m_current_angle(0) , m_temp_angle(0) @@ -154,10 +151,14 @@ void SimpleUI::resume() { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); m_functionViewPrepare(); + if (m_pwa.isActive()) + m_webEngine->setFocus(); #if DUMMY_BUTTON - m_webPageUI->createDummyButton(); + else + m_webPageUI->createDummyButton(); #endif - if (m_webPageUI->stateEquals(WPUState::MAIN_INCOGNITO_PAGE) || + if (m_pwa.isActive() || + m_webPageUI->stateEquals(WPUState::MAIN_INCOGNITO_PAGE) || m_webPageUI->stateEquals(WPUState::MAIN_WEB_PAGE)) m_webEngine->resume(); if (m_languageChanged) { @@ -185,89 +186,80 @@ void SimpleUI::prepareServices() initUIServices(); initModelServices(); } -#if PWA -std::string SimpleUI::preparePWA(const std::string& url) -{ - std::string startUrl; - if (!strncmp(url.c_str(), "browser_shortcut::", strlen("browser_shortcut::"))) { - BROWSER_LOGD("Progressive web app"); - m_pwa.preparePWAParameters(url); - startUrl = m_pwa.getPWAinfo().uri; - if (startUrl.empty()) - return std::string(); - BROWSER_LOGD("Display mode: %d", m_pwa.getPWAinfo().displayMode); - m_webPageUI->setDisplayMode( - static_cast<WebPageUI::WebDisplayMode>( - m_pwa.getPWAinfo().displayMode)); - - if (m_pwa.getPWAinfo().orientation == WebPageUI::WebScreenOrientationLockPortrait) - rotationType(rotationLock::portrait); - else if (m_pwa.getPWAinfo().orientation == WebPageUI::WebScreenOrientationLockLandscape) - rotationType(rotationLock::landscape); - return startUrl; - } - return std::string(); + +void SimpleUI::preparePWAServices() +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + m_webPageMin = + std::dynamic_pointer_cast<base_ui::WebPageMin, core::AbstractService>( + core::ServiceManager::getInstance().getService("org.tizen.browser.webpagemin", "libWebPageMin.so")); + + m_webEngine = + std::dynamic_pointer_cast + <basic_webengine::AbstractWebEngine, core::AbstractService>( + core::ServiceManager::getInstance().getService("org.tizen.browser.webenginemin", "libWebEngineMin.so")); + + m_platformInputManager = + std::dynamic_pointer_cast + <services::PlatformInputManager, core::AbstractService>( + core::ServiceManager::getInstance().getService("org.tizen.browser.platforminputmanager", "libPlatformInputManager.so")); + + m_platformInputManager->backPressed.connect(boost::bind(&SimpleUI::onPWABackPressed, this)); + + m_webPageMin->init(m_viewManager.getContent()); + m_webEngine->init(m_webPageMin->getContent()); + m_platformInputManager->init(m_window.get()); } -#endif -int SimpleUI::exec(const std::string& _url, const std::string& _caller, const std::string& _operation) +int SimpleUI::exec(const std::string& url, const std::string& caller, const std::string& operation) { BROWSER_LOGD( - "[%s] _url=%s, _caller=%s, _operation=%s, initialised=%d", + "[%s] url=%s, caller=%s, operation=%s, initialised=%d", __func__, - _url.c_str(), - _caller.c_str(), - _operation.c_str(), + url.c_str(), + caller.c_str(), + operation.c_str(), m_initialised); - std::string url = _url; - std::string operation = _operation; m_alreadyOpenedExecURL = false; m_functionViewPrepare = [url, operation, this]() mutable { + std::string pwaUrl = m_pwa.preparePWA(url); if (!m_initialised) { - if (m_window.get()) { - prepareServices(); + if (m_pwa.isActive()) { // Progressive web app + preparePWAServices(); + if (m_pwa.getPWAinfo().orientation == WebPageUI::WebScreenOrientationLockPortrait) + rotationType(rotationLock::portrait); + else if (m_pwa.getPWAinfo().orientation == WebPageUI::WebScreenOrientationLockLandscape) + rotationType(rotationLock::landscape); + pushViewToStack(m_webPageMin); + m_platformInputManager->registerHWKeyCallback(m_viewManager.getContent()); + m_webEngine->rotatePrepared.connect([this]{ this->rotatePrepared(); }); + } else { + if (m_window.get()) { + prepareServices(); - //Push first view to stack. - pushViewToStack(m_webPageUI); + //Push first view to stack. + pushViewToStack(m_webPageUI); - // Register H/W back key callback - m_platformInputManager->registerHWKeyCallback(m_viewManager.getContent()); - } + // Register H/W back key callback + m_platformInputManager->registerHWKeyCallback(m_viewManager.getContent()); + } - BROWSER_LOGD("[%s]: restore last session", __func__); - switchViewToQuickAccess(); - restoreLastSession(); + BROWSER_LOGD("[%s]: restore last session", __func__); + switchViewToQuickAccess(); + restoreLastSession(); + } m_initialised = true; } - std::string pwaUrl = std::string(); -#if PWA - // Progressive web app - pwaUrl = preparePWA(url); - - if ((!pwaUrl.empty() && m_webEngine->getState() != basic_webengine::State::SECRET) || - (pwaUrl.empty() && m_webEngine->getState() == basic_webengine::State::SECRET)) - changeEngineState(); - - m_webPageUI->updateEngineStateUI(); -#endif if (!pwaUrl.empty() || (!url.empty() && !m_alreadyOpenedExecURL)) { - BROWSER_LOGD("[%s]: open new tab", __func__); std::string newUrl = url; - if (!operation.compare(APP_CONTROL_OPERATION_SEARCH)) { + if (!operation.compare(APP_CONTROL_OPERATION_SEARCH) && !m_pwa.isActive()) { newUrl = m_webPageUI->getURIEntry().rewriteURI(url); popStackTo(m_webPageUI); } - auto taburl = pwaUrl.empty() ? newUrl : pwaUrl; -#if PWA - // Allow for only one instance of PWA - if (m_alreadyOpenedPWA) - m_webEngine->closeTab(); - if (!pwaUrl.empty()) - popStackTo(m_webPageUI); - m_alreadyOpenedPWA = !pwaUrl.empty(); -#endif + auto taburl = pwaUrl.empty() ? newUrl : pwaUrl; openNewTab(taburl); m_alreadyOpenedExecURL = true; } @@ -279,7 +271,6 @@ 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__); @@ -295,7 +286,6 @@ void SimpleUI::countCheckUrl() BROWSER_LOGD("[%s:%d] url count : %d", __PRETTY_FUNCTION__, __LINE__, ret); } } -#endif void SimpleUI::restoreLastSession() { @@ -318,39 +308,39 @@ void SimpleUI::loadUIServices() m_webPageUI = std::dynamic_pointer_cast<base_ui::WebPageUI, core::AbstractService>( - core::ServiceManager::getInstance().getService("org.tizen.browser.webpageui")); + core::ServiceManager::getInstance().getService("org.tizen.browser.webpageui", "libWebPageUI.so")); m_quickAccess = std::dynamic_pointer_cast<base_ui::QuickAccess, core::AbstractService>( - core::ServiceManager::getInstance().getService("org.tizen.browser.quickaccess")); + core::ServiceManager::getInstance().getService("org.tizen.browser.quickaccess", "libQuickAccess.so")); m_historyUI = std::dynamic_pointer_cast<base_ui::HistoryUI, core::AbstractService>( - core::ServiceManager::getInstance().getService("org.tizen.browser.historyui")); + core::ServiceManager::getInstance().getService("org.tizen.browser.historyui", "libHistoryUI.so")); m_tabUI = std::dynamic_pointer_cast<base_ui::TabUI, core::AbstractService>( - core::ServiceManager::getInstance().getService("org.tizen.browser.tabui")); + core::ServiceManager::getInstance().getService("org.tizen.browser.tabui", "libTabUI.so")); auto futureSettings(std::async(std::launch::async, [this](){ m_settingsManager = std::dynamic_pointer_cast<SettingsManager, core::AbstractService>( - core::ServiceManager::getInstance().getService("org.tizen.browser.settingsui")); + core::ServiceManager::getInstance().getService("org.tizen.browser.settingsui", "libSettingsUI.so")); })); auto futureBookmarkFlow(std::async(std::launch::async, [this](){ m_bookmarkFlowUI = std::dynamic_pointer_cast<base_ui::BookmarkFlowUI, core::AbstractService>( - core::ServiceManager::getInstance().getService("org.tizen.browser.bookmarkflowui")); + core::ServiceManager::getInstance().getService("org.tizen.browser.bookmarkflowui", "libBookmarkFlowUI.so")); })); auto futureFindOnPage(std::async(std::launch::async, [this](){ m_findOnPageUI = std::dynamic_pointer_cast<base_ui::FindOnPageUI, core::AbstractService>( - core::ServiceManager::getInstance().getService("org.tizen.browser.findonpageui")); + core::ServiceManager::getInstance().getService("org.tizen.browser.findonpageui", "libFindOnPageUI.so")); })); auto futureBookmarksMan(std::async(std::launch::async, [this](){ m_bookmarkManagerUI = std::dynamic_pointer_cast<base_ui::BookmarkManagerUI, core::AbstractService>( - core::ServiceManager::getInstance().getService("org.tizen.browser.bookmarkmanagerui")); + core::ServiceManager::getInstance().getService("org.tizen.browser.bookmarkmanagerui", "libBookmarkManagerUI.so")); })); futureSettings.get(); futureBookmarkFlow.get(); @@ -365,37 +355,37 @@ void SimpleUI::loadModelServices() m_webEngine = std::dynamic_pointer_cast <basic_webengine::AbstractWebEngine, core::AbstractService>( - core::ServiceManager::getInstance().getService("org.tizen.browser.webengineservice")); + core::ServiceManager::getInstance().getService("org.tizen.browser.webengineservice", "libWebEngineService.so")); m_historyService = std::dynamic_pointer_cast <services::HistoryService, core::AbstractService>( - core::ServiceManager::getInstance().getService("org.tizen.browser.historyservice")); + core::ServiceManager::getInstance().getService("org.tizen.browser.historyservice", "libHistoryService.so")); m_platformInputManager = std::dynamic_pointer_cast <services::PlatformInputManager, core::AbstractService>( - core::ServiceManager::getInstance().getService("org.tizen.browser.platforminputmanager")); + core::ServiceManager::getInstance().getService("org.tizen.browser.platforminputmanager", "libPlatformInputManager.so")); auto futureStorage(std::async(std::launch::async, [this]{ m_storageService = std::dynamic_pointer_cast <services::StorageService, core::AbstractService>( - core::ServiceManager::getInstance().getService("org.tizen.browser.storageservice")); + core::ServiceManager::getInstance().getService("org.tizen.browser.storageservice", "libStorageService.so")); })); auto futureTab(std::async(std::launch::async, [this]{ m_tabService = std::dynamic_pointer_cast< services::TabService, core::AbstractService>( - core::ServiceManager::getInstance().getService("org.tizen.browser.tabservice")); + core::ServiceManager::getInstance().getService("org.tizen.browser.tabservice", "libTabService.so")); })); auto futureFavourite(std::async(std::launch::async, [this]{ m_favoriteService = std::dynamic_pointer_cast - <interfaces::AbstractFavoriteService, core::AbstractService>( - core::ServiceManager::getInstance().getService("org.tizen.browser.favoriteservice")); + <services::BookmarkService, core::AbstractService>( + core::ServiceManager::getInstance().getService("org.tizen.browser.favoriteservice", "libBookmarkService.so")); })); auto futureCertificates(std::async(std::launch::async, [this]{ m_certificateContents = std::dynamic_pointer_cast <services::CertificateContents, core::AbstractService>( - core::ServiceManager::getInstance().getService("org.tizen.browser.certificateservice")); + core::ServiceManager::getInstance().getService("org.tizen.browser.certificateservice", "libCertificateService.so")); })); futureStorage.get(); futureTab.get(); @@ -498,12 +488,10 @@ void SimpleUI::connectWebPageSignals() [this]{ return m_webEngine->getState(); }); m_webPageUI->requestCurrentPageForWebPageUI.connect( [this]{ return requestSettingsCurrentPage(); }); -#if PWA m_webPageUI->pwaRequestManifest.connect( [this]{ m_webEngine->setPWAData(); }); m_webPageUI->getCountCheckSignal.connect( [this]{ return this->countCheckUrl(); }); -#endif m_webPageUI->isMostVisited.connect( [this]{ return m_quickAccess->isMostVisitedActive(); }); m_webPageUI->setBarsShown.connect( @@ -914,14 +902,24 @@ void SimpleUI::switchViewToWebPage() BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); if (m_webEngine->isSuspended()) m_webEngine->resume(); - m_webPageUI->switchViewToWebPage(m_webEngine->getLayout(), m_webEngine->getURI(), m_webEngine->isLoading()); + if (!m_pwa.isActive()) + m_webPageUI->switchViewToWebPage(m_webEngine->getLayout(), + m_webEngine->getURI(), + m_webEngine->isLoading()); + else + m_webPageMin->setMainContent(m_webEngine->getLayout()); } void SimpleUI::switchToTab(const basic_webengine::TabId& tabId) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); m_webEngine->switchToTab(tabId); - m_webPageUI->switchViewToWebPage(m_webEngine->getLayout(), m_webEngine->getURI(), m_webEngine->isLoading()); + if (!m_pwa.isActive()) + m_webPageUI->switchViewToWebPage(m_webEngine->getLayout(), + m_webEngine->getURI(), + m_webEngine->isLoading()); + else + m_webPageMin->setMainContent(m_webEngine->getLayout()); } void SimpleUI::switchViewToQuickAccess() @@ -1201,6 +1199,9 @@ void SimpleUI::onEditFolderPopupClicked(const std::string& newName, services::Sh void SimpleUI::hideBottomBar(const bool& state) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (m_pwa.isActive()) + return; + if (m_webEngine->getLayout() && !m_webPageUI->stateEquals(WPUState::QUICK_ACCESS)) m_webEngine->setIMEState(state); else @@ -1312,6 +1313,19 @@ void SimpleUI::onBackPressed() #endif } +void SimpleUI::onPWABackPressed() +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + if (m_wvIMEStatus) { // if IME opened + return; + } else if (m_webEngine->isBackEnabled()) { + m_webEngine->backButtonClicked(); + } else { + minimizeBrowser(); + } +} + void SimpleUI::dismissPopup(interfaces::AbstractPopup* popup) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); @@ -1376,7 +1390,8 @@ void SimpleUI::onRotation() BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); m_current_angle = m_temp_angle; - m_webEngine->orientationChanged(); + if (m_webEngine) + m_webEngine->orientationChanged(); if (!m_manualRotation) { if (m_bookmarkFlowUI) m_bookmarkFlowUI->orientationChanged(); @@ -1569,7 +1584,6 @@ void SimpleUI::tabClicked(const tizen_browser::basic_webengine::TabId& tabId) popStackTo(m_webPageUI); } -#if PWA void SimpleUI::pwaPopupRequest() { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); @@ -1611,7 +1625,6 @@ void SimpleUI::pwaPopupButtonClicked(const PopupButtons& button) BROWSER_LOGW("[%s:%d] Unknown button type!", __PRETTY_FUNCTION__, __LINE__); } } -#endif void SimpleUI::handleConfirmationRequest(basic_webengine::WebConfirmationPtr webConfirmation) { @@ -2057,12 +2070,8 @@ void SimpleUI::changeEngineState() BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); m_webEngine->changeState(); -#if PWA - if (!m_alreadyOpenedPWA) -#endif - m_webPageUI->switchViewToQuickAccess(m_quickAccess->getContent()); + m_webPageUI->switchViewToQuickAccess(m_quickAccess->getContent()); updateView(); - } void SimpleUI::engineTabClosed(const basic_webengine::TabId& id) diff --git a/services/SimpleUI/SimpleUI.h b/services/SimpleUI/SimpleUI.h index b4081b9..bd7e4c8 100755 --- a/services/SimpleUI/SimpleUI.h +++ b/services/SimpleUI/SimpleUI.h @@ -29,7 +29,6 @@ #include "AbstractContextMenu.h" #include "AbstractMainWindow.h" #include "AbstractService.h" -#include "AbstractFavoriteService.h" #include "service_macros.h" #include "TabServiceTypedef.h" @@ -53,10 +52,12 @@ class HistoryService; class PlatformInputManager; class StorageService; class CertificateContents; +class BookmarkService; } namespace base_ui{ class WebPageUI; +class WebPageMin; class HistoryUI; class FindOnPageUI; class SettingsUI; @@ -71,9 +72,7 @@ class ContentPopup; class ViewManager; class MenuButton; class NaviframeWrapper; -#if PWA class ProgressiveWebApp; -#endif template <> void AbstractMainWindow<Evas_Object>::setMainWindow(Evas_Object * rawPtr) @@ -105,10 +104,8 @@ public: private: // setup functions void prepareServices(); -#if PWA - std::string preparePWA(const std::string& url); + void preparePWAServices(); void countCheckUrl(); -#endif void loadUIServices(); void connectUISignals(); void loadModelServices(); @@ -167,10 +164,8 @@ private: void onMenuButtonPressed(); void handleConfirmationRequest(basic_webengine::WebConfirmationPtr webConfirmation); void setwvIMEStatus(bool status) { m_wvIMEStatus = status; }; -#if PWA void pwaPopupRequest(); void pwaPopupButtonClicked(const PopupButtons& button); -#endif sharedAction m_showBookmarkManagerUI; @@ -279,13 +274,15 @@ private: void onXF86MenuPressed(); void onXF86BackPressed(); void onBackPressed(); + void onPWABackPressed(); void onFirstSecretMode(); std::vector<interfaces::AbstractPopup*> m_popupVector; std::shared_ptr<WebPageUI> m_webPageUI; + std::shared_ptr<WebPageMin> m_webPageMin; std::shared_ptr<basic_webengine::AbstractWebEngine> m_webEngine; - std::shared_ptr<interfaces::AbstractFavoriteService> m_favoriteService; + std::shared_ptr<services::BookmarkService> m_favoriteService; std::shared_ptr<services::HistoryService> m_historyService; services::TabServicePtr m_tabService; std::shared_ptr<BookmarkFlowUI> m_bookmarkFlowUI; @@ -308,10 +305,7 @@ private: //helper object used to view management ViewManager m_viewManager; Evas_Object *main_window; -#if PWA ProgressiveWebApp m_pwa; - bool m_alreadyOpenedPWA; -#endif bool m_manualRotation; int m_current_angle; int m_temp_angle; diff --git a/services/WebEngineMin/CMakeLists.txt b/services/WebEngineMin/CMakeLists.txt new file mode 100755 index 0000000..5caedac --- /dev/null +++ b/services/WebEngineMin/CMakeLists.txt @@ -0,0 +1,20 @@ +project(WebEngineMin) + +set(WebEngineMin_SRCS + WebEngineMin.cpp + ) + +include(Coreheaders) +include(EFLHelpers) +include(EWebKitHelpers) + +include_directories(${CMAKE_BINARY_DIR}) +include_directories(${CMAKE_SOURCE_DIR}) + +add_library(${PROJECT_NAME} SHARED ${WebEngineMin_SRCS}) +target_link_libraries(${PROJECT_NAME} ${EFL_LDFLAGS}) +target_link_libraries(${PROJECT_NAME} ${EWEBKIT2_LDFLAGS}) + +install(TARGETS ${PROJECT_NAME} + LIBRARY DESTINATION services + ARCHIVE DESTINATION services/static) diff --git a/services/WebEngineMin/WebEngineMin.cpp b/services/WebEngineMin/WebEngineMin.cpp new file mode 100644 index 0000000..1398075 --- /dev/null +++ b/services/WebEngineMin/WebEngineMin.cpp @@ -0,0 +1,128 @@ +#include "WebEngineMin.h" +#include <EWebKit.h> +#include <app_common.h> +#include "BrowserAssert.h" +#include "BrowserLogger.h" +#include "Tools/GeneralTools.h" + + +namespace tizen_browser { +namespace basic_webengine { + +EXPORT_SERVICE(WebEngineMin, "org.tizen.browser.webenginemin") + +const std::string WebEngineMin::COOKIES_PATH = "cookies"; +const char* const APPLICATION_NAME_FOR_USER_AGENT_MOBILE = + "Mozilla/5.0 (Linux; Tizen 3.0; SAMSUNG TM1) AppleWebKit/537.36" + " (KHTML, like Gecko) SamsungBrowser/1.0 Chrome/47.0.2526.69 Mobile safari/537.36"; + +WebEngineMin::~WebEngineMin() +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (m_ewkView) { + evas_object_smart_callback_del_full(m_ewkView, "load,finished", _load_finished, this); + evas_object_smart_callback_del_full(m_ewkView, "rotate,prepared", _rotate_prepared, this); + evas_object_del(m_ewkView); + } +} + +void WebEngineMin::init(Evas_Object* guiParent) +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + m_ewkView = ewk_view_add_with_context(evas_object_evas_get(guiParent), ewk_context_default_get()); + + m_ewkContext = ewk_view_context_get(m_ewkView); + if (m_ewkContext) + ewk_cookie_manager_accept_policy_set(ewk_context_cookie_manager_get(m_ewkContext), + EWK_COOKIE_ACCEPT_POLICY_ALWAYS); + + evas_object_data_set(m_ewkView, "_container", this); + evas_object_color_set(m_ewkView, 255, 255, 255, 255); + evas_object_size_hint_weight_set(m_ewkView, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(m_ewkView, EVAS_HINT_FILL, EVAS_HINT_FILL); + ewk_view_user_agent_set(m_ewkView, APPLICATION_NAME_FOR_USER_AGENT_MOBILE); + ewk_context_cache_model_set(m_ewkContext, EWK_CACHE_MODEL_PRIMARY_WEBBROWSER); + std::string path = app_get_data_path() + COOKIES_PATH; + ewk_cookie_manager_persistent_storage_set(ewk_context_cookie_manager_get(m_ewkContext), + path.c_str(), EWK_COOKIE_PERSISTENT_STORAGE_SQLITE); + + evas_object_smart_callback_add(m_ewkView, "load,finished", _load_finished, this); + evas_object_smart_callback_add(m_ewkView, "rotate,prepared", _rotate_prepared, this); + + resume(); +} + +TabId WebEngineMin::addTab(const std::string& uri, + const boost::optional<int>, + const std::string&, + bool, + TabOrigin) +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + setURI(uri); + return 0; +} + +void WebEngineMin::suspend() +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + M_ASSERT(m_ewkView); + + ewk_view_suspend(m_ewkView); +} + +void WebEngineMin::resume() +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + M_ASSERT(m_ewkView); + + ewk_view_resume(m_ewkView); +} + +void WebEngineMin::setURI(const std::string& uri) +{ + BROWSER_LOGD("[%s:%d] uri=%s", __PRETTY_FUNCTION__, __LINE__, uri.c_str()); + ewk_view_url_set(m_ewkView, uri.c_str()); +} + +std::string WebEngineMin::getURI(void) const +{ + return tools::fromChar(ewk_view_url_get(m_ewkView)); +} + +void WebEngineMin::orientationChanged() +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + boost::optional<int> signal = getRotation(); + if (signal && *signal != -1) { + int angle = *signal; + if ((angle % 180) == 90) + angle -= 180; + ewk_view_orientation_send(m_ewkView, angle); + } +} + +void WebEngineMin::_load_finished(void * data, Evas_Object * /* obj */, void * /* event_info */) +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (!data) { + BROWSER_LOGW("[%s:%d] Wrong data!", __PRETTY_FUNCTION__, __LINE__); + return; + } + WebEngineMin * self = static_cast<WebEngineMin *>(data); + self->loadFinished(); +} + +void WebEngineMin::_rotate_prepared(void * data, Evas_Object *, void *) +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data) { + auto *self = static_cast<WebEngineMin *>(data); + self->rotatePrepared(); + } else + BROWSER_LOGW("[%s] data = nullptr", __PRETTY_FUNCTION__); +} + + +} +} diff --git a/services/WebEngineMin/WebEngineMin.h b/services/WebEngineMin/WebEngineMin.h new file mode 100644 index 0000000..cd2b557 --- /dev/null +++ b/services/WebEngineMin/WebEngineMin.h @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WEBENGINEMIN_H_ +#define WEBENGINEMIN_H_ + + +#include <boost/noncopyable.hpp> +#include <Evas.h> +#include <EWebKit_internal.h> +#include "AbstractWebEngine/AbstractWebEngine.h" +#include "service_macros.h" + +namespace tizen_browser { +namespace basic_webengine { + + +class BROWSER_EXPORT WebEngineMin : public AbstractWebEngine, boost::noncopyable +{ +public: + WebEngineMin() = default; + ~WebEngineMin(); + + std::string getName() override; + Evas_Object* getLayout() override { return m_ewkView; } + + void init(Evas_Object* guiParent) override; + void setURI(const std::string& uri) override; + std::string getURI() const override; + std::string getTitle() const override { return std::string(); } + TabOrigin getOrigin() const override { return TabOrigin::UNKNOWN; } + std::string getUserAgent() const override { return std::string(); } + void suspend() override; + void resume() override; + bool isSuspended() const override { return false; } + bool isBackEnabled() const override { return ewk_view_back_possible(m_ewkView); } + bool isForwardEnabled() const override { return false; } + bool isLoading() const override { return false; } + int tabsCount() const override { return 1; } + TabId currentTabId() const override { return 0; } + TabId oldestTabId() const override { return 0; } + void destroyTabs() override { evas_object_del(m_ewkView); } + std::vector<std::shared_ptr<TabContent>> getTabContents() const override + { return std::vector<std::shared_ptr<TabContent>>(); } + TabId addTab(const std::string& uri, const boost::optional<int>, const std::string&, + bool, TabOrigin) override; + TabId openRequestedPage() override { return 0; } + Evas_Object* getTabView(TabId) override { return m_ewkView; } + bool switchToTab(TabId) override { return true; } + bool closeTab() override { return false; } + bool closeTab(TabId) override { return false; } + std::shared_ptr<tools::BrowserImage> getSnapshotData(int, int, tools::SnapshotType) override + { return nullptr; } + std::shared_ptr<tools::BrowserImage> getSnapshotData(TabId, int, int, bool, tools::SnapshotType) override + { return nullptr; } + bool isSecretMode() override { return false; } + bool isLoadError() const override { return false; } + bool getIMEState() const override { return false; } + void setFocus() override { ewk_view_focus_set(m_ewkView, EINA_TRUE); }; + void clearFocus() override { ewk_view_focus_set(m_ewkView, EINA_FALSE); }; + bool hasFocus() const override { return ewk_view_focus_get(m_ewkView) == EINA_TRUE; } + std::shared_ptr<tools::BrowserImage> getFavicon() override { + return nullptr; } + void backButtonClicked() override { ewk_view_back(m_ewkView); } + bool isDesktopMode() const override { return false; } + bool isFullScreenMode() const override { return false; } + bool getSettingsParam(WebEngineSettings) override { return false; } + void orientationChanged() override; + State getState() override { return State::NORMAL; } + +#if !DUMMY_BUTTON + Evas_Object* getWidget() override { } +#endif + void requestManifest() override { } + void setPWAData() override { } + void setUserAgent(const std::string&) override { } + void languageChanged() override { } + void stopLoading() override { } + void reload() override { } + void back() override { } + void forward() override { } + void confirmationResult(WebConfirmationPtr) override { } + void setIMEState(const bool&) override { } + void clearCache() override { } + void clearCookies() override { } + void clearPrivateData() override { } + void clearPasswordData() override { } + void clearFormData() override { } + void searchOnWebsite(const std::string &, int) override { } + void switchToMobileMode() override { } + void switchToDesktopMode() override { } + void onTabIdCreated(int) override { } + void findWord(const char*, Eina_Bool, Evas_Smart_Cb, void*) { } + void setSettingsParam(WebEngineSettings, bool) override { } + void changeState() override { } + void setBarsShown(bool) const override { } + +private: + static void _load_finished(void * data, Evas_Object * obj, void * event_info); + static void _rotate_prepared(void * data, Evas_Object * obj, void * event_info); + Evas_Object* m_ewkView; + Ewk_Context* m_ewkContext; + + static const std::string COOKIES_PATH; +}; + + + +} +} + + +#endif /* WEBENGINEMIN_H_ */ diff --git a/services/WebEngineService/WebEngineService.cpp b/services/WebEngineService/WebEngineService.cpp index 626cb3c..52056e3 100755 --- a/services/WebEngineService/WebEngineService.cpp +++ b/services/WebEngineService/WebEngineService.cpp @@ -266,7 +266,6 @@ void WebEngineService::requestManifest() m_currentWebView->requestManifest(); } -#if PWA void WebEngineService::setPWAData() { m_currentWebView->addManifestTypeToHandle(ManifestType::PWA_MANIFEST); @@ -275,7 +274,6 @@ void WebEngineService::setPWAData() else m_currentWebView->handleManifest(); } -#endif bool WebEngineService::isLoadError() const { diff --git a/services/WebEngineService/WebEngineService.h b/services/WebEngineService/WebEngineService.h index fbb92a9..60d8ec6 100755 --- a/services/WebEngineService/WebEngineService.h +++ b/services/WebEngineService/WebEngineService.h @@ -64,9 +64,7 @@ public: void setURI(const std::string &); std::string getURI(void) const; void requestManifest(void); -#if PWA void setPWAData(); -#endif std::string getTitle(void) const; TabOrigin getOrigin(void) const; std::string getUserAgent(void) const; diff --git a/services/WebEngineService/WebView.cpp b/services/WebEngineService/WebView.cpp index 3458f8b..bc229c5 100755 --- a/services/WebEngineService/WebView.cpp +++ b/services/WebEngineService/WebView.cpp @@ -51,12 +51,10 @@ #include <device/haptic.h> #include <Ecore.h> -#if PWA #include <sys/stat.h> #include <fcntl.h> #include <tzplatform_config.h> #include <glib.h> -#endif const char* const APPLICATION_NAME_FOR_USER_AGENT = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.69 safari/537.36 "; @@ -81,12 +79,10 @@ namespace basic_webengine { namespace webengine_service { const std::string WebView::COOKIES_PATH = "cookies"; -#if PWA std::string WebView::s_pwaData = ""; std::string WebView::s_name = ""; std::string WebView::s_icon = ""; const std::string WebView::DOWNLOAD_PATH = tzplatform_getenv(TZ_USER_DOWNLOADS); -#endif struct SnapshotItemData { WebView* web_view; @@ -700,11 +696,9 @@ void WebView::handleManifest() case ManifestType::THEME_MANIFEST: BROWSER_LOGD("Quickaccess manifest - not implemented"); break; -#if PWA case ManifestType::PWA_MANIFEST: setPWAData(); break; -#endif default: BROWSER_LOGD("Bad manifest type"); break; @@ -713,7 +707,6 @@ void WebView::handleManifest() m_manifestVector.clear(); } -#if PWA void WebView::setPWAData() { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); @@ -812,7 +805,6 @@ void WebView::__download_result_cb(const std::string& file_path, void *data) BROWSER_LOGD("[%s:%d] file_path = [%s], data = [%s]", file_path.c_str(), data); BROWSER_LOGD("[%s:%d] complete !", __PRETTY_FUNCTION__, __LINE__); } -#endif std::string WebView::getTitle(void) { @@ -1009,7 +1001,7 @@ void WebView::__newWindowRequest(void *data, Evas_Object *, void *out) < basic_webengine::AbstractWebEngine,tizen_browser::core::AbstractService > - (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.webengineservice")); + (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.webengineservice", "libWebEngineService.so")); M_ASSERT(m_webEngine); /// \todo: Choose newly created tab. @@ -1037,7 +1029,7 @@ void WebView::__closeWindowRequest(void *data, Evas_Object *, void *) std::shared_ptr<AbstractWebEngine> m_webEngine = std::dynamic_pointer_cast <basic_webengine::AbstractWebEngine,tizen_browser::core::AbstractService> - (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.webengineservice")); + (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.webengineservice", "libWebEngineService.so")); m_webEngine->closeTab(self->getTabId()); } diff --git a/services/WebEngineService/WebView.h b/services/WebEngineService/WebView.h index 2b8e590..213943e 100755 --- a/services/WebEngineService/WebView.h +++ b/services/WebEngineService/WebView.h @@ -33,10 +33,7 @@ #include <app_control.h> #include <app.h> #include "AbstractRotatable.h" - -#if PWA #include <libsoup/soup.h> -#endif enum context_menu_type { TEXT_ONLY = 0, @@ -150,7 +147,6 @@ public: void handleManifest(); void addManifestTypeToHandle(const ManifestType &type) { m_manifestVector.push_back(type); } -#if PWA void setPWAData(); void request_file_download(const std::string& uri, const std::string& file_path, download_finish_callback cb, void *data); @@ -173,7 +169,6 @@ public: download_request& operator=(const download_request&); download_request(const download_request&); }; -#endif std::map<std::string, std::vector<std::string> > parse_uri(const char *uriToParse); @@ -369,12 +364,10 @@ private: static void __closeWindowRequest(void * data, Evas_Object *, void *); static void __setManifestData(Evas_Object* view, Ewk_View_Request_Manifest* manifest, void *data); -#if PWA static int result_cb(int ret, void *data); static void makeShortcut(const std::string& name, const std::string& pwaData, const std::string& icon); static void __file_download_finished_cb(SoupSession *session, SoupMessage *msg, gpointer data); static void __download_result_cb(const std::string& file_path, void *data); -#endif context_menu_type _get_menu_type(Ewk_Context_Menu *menu); void _customize_context_menu(Ewk_Context_Menu *menu); @@ -469,13 +462,11 @@ private: ManifestTypesVector m_manifestVector; static const std::string COOKIES_PATH; -#if PWA static std::string s_pwaData; static std::string s_name; static std::string s_start_url; static std::string s_icon; static const std::string DOWNLOAD_PATH; -#endif DownloadControl* m_downloadControl; int m_policyCounter; diff --git a/services/WebPageMin/CMakeLists.txt b/services/WebPageMin/CMakeLists.txt new file mode 100755 index 0000000..55b5f60 --- /dev/null +++ b/services/WebPageMin/CMakeLists.txt @@ -0,0 +1,19 @@ +project(WebPageMin) + +set(WebPageMin_SRCS + WebPageMin.cpp + ) + +include(Coreheaders) +include(EFLHelpers) +include(EWebKitHelpers) + +include_directories(${CMAKE_BINARY_DIR}) +include_directories(${CMAKE_SOURCE_DIR}) + +add_library(${PROJECT_NAME} SHARED ${WebPageMin_SRCS}) +target_link_libraries(${PROJECT_NAME} ${EFL_LDFLAGS}) + +install(TARGETS ${PROJECT_NAME} + LIBRARY DESTINATION services + ARCHIVE DESTINATION services/static) diff --git a/services/WebPageMin/WebPageMin.cpp b/services/WebPageMin/WebPageMin.cpp new file mode 100644 index 0000000..9a936be --- /dev/null +++ b/services/WebPageMin/WebPageMin.cpp @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "WebPageMin.h" +#include "Tools/EflTools.h" +#include <Elementary.h> + +namespace tizen_browser { +namespace base_ui { + +EXPORT_SERVICE(WebPageMin, "org.tizen.browser.webpagemin") + +WebPageMin::WebPageMin() + : m_layout(nullptr) +{ } + +void WebPageMin::init(Evas_Object* parent) +{ + // create web layout + m_layout = elm_layout_add(parent); + tools::EflTools::setExpandHints(m_layout); + elm_layout_theme_set(m_layout, "layout", "application", "default"); + evas_object_show(m_layout); +} + +Evas_Object* WebPageMin::getContent() +{ + return m_layout; +} + +void WebPageMin::showUI() +{ + evas_object_show(m_layout); +} + +void WebPageMin::hideUI() +{ + evas_object_hide(m_layout); +} + +void WebPageMin::setMainContent(Evas_Object* content) +{ + elm_layout_content_set(m_layout, "elm.swallow.content", content); +} + +} // base_ui +} // tizen_browser diff --git a/services/WebPageMin/WebPageMin.h b/services/WebPageMin/WebPageMin.h new file mode 100644 index 0000000..0052e64 --- /dev/null +++ b/services/WebPageMin/WebPageMin.h @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WebPageMin_H +#define WebPageMin_H + +#include "AbstractService.h" +#include "AbstractUIComponent.h" +#include "AbstractRotatable.h" +#include "service_macros.h" + +namespace tizen_browser { +namespace base_ui { + +class BROWSER_EXPORT WebPageMin + : public interfaces::AbstractUIComponent + , public core::AbstractService +{ +public: + WebPageMin(); + virtual ~WebPageMin() = default; + std::string getName() override; + void init(Evas_Object* parent) override; + Evas_Object* getContent() override; + void showUI() override; + void hideUI() override; + void setMainContent(Evas_Object* content); +private: + Evas_Object* m_layout; +}; + +} // base_ui +} // tizen_browser + +#endif diff --git a/services/WebPageUI/WebPageUI.cpp b/services/WebPageUI/WebPageUI.cpp index df32199..d53db7b 100755 --- a/services/WebPageUI/WebPageUI.cpp +++ b/services/WebPageUI/WebPageUI.cpp @@ -55,9 +55,7 @@ WebPageUI::WebPageUI() , m_webviewLocked(false) , m_WebPageUIvisible(false) , m_desktopMode(false) -#if PWA , m_pwaInfo(nullptr) -#endif #if GESTURE , m_gestureLayer(nullptr) #endif @@ -219,9 +217,7 @@ void WebPageUI::loadFinished() elm_object_focus_set(m_dummy_button, EINA_TRUE); #endif -#if PWA getCountCheckSignal(); -#endif } void WebPageUI::setMainContent(Evas_Object* content) @@ -433,10 +429,8 @@ void WebPageUI::showContextMenu() return; } elm_ctxpopup_item_append(m_ctxpopup, _("IDS_BR_BODY_SETTINGS"), nullptr, _cm_settings_clicked, this); -#if PWA if (!m_statesMgr->equals(WPUState::QUICK_ACCESS)) elm_ctxpopup_item_append(m_ctxpopup, "Add to Homescreen", nullptr, _cm_add_to_hs_clicked, this); -#endif alignContextMenu(*window); } else BROWSER_LOGE("[%s:%d] Signal not found", __PRETTY_FUNCTION__, __LINE__); @@ -579,7 +573,7 @@ void WebPageUI::_cm_settings_clicked(void* data, Evas_Object*, void* ) } else BROWSER_LOGW("[%s] data = nullptr", __PRETTY_FUNCTION__); } -#if PWA + void WebPageUI::_cm_add_to_hs_clicked(void* data, Evas_Object*, void* ) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); @@ -596,7 +590,6 @@ void WebPageUI::_cm_add_to_hs_clicked(void* data, Evas_Object*, void* ) BROWSER_LOGW("[%s] data = nullptr", __PRETTY_FUNCTION__); } } -#endif void WebPageUI::urlbarOffsetSet(const float& offset) { @@ -963,21 +956,6 @@ void WebPageUI::mobileEntryUnfocused() elm_object_signal_emit(m_mainLayout, "decrease_unfocused_uri", "ui"); } -#if PWA -void WebPageUI::setDisplayMode(WebDisplayMode mode) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (mode == WebDisplayMode::WebDisplayModeFullscreen) - elm_object_signal_emit(m_mainLayout, "webview_fullscreen", "ui"); - else if (mode == WebDisplayMode::WebDisplayModeStandalone) - elm_object_signal_emit(m_mainLayout, "webview_fullscreen", "ui"); - else if (mode == WebDisplayMode::WebDisplayModeMinimalUi) - BROWSER_LOGD("Not implemented"); - else if (mode == WebDisplayMode::WebDisplayModeBrowser) - elm_object_signal_emit(m_mainLayout, "webview_default", "ui"); -} -#endif - void WebPageUI:: launch_share(const char *uri) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); diff --git a/services/WebPageUI/WebPageUI.h b/services/WebPageUI/WebPageUI.h index 581862e..2b9c331 100755 --- a/services/WebPageUI/WebPageUI.h +++ b/services/WebPageUI/WebPageUI.h @@ -45,7 +45,6 @@ class BROWSER_EXPORT WebPageUI , public interfaces::AbstractRotatable { public: -#if PWA enum orientationType { WebScreenOrientationLockDefault = 0, // Equivalent to unlock. WebScreenOrientationLockPortraitPrimary, @@ -78,7 +77,6 @@ public: long themeColor; long backgroundColor; }; -#endif WebPageUI(); virtual ~WebPageUI(); @@ -141,9 +139,6 @@ public: const int& a = DEFAULT_THEME.a); bool isBrighterThanDefault(const int& r, const int& g, const int& b); -#if PWA - void setDisplayMode(WebDisplayMode mode); -#endif std::string getURI(); boost::signals2::signal<void ()> backPage; @@ -178,10 +173,8 @@ public: boost::signals2::signal<std::string ()> requestCurrentPageForWebPageUI; boost::signals2::signal<basic_webengine::State ()> getEngineState; -#if PWA boost::signals2::signal<void ()> pwaRequestManifest; boost::signals2::signal<void ()> getCountCheckSignal; -#endif boost::signals2::signal<void (bool value)> setBarsShown; private: @@ -209,9 +202,7 @@ private: static void _cm_desktop_view_page_clicked(void*, Evas_Object*, void*); static void _cm_mobile_view_page_clicked(void*, Evas_Object*, void*); static void _cm_settings_clicked(void*, Evas_Object*, void*); -#if PWA static void _cm_add_to_hs_clicked(void*, Evas_Object*, void*); -#endif static void launch_share(const char *uri); void createLayout(); @@ -262,9 +253,7 @@ private: sharedAction m_bookmarks; sharedAction m_tabs; -#if PWA std::shared_ptr<pwaInfo> m_pwaInfo; -#endif #if GESTURE Evas_Object* m_gestureLayer; |