From 7dcd30a28c16f24b2fdc3f5b8459cef3723f278f Mon Sep 17 00:00:00 2001 From: Taejeong Lee Date: Tue, 18 Jun 2013 18:20:17 +0900 Subject: [PATCH] [Release] wrt_0.8.229 Change-Id: I78fcaa3a6bc537777e1f3888b32fd393cbfa27c5 --- packaging/wrt.spec | 5 +- src/CMakeLists.txt | 26 ++- src/api_new/CMakeLists.txt | 1 + src/api_new/ewk_context_manager.cpp | 17 +- src/view/common/view_logic_storage_support.cpp | 1 + src/view/webkit/injected-bundle/CMakeLists.txt | 6 +- .../injected_bundle_uri_handling.cpp | 13 +- .../injected-bundle/injected_bundle_uri_handling.h | 2 +- .../webkit/injected-bundle/wrt-injected-bundle.cpp | 11 +- src/view/webkit/view_logic.cpp | 97 +++++++--- src/view/webkit/view_logic.h | 7 + src/wrt-client/CMakeLists.txt | 2 + .../process_pool/smack_labeling_support.cpp | 205 +++++++++++++++++++++ .../process_pool/smack_labeling_support.h | 28 +++ src/wrt-client/window_data.cpp | 43 ++++- src/wrt-client/window_data.h | 9 + src/wrt-client/wrt-client.cpp | 53 ++++-- src/wrt-client/wrt-client.h | 7 + src/wrt-launchpad-daemon/include/launchpad_util.h | 113 ------------ .../include/process_pool_launchpad_util.h | 149 +++++++++++++++ src/wrt-launchpad-daemon/legacy/preload.h | 3 - wrt_env.sh | 2 +- 22 files changed, 619 insertions(+), 181 deletions(-) create mode 100644 src/wrt-client/process_pool/smack_labeling_support.cpp create mode 100644 src/wrt-client/process_pool/smack_labeling_support.h create mode 100644 src/wrt-launchpad-daemon/include/process_pool_launchpad_util.h diff --git a/packaging/wrt.spec b/packaging/wrt.spec index 8550da7..5b066f4 100644 --- a/packaging/wrt.spec +++ b/packaging/wrt.spec @@ -1,7 +1,7 @@ #git:framework/web/wrt Name: wrt Summary: web runtime -Version: 0.8.227 +Version: 0.8.229 Release: 1 Group: Development/Libraries License: Apache License, Version 2.0 @@ -19,7 +19,6 @@ BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(ewebkit2) BuildRequires: pkgconfig(appcore-efl) BuildRequires: pkgconfig(openssl) -BuildRequires: pkgconfig(cert-svc) BuildRequires: pkgconfig(dpl-efl) BuildRequires: pkgconfig(libpcrecpp) BuildRequires: pkgconfig(ecore) @@ -30,6 +29,7 @@ BuildRequires: pkgconfig(secure-storage) BuildRequires: pkgconfig(pkgmgr) BuildRequires: pkgconfig(libiri) BuildRequires: pkgconfig(appsvc) +BuildRequires: pkgconfig(cert-svc) BuildRequires: pkgconfig(cert-svc-vcore) BuildRequires: pkgconfig(libsoup-2.4) BuildRequires: pkgconfig(security-core) @@ -47,6 +47,7 @@ BuildRequires: pkgconfig(wrt-popup-ace-runner) BuildRequires: pkgconfig(sysman) BuildRequires: pkgconfig(app2sd) BuildRequires: pkgconfig(capi-system-system-settings) +BuildRequires: pkgconfig(libsmack) BuildRequires: libss-client-devel BuildRequires: gettext BuildRequires: edje-tools diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7c402fd..205267c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -18,10 +18,34 @@ # @version 1.0 # +# "smack-labeling-support-static" static library ------------------------------- +SET(SMACK_LABELING_SUPPORT_STATIC "smack-labeling-support-static") +PKG_CHECK_MODULES(SMACK_LABELING_SUPPORT_DEPS + dpl-efl + libsmack + REQUIRED +) +SET(SMACK_LABELING_SUPPORT_SOURCES + ${PROJECT_SOURCE_DIR}/src/wrt-client/process_pool/smack_labeling_support.cpp + ) +SET(SMACK_LABELING_SUPPORT_INCLUDES + ${PROJECT_SOURCE_DIR}/src/wrt-client/process_pool/ + ) +INCLUDE_DIRECTORIES( + ${SMACK_LABELING_SUPPORT_INCLUDES} + ${SMACK_LABELING_SUPPORT_DEPS_INCLUDE_DIRS} + ) +ADD_LIBRARY(${SMACK_LABELING_SUPPORT_STATIC} STATIC + ${SMACK_LABELING_SUPPORT_SOURCES} + ) +TARGET_LINK_LIBRARIES(${SMACK_LABELING_SUPPORT_STATIC} + ${SMACK_LABELING_SUPPORT_DEPS_LIBRARIES} + ) +# ------------------------------------------------------------------------------ + #it is here, so no INCLUDE_DIRS and DEFINITIONS are passed there ADD_SUBDIRECTORY(view) - SET(WRT_SRC_DIR ${PROJECT_SOURCE_DIR}/src ) diff --git a/src/api_new/CMakeLists.txt b/src/api_new/CMakeLists.txt index f5af14a..34b6668 100644 --- a/src/api_new/CMakeLists.txt +++ b/src/api_new/CMakeLists.txt @@ -36,6 +36,7 @@ PKG_CHECK_MODULES(CORE_MODULE_DEP PKG_CHECK_MODULES(SYS_CORE_MODULE_DEP ewebkit2 libprivilege-control + cert-svc REQUIRED ) diff --git a/src/api_new/ewk_context_manager.cpp b/src/api_new/ewk_context_manager.cpp index 9d3db72..3884276 100644 --- a/src/api_new/ewk_context_manager.cpp +++ b/src/api_new/ewk_context_manager.cpp @@ -22,6 +22,7 @@ */ #include +#include #include #include #include @@ -37,7 +38,6 @@ namespace WRT { static const std::string bundlePath("/usr/lib/libwrt-injected-bundle.so"); -static const std::string caCertPath("/opt/usr/share/certs/ca-certificate.crt"); EwkContextManager::EwkContextManager( const std::string& tizenAppId, @@ -93,7 +93,12 @@ bool EwkContextManager::initialize() setNetworkProxy(); LogInfo("ewk_context_certificate_file_set() was called."); - ewk_context_certificate_file_set(m_ewkContext, caCertPath.c_str()); + const char* caCertPath = cert_svc_get_certificate_crt_file_path(); + if (caCertPath) { + ewk_context_certificate_file_set(m_ewkContext, caCertPath); + } else { + LogError("cert path is null"); + } // set local stroage database path WrtDB::WidgetDAOReadOnly dao(DPL::FromUTF8String(m_appId)); @@ -101,12 +106,6 @@ bool EwkContextManager::initialize() m_ewkContext, dao.getPrivateLocalStoragePath().c_str()); - // memory saving mode - //ewk_context_memory_saving_mode_set( - // m_ewkContext, - // static_cast(result) == - // WrtDB::SETTINGS_TYPE_ON ? EINA_TRUE : EINA_FALSE); - ewk_context_tizen_extensible_api_set( m_ewkContext, EWK_EXTENSIBLE_API_MEDIA_STREAM_RECORD, @@ -289,7 +288,6 @@ void EwkContextManager::messageFromInjectedBundleCallback( void* clientInfo) { LogDebug("enter"); - LogDebug("did recive message: " << name); EwkContextManager* This = static_cast(clientInfo); if (returnData) { @@ -302,7 +300,6 @@ void EwkContextManager::messageFromInjectedBundleCallback( void EwkContextManager::didStartDownloadCallback(const char* downloadUrl, void* data) { LogDebug("enter"); - LogDebug("download url: " << downloadUrl); EwkContextManager* This = static_cast(data); This->m_view->downloadData(downloadUrl); diff --git a/src/view/common/view_logic_storage_support.cpp b/src/view/common/view_logic_storage_support.cpp index ed720bd..c6cba82 100644 --- a/src/view/common/view_logic_storage_support.cpp +++ b/src/view/common/view_logic_storage_support.cpp @@ -40,6 +40,7 @@ static int removeFile(const char* path, const struct stat* /*sb*/, int tflag) { if (path == NULL) { LogError("Wrong input path"); + return 0; } LogDebug(path); std::string inputPath = path; diff --git a/src/view/webkit/injected-bundle/CMakeLists.txt b/src/view/webkit/injected-bundle/CMakeLists.txt index ce05e33..45d1215 100644 --- a/src/view/webkit/injected-bundle/CMakeLists.txt +++ b/src/view/webkit/injected-bundle/CMakeLists.txt @@ -49,7 +49,10 @@ SET(INJECTED_BUNDLE_INCLUDES ) ADD_DEFINITIONS(${INJECTED_BUNDLE_DEP_CFLAGS}) -INCLUDE_DIRECTORIES(${INJECTED_BUNDLE_INCLUDES}) +INCLUDE_DIRECTORIES( + ${INJECTED_BUNDLE_INCLUDES} + ${SMACK_LABELING_SUPPORT_INCLUDES} + ) ADD_LIBRARY(${TARGET_INJECTED_BUNDLE_LIB} SHARED ${INJECTED_BUNDLE_SOURCES} @@ -61,6 +64,7 @@ TARGET_LINK_LIBRARIES( ${TARGET_WRT_ENGINE_STATIC} ${TARGET_PLUGIN_MODULE_LIB} ${PROF_LIB} + ${SMACK_LABELING_SUPPORT_STATIC} ) # for encryption diff --git a/src/view/webkit/injected-bundle/injected_bundle_uri_handling.cpp b/src/view/webkit/injected-bundle/injected_bundle_uri_handling.cpp index b2ea952..a2aaae9 100644 --- a/src/view/webkit/injected-bundle/injected_bundle_uri_handling.cpp +++ b/src/view/webkit/injected-bundle/injected_bundle_uri_handling.cpp @@ -119,7 +119,7 @@ bool checkWARP(const char *url, const DPL::String& tizenId) bool checkWhitelist(const char *url) { - LogInfo("Check WhiteList"); + LogInfo("Check WhiteList for uri: " << url); if (url == NULL) { return true; } @@ -348,11 +348,20 @@ bool processMainResource(const DPL::String& inputURI, return true; } -bool processURIForPlugin(const char* url) +bool processURIForPlugin(const char* url, const DPL::String &tizenId) { if (!checkWhitelist(url)) { return false; } + DPL::OptionalString found = + W3CFileLocalization::getFilePathInWidgetPackageFromUrl( + tizenId, + DPL::FromUTF8String(std::string(url))); + if (found.IsNull()) { + LogDebug("Path not found within current locale in current widget"); + return false; + } + return true; } diff --git a/src/view/webkit/injected-bundle/injected_bundle_uri_handling.h b/src/view/webkit/injected-bundle/injected_bundle_uri_handling.h index f7705b9..73bc23a 100644 --- a/src/view/webkit/injected-bundle/injected_bundle_uri_handling.h +++ b/src/view/webkit/injected-bundle/injected_bundle_uri_handling.h @@ -37,7 +37,7 @@ bool processURI(const std::string& inputURI, bool processMainResource(const DPL::String& inputURI, const DPL::String& tizenId, WrtDB::WidgetSecurityModelVersion m_securityModelVersion); -bool processURIForPlugin(const char* url); +bool processURIForPlugin(const char* url, const DPL::String &tizenId); DPL::OptionalString localizeURI(const DPL::String& inputURI, const DPL::String& tizenId); std::string localizeURI(const std::string& inputURI, const std::string& tizenId); diff --git a/src/view/webkit/injected-bundle/wrt-injected-bundle.cpp b/src/view/webkit/injected-bundle/wrt-injected-bundle.cpp index 705c0c8..9ddd6d4 100644 --- a/src/view/webkit/injected-bundle/wrt-injected-bundle.cpp +++ b/src/view/webkit/injected-bundle/wrt-injected-bundle.cpp @@ -68,6 +68,7 @@ #include #include +#include // URI localization on WebProcess side #include "injected_bundle_uri_handling.h" @@ -461,6 +462,12 @@ void Bundle::didReceiveMessage(WKStringRef messageName, WKTypeRef messageBody) GetUserWidgetExecPath() + "/" + tzAppId; } + LogDebug("set_app_smack_label(" << appPath << ")"); + if (set_app_smack_label(appPath.c_str()) != 0) + { + LogError("set_app_smack_label() failed"); + } + LogDebug("set_app_privilege(" << appPath << ")"); set_app_privilege(tzPkgId.c_str(), PRIVILEGE_APP_TYPE, appPath.c_str()); } @@ -646,7 +653,9 @@ void Bundle::didCommitLoadForFrameCallback( } std::string urlStr = toString(url); - if (InjectedBundleURIHandling::processURIForPlugin(urlStr.c_str())) { + if (InjectedBundleURIHandling::processURIForPlugin(urlStr.c_str(), + This->m_widgetTizenId)) + { LogDebug("start plugin"); if(This->m_pageGlobalContext.find(page) != This->m_pageGlobalContext.end()) { diff --git a/src/view/webkit/view_logic.cpp b/src/view/webkit/view_logic.cpp index 3ed737d..75fdb66 100644 --- a/src/view/webkit/view_logic.cpp +++ b/src/view/webkit/view_logic.cpp @@ -172,7 +172,11 @@ std::mapsuspend.empty()) { m_cbs->suspend(true); @@ -368,7 +371,6 @@ void ViewLogic::resumeWidget() * elm_win_raise(m_window); * } */ - evas_object_focus_set(m_currentEwkView, EINA_TRUE); // call user callback if (!m_cbs->resume.empty()) { @@ -380,35 +382,53 @@ void ViewLogic::resetWidget() { LogInfo("Resetting Widget"); - // destory all webview - while (!m_ewkViewList.empty()) { - LogInfo("pop webview: " << m_ewkViewList.back()); - removeEwkView(m_ewkViewList.back()); - } - m_ewkViewList.clear(); + // handling case of WebProcess is locked + if (m_isPopupReplyWait) { + // resume web application + LogDebug("WebProcess is locked"); + if (m_currentEwkView) { + setEwkViewVisible(m_currentEwkView); + if (!m_isBackgroundSupport) { + resumeWebkit(m_currentEwkView); + } + } + // webview activated + elm_win_activate(m_window); - // create new webview - createEwkView(evas_object_evas_get(m_window)); - ewkClientInit(m_currentEwkView); - prepareEwkView(m_currentEwkView); + // call user callback + if (!m_cbs->reset.empty()) { + m_cbs->reset(false); + } + } else { + // reset web application + // destory all webview + while (!m_ewkViewList.empty()) { + LogInfo("pop webview: " << m_ewkViewList.back()); + removeEwkView(m_ewkViewList.back()); + } + m_ewkViewList.clear(); - // check if current url is service url for this tizen service - std::string url = - ViewModule::UriSupport::getUri(m_model, m_startUrl); + // create new webview + createEwkView(evas_object_evas_get(m_window)); + ewkClientInit(m_currentEwkView); + prepareEwkView(m_currentEwkView); - initializePluginLoading(); + // check if current url is service url for this tizen service + std::string url = + ViewModule::UriSupport::getUri(m_model, m_startUrl); - // webview activated - ewk_view_url_set(m_currentEwkView, url.c_str()); - elm_win_activate(m_window); - evas_object_focus_set(m_currentEwkView, EINA_TRUE); + initializePluginLoading(); + // webview activated + ewk_view_url_set(m_currentEwkView, url.c_str()); + elm_win_activate(m_window); - // call user callback - if (!m_cbs->reset.empty()) { - m_cbs->reset(true); - } - if (!m_cbs->bufferSet.empty()) { - m_cbs->bufferSet(m_currentEwkView); + // call user callback + if (!m_cbs->reset.empty()) { + m_cbs->reset(true); + } + if (!m_cbs->bufferSet.empty()) { + m_cbs->bufferSet(m_currentEwkView); + } } } @@ -898,7 +918,6 @@ void ViewLogic::loadFinishedCallback( LogDebug("loadFinishedCallback called"); Assert(data); ViewLogic* This = static_cast(data); - evas_object_focus_set(This->m_currentEwkView, EINA_TRUE); // Fill id/password const char* url = ewk_view_url_get(This->m_currentEwkView); @@ -2263,6 +2282,26 @@ Eina_Bool ViewLogic::orientationThresholdTimerCallback(void* data) return ECORE_CALLBACK_CANCEL; } +void ViewLogic::popupReplyWaitStart(void* data, + Evas_Object* /*obj*/, + void* /*eventInfo*/) +{ + LogInfo("called"); + Assert(data); + ViewLogic* This = static_cast(data); + This->m_isPopupReplyWait = true; +} + +void ViewLogic::popupReplyWaitFinish(void* data, + Evas_Object* /*obj*/, + void* /*eventInfo*/) +{ + LogInfo("called"); + Assert(data); + ViewLogic* This = static_cast(data); + This->m_isPopupReplyWait = false; +} + void ViewLogic::requestUrlBlocked(const std::string& blockedUrl) { LogInfo("enter"); diff --git a/src/view/webkit/view_logic.h b/src/view/webkit/view_logic.h index bc9bd80..3826a7e 100644 --- a/src/view/webkit/view_logic.h +++ b/src/view/webkit/view_logic.h @@ -266,6 +266,12 @@ class ViewLogic : public ViewModule::IViewModule static void mediacontrolRotateExit(void* data, Evas_Object* obj, void* eventInfo); + static void popupReplyWaitStart(void* data, + Evas_Object* obj, + void* eventInfo); + static void popupReplyWaitFinish(void* data, + Evas_Object* obj, + void* eventInfo); #ifdef MULTIPROCESS_SERVICE_SUPPORT_INLINE static int appServiceCallerIsKilled(void *data); @@ -320,6 +326,7 @@ class ViewLogic : public ViewModule::IViewModule int m_rotateAngle; int m_deferredRotateAngle; Ecore_Timer* m_orientationThresholdTimer; + bool m_isPopupReplyWait; std::unique_ptr m_schemeSupport; std::unique_ptr m_appsSupport; diff --git a/src/wrt-client/CMakeLists.txt b/src/wrt-client/CMakeLists.txt index 15f0fb9..b3b51a8 100644 --- a/src/wrt-client/CMakeLists.txt +++ b/src/wrt-client/CMakeLists.txt @@ -39,6 +39,7 @@ INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/src/api_new ${PROJECT_SOURCE_DIR}/src/wrt-launchpad-daemon/include ${CLIENT_DEP_INCLUDE_DIRS} + ${SMACK_LABELING_SUPPORT_INCLUDES} ) ADD_EXECUTABLE(${TARGET_WRT_CLIENT} @@ -48,6 +49,7 @@ ADD_EXECUTABLE(${TARGET_WRT_CLIENT} TARGET_LINK_LIBRARIES(${TARGET_WRT_CLIENT} ${CLIENT_DEP_LIBRARIES} ${TARGET_CORE_MODULE_LIB} + ${SMACK_LABELING_SUPPORT_STATIC} "-pie" ) diff --git a/src/wrt-client/process_pool/smack_labeling_support.cpp b/src/wrt-client/process_pool/smack_labeling_support.cpp new file mode 100644 index 0000000..8833960 --- /dev/null +++ b/src/wrt-client/process_pool/smack_labeling_support.cpp @@ -0,0 +1,205 @@ +/* + * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ +/** + * @file smack_labeling_support.cpp + * @author Tae-Jeong Lee (taejeong.lee@samsung.com) + * @version 0.1 + * @brief API to support smack labeling for whole threads in a process. + */ + +#include "smack_labeling_support.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define SMACK_LABEL_LEN 255 +#define FILE_MAX_LEN 1024 +#define MAX_RETRY_CNT 1000 +#define UID_ROOT 0 + +static char s_smack_label[SMACK_LABEL_LEN + 1] = {0,}; +static int s_waiting_task_cnt = 0; + +static int smack_set_label_for_tid(const char *label) +{ + int len, fd, ret; + char curren_path[FILE_MAX_LEN + 1] = {0,}; + + len = strnlen(label, SMACK_LABEL_LEN + 1); + + if (len > SMACK_LABEL_LEN) + { + return -1; + } + + snprintf(curren_path, sizeof(curren_path), "/proc/%d/attr/current", (int)syscall(__NR_gettid)); + + fd = open(curren_path, O_WRONLY); + + if (fd < 0) + { + return -1; + } + + ret = write(fd, label, len); + close(fd); + + return (ret < 0) ? -1 : 0; +} + +static void SIGUSR1_handler(int /*signo*/) +{ + if (smack_set_label_for_tid(s_smack_label) != 0) + { + LogError("## [tid:" << syscall(__NR_gettid) << "] smack_set_label_for_tid() failed! ##"); + } + s_waiting_task_cnt--; +} + +static int set_SIGUSR1_handler() +{ + if (signal(SIGUSR1, SIGUSR1_handler) == SIG_ERR) + { + LogError("## signal(SIGUSR1, SIGUSR1_handler) failed! ##"); + return -1; + } + + return 0; +} + +static int set_SIGUSR1_to_default() +{ + if (signal(SIGUSR1, SIG_DFL) == SIG_ERR) + { + LogError("## signal(SIGUSR1, SIG_ERR) failed! ##"); + return -1; + } + + return 0; +} + +static int send_SIGUSR1_to_threads() +{ + int ret; + DIR *dir; + struct dirent entry, *result; + char proc_self_task_path[FILE_MAX_LEN + 1] = {0, }; + + sprintf(proc_self_task_path, "/proc/self/task"); + + dir = opendir(proc_self_task_path); + + if (dir) + { + for (ret = readdir_r(dir, &entry, &result); + result != NULL && ret == 0; + ret = readdir_r(dir, &entry, &result)) + { + if (strncmp(entry.d_name, ".", 2) == 0 || + strncmp(entry.d_name, "..", 3) == 0) + { + continue; + } + + s_waiting_task_cnt++; + if (syscall(__NR_tkill, atoi(entry.d_name), SIGUSR1) != 0) + { + LogError("## tkill(" << atoi(entry.d_name) << "SIGUSR1) failed! ##"); + s_waiting_task_cnt--; + } + } + + closedir(dir); + } + else + { + LogError("## opendir(\"/proc/self/task\") failed! ##"); + return -1; + } + + return 0; +} + +int set_app_smack_label(const char* app_path) +{ + assert(s_waiting_task_cnt == 0); + + if (UID_ROOT != getuid() || app_path == NULL) + { + LogError("## parameter error! ##"); + return -1; + } + + // set SIGUSR1 signal handler + if (set_SIGUSR1_handler() != 0) + { + return -1; + } + + // get smack label from app_path + char *smack_label = NULL; + + if (smack_lgetlabel(app_path, &smack_label, SMACK_LABEL_EXEC) != 0) + { + LogError("## smack_lgetlabel() failed! ##"); + goto err_set_app_smack_label; + } + + strncpy(s_smack_label, smack_label, sizeof(s_smack_label)); + + if (send_SIGUSR1_to_threads() != 0) + { + LogError("## send_SIGUSR1_to_threads() timeout! ##"); + goto err_set_app_smack_label; + } + + // wait for labeling on each tasks + int i; + + for (i=0; s_waiting_task_cnt && i < MAX_RETRY_CNT; i++) + { + usleep(100); // 0.1ms + } + + if (i == MAX_RETRY_CNT) + { + LogError("## set_app_smack_label() timeout! ##"); + } + + // set SIGUSR1 signal defualt handler + set_SIGUSR1_to_default(); + + return 0; + +err_set_app_smack_label: + s_waiting_task_cnt = 0; + set_SIGUSR1_to_default(); + + return -1; +} + + diff --git a/src/wrt-client/process_pool/smack_labeling_support.h b/src/wrt-client/process_pool/smack_labeling_support.h new file mode 100644 index 0000000..09ef1a5 --- /dev/null +++ b/src/wrt-client/process_pool/smack_labeling_support.h @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ +/** + * @file smack_labeling_support.h + * @author Tae-Jeong Lee (taejeong.lee@samsung.com) + * @version 0.1 + * @brief API to support smack labeling for whole threads in a process. + */ + +#ifndef SMACK_LABELING_SUPPORT_H +#define SMACK_LABELING_SUPPORT_H + +int set_app_smack_label(const char* app_path); + +#endif // SMACK_LABELING_SUPPORT_H diff --git a/src/wrt-client/window_data.cpp b/src/wrt-client/window_data.cpp index acac622..1be14b6 100644 --- a/src/wrt-client/window_data.cpp +++ b/src/wrt-client/window_data.cpp @@ -94,6 +94,8 @@ void WindowData::init() evas_object_show(m_navigation); m_user_layout = createUserLayout(m_navigation); evas_object_show(m_user_layout); + m_focus = createFocus(m_user_layout); + evas_object_show(m_focus); m_progressbar = createProgressBar(m_win, m_user_layout); evas_object_show(m_progressbar); @@ -101,14 +103,15 @@ void WindowData::init() m_initialized = true; } -void WindowData::setEvasObjectForLayout(Evas_Object* evas_object) +void WindowData::setEvasObjectForLayout(Evas_Object* obj) { - elm_object_content_set(m_conformant, evas_object); + elm_object_part_content_set(m_focus, ELM_SWALLOW_CONTENT, obj); + elm_object_focus_set(m_focus, EINA_TRUE); } void WindowData::unsetEvasObjectForLayout() { - elm_object_content_unset(m_conformant); + elm_object_part_content_unset(m_focus, ELM_SWALLOW_CONTENT); } void WindowData::toggleIndicator(bool fullscreen) @@ -248,10 +251,25 @@ Evas_Object* WindowData::createUserLayout(Evas_Object* parent) NULL); ADD_PROFILING_POINT("elm_naviframe_item_push", "stop"); elm_naviframe_item_title_visible_set(naviIt, EINA_FALSE); - return layout; } +Evas_Object* WindowData::createFocus(Evas_Object* parent) +{ + Assert(parent != NULL && "Parent for Focus is null"); + // ewkview isn't elementary widget style. This is reason why ewkview focus + // doesn't restore after focus-out and focus-in. To support focus restore + // for ewkview, WRT add selectable elementary(button) to manage focus + Evas_Object* focus = elm_button_add(parent); + elm_object_style_set(focus, "focus"); + elm_object_part_content_set(parent, ELM_SWALLOW_CONTENT, focus); + evas_object_size_hint_weight_set(focus, + EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(focus, EVAS_HINT_FILL, EVAS_HINT_FILL); + return focus; +} + Evas_Object* WindowData::createProgressBar(Evas_Object* window, Evas_Object* parent) { Assert(parent != NULL && "Parent is null"); @@ -342,6 +360,23 @@ void* WindowData::userlayoutCallbackDel( return evas_object_event_callback_del(m_user_layout, event, callBack); } +void WindowData::focusCallbackAdd( + const char* event, + CallbackType callback, + const void* data) +{ + Assert(m_focus != NULL && "m_focus is null"); + evas_object_smart_callback_add(m_focus, event, callback, data); +} + +void* WindowData::focusCallbackDel( + const char* event, + CallbackType callback) +{ + Assert(m_focus != NULL && "m_focus is null"); + return evas_object_smart_callback_del(m_focus, event, callback); +} + void WindowData::emitSignalForUserLayout( const char* emission, const char* source) { diff --git a/src/wrt-client/window_data.h b/src/wrt-client/window_data.h index a45c8a3..44e5eeb 100644 --- a/src/wrt-client/window_data.h +++ b/src/wrt-client/window_data.h @@ -90,6 +90,13 @@ class WindowData : private DPL::Noncopyable void* userlayoutCallbackDel( const Evas_Callback_Type event, EvasCallbackType callback); + void focusCallbackAdd( + const char* event, + CallbackType callback, + const void* data); + void* focusCallbackDel( + const char* event, + CallbackType callback); void emitSignalForUserLayout( const char* emission, const char* source); @@ -109,6 +116,7 @@ class WindowData : private DPL::Noncopyable Evas_Object* m_conformant; Evas_Object* m_platform_layout; Evas_Object* m_navigation; + Evas_Object* m_focus; Evas_Object* m_floatBackButton; Evas_Object* m_progressbar; Evas_Object* m_ctxpopup; @@ -120,6 +128,7 @@ class WindowData : private DPL::Noncopyable Evas_Object* createPlatformLayout(Evas_Object* parent); Evas_Object* createNavigationBar(Evas_Object* parent); Evas_Object* createUserLayout(Evas_Object* parent); + Evas_Object* createFocus(Evas_Object* parent); Evas_Object* createProgressBar(Evas_Object* window, Evas_Object* parent); Evas_Object* createCtxPopup(Evas_Object* parent); diff --git a/src/wrt-client/wrt-client.cpp b/src/wrt-client/wrt-client.cpp index 7429412..581900b 100644 --- a/src/wrt-client/wrt-client.cpp +++ b/src/wrt-client/wrt-client.cpp @@ -37,9 +37,8 @@ #include #include "auto_rotation_support.h" -#include "process_pool.h" -#include "menu_db_util.h" -#include "launchpad_util.h" +#include +#include #include #include "client_service_support.h" @@ -57,7 +56,6 @@ const std::string VIEWMODE_TYPE_MAXIMIZED = "maximized"; const std::string VIEWMODE_TYPE_WINDOWED = "windowed"; char const* const ELM_SWALLOW_CONTENT = "elm.swallow.content"; const char* const BUNDLE_PATH = "/usr/lib/libwrt-injected-bundle.so"; -const char* const caCertPath = "/opt/usr/share/certs/ca-certificate.crt"; const char* const MESSAGE_NAME_INITIALIZE = "ToInjectedBundle::INIT"; // process pool @@ -411,6 +409,15 @@ void WrtClient::loadFinishCallback(Evas_Object* webview) delete debug; } +void WrtClient::resetCallback(bool result) +{ + if (!result) { + LogDebug("Fail to handle reset event"); + // free bundle data + ApplicationDataSingleton::Instance().freeBundle(); + } +} + void WrtClient::progressStartedCallback() { if (m_settingList->getProgressBarPresence() == ProgressBar_Enable || @@ -562,6 +569,8 @@ void WrtClient::launchStep() //you can't show window with splash screen before PrepareView //ewk_view_add_with_context() in viewLogic breaks window m_windowData->init(); + m_windowData->focusCallbackAdd("focused", focusedCallback, this); + m_windowData->focusCallbackAdd("unfocused", unfocusedCallback, this); WrtDB::WidgetLocalizedInfo localizedInfo = W3CFileLocalization::getLocalizedInfo(m_dao); @@ -590,6 +599,7 @@ void WrtClient::launchStep() cbs->progress = DPL::MakeDelegate(this, &WrtClient::loadProgressCallback); cbs->progressFinish = DPL::MakeDelegate(this, &WrtClient::progressFinishCallback); cbs->loadFinish = DPL::MakeDelegate(this, &WrtClient::loadFinishCallback); + cbs->reset = DPL::MakeDelegate(this, &WrtClient::resetCallback); cbs->bufferSet = DPL::MakeDelegate(this, &WrtClient::setLayout); cbs->bufferUnset = DPL::MakeDelegate(this, &WrtClient::unsetLayout); cbs->webkitExit = DPL::MakeDelegate(this, &WrtClient::webkitExitCallback); @@ -836,11 +846,7 @@ void WrtClient::setLayout(Evas_Object* newBuffer) { LogDebug("add new webkit buffer to window"); Assert(newBuffer); - - elm_object_part_content_set(m_windowData->m_user_layout, - ELM_SWALLOW_CONTENT, - newBuffer); - + m_windowData->setEvasObjectForLayout(newBuffer); evas_object_show(newBuffer); } @@ -849,9 +855,7 @@ void WrtClient::unsetLayout(Evas_Object* currentBuffer) LogDebug("remove current webkit buffer from window"); Assert(currentBuffer); evas_object_hide(currentBuffer); - - elm_object_part_content_unset(m_windowData->m_user_layout, - ELM_SWALLOW_CONTENT); + m_windowData->unsetEvasObjectForLayout(); } void WrtClient::shutdownStep() @@ -872,6 +876,8 @@ void WrtClient::shutdownStep() if (m_initialized) { m_initialized = false; } + m_windowData->focusCallbackDel("focused", focusedCallback); + m_windowData->focusCallbackDel("unfocused", unfocusedCallback); m_windowData.reset(); Quit(); } @@ -888,6 +894,26 @@ void WrtClient::autoRotationCallback(void* data, Evas_Object* obj, void* /*event This->autoRotationSetOrientation(obj); } +void WrtClient::focusedCallback(void* data, + Evas_Object* /*obj*/, + void* /*eventInfo*/) +{ + LogInfo("entered"); + Assert(data); + WrtClient* This = static_cast(data); + elm_object_focus_set(This->m_widget->GetCurrentWebview(), EINA_TRUE); +} + +void WrtClient::unfocusedCallback(void* data, + Evas_Object* /*obj*/, + void* /*eventInfo*/) +{ + LogInfo("entered"); + Assert(data); + WrtClient* This = static_cast(data); + elm_object_focus_set(This->m_widget->GetCurrentWebview(), EINA_FALSE); +} + void WrtClient::autoRotationSetOrientation(Evas_Object* obj) { LogInfo("entered"); @@ -971,7 +997,7 @@ static Eina_Bool proces_pool_fd_handler(void* /*data*/, Ecore_Fd_Handler *handle ecore_main_fd_handler_del(handler); - __wrt_launchpad_main_loop(pkt, app_argv[0], &app_argc, &app_argv); + process_pool_launchpad_main_loop(pkt, app_argv[0], &app_argc, &app_argv); free(pkt); } @@ -1100,6 +1126,7 @@ int main(int argc, s_preparedEwkContext, MESSAGE_NAME_INITIALIZE, tizenId.c_str()); + } else { diff --git a/src/wrt-client/wrt-client.h b/src/wrt-client/wrt-client.h index 871edde..6f5c238 100644 --- a/src/wrt-client/wrt-client.h +++ b/src/wrt-client/wrt-client.h @@ -87,6 +87,12 @@ class WrtClient : static int appcoreLowMemoryCallback(void* data); static int languageChangedCallback(void *data); static void autoRotationCallback(void* data, Evas_Object* obj, void* event); + static void focusedCallback(void* data, + Evas_Object* obj, + void* eventInfo); + static void unfocusedCallback(void* data, + Evas_Object* obj, + void* eventInfo); //view-mode void setInitialViewMode(); @@ -111,6 +117,7 @@ class WrtClient : void launchStep(); void shutdownStep(); void loadFinishCallback(Evas_Object* webview); + void resetCallback(bool result); void progressStartedCallback(); void loadProgressCallback(Evas_Object* webview, double value); void progressFinishCallback(); diff --git a/src/wrt-launchpad-daemon/include/launchpad_util.h b/src/wrt-launchpad-daemon/include/launchpad_util.h index 7df4776..26edc7e 100644 --- a/src/wrt-launchpad-daemon/include/launchpad_util.h +++ b/src/wrt-launchpad-daemon/include/launchpad_util.h @@ -51,11 +51,8 @@ _static_ int __parser(const char *arg, char *out, int out_size); _static_ void __modify_bundle(bundle * kb, int caller_pid, app_info_from_db * menu_info, int cmd); _static_ void __set_oom(); _static_ void __set_env(app_info_from_db * menu_info, bundle * kb); -_static_ int __wrt_prepare_exec(const char *pkg_name, const char *app_path, app_info_from_db * menu_info, bundle * kb); -_static_ void __wrt_launchpad_main_loop(app_pkt_t* pkt, char* out_app_path, int* out_argc, char ***out_argv); // Implementation - _static_ char** __create_argc_argv(bundle * kb, int *margc) { char **argv; @@ -297,114 +294,4 @@ _static_ void __set_env(app_info_from_db * menu_info, bundle * kb) } } -_static_ int __wrt_prepare_exec(const char *pkg_name, - const char *app_path, app_info_from_db * menu_info, - bundle * kb) -{ - const char *file_name; - char process_name[WRT_AUL_PR_NAME]; - - /* SET PRIVILEGES*/ - char pkg_id[PKG_ID_LENGTH]; - memset(pkg_id, '\0', PKG_ID_LENGTH); - snprintf(pkg_id, PKG_ID_LENGTH, "%s", pkg_name); - - if (__set_access(pkg_id, menu_info->pkg_type, app_path) < 0) { - _D("fail to set privileges - check your package's credential\n"); - return -1; - } - - /* SET PROCESS NAME*/ - if (app_path == NULL) { - _D("app_path should not be NULL - check menu db"); - return -1; - } - file_name = strrchr(app_path, '/') + 1; - if (file_name == NULL) { - _D("can't locate file name to execute"); - return -1; - } - memset(process_name, '\0', WRT_AUL_PR_NAME); - snprintf(process_name, WRT_AUL_PR_NAME, "%s", file_name); - prctl(PR_SET_NAME, process_name); - - /* SET ENVIROMENT*/ - __set_env(menu_info, kb); - - return 0; -} - -_static_ void __wrt_launchpad_main_loop(app_pkt_t* pkt, char* out_app_path, int* out_argc, char ***out_argv) - -{ - bundle *kb = NULL; - app_info_from_db *menu_info = NULL; - - const char *pkg_name = NULL; - const char *app_path = NULL; - - kb = bundle_decode(pkt->data, pkt->len); - if (!kb) { - _E("bundle decode error"); - exit(-1); - } - - pkg_name = bundle_get_val(kb, AUL_K_PKG_NAME); - SECURE_LOGD("pkg name : %s", pkg_name); - - menu_info = _get_app_info_from_bundle_by_pkgname(pkg_name, kb); - if (menu_info == NULL) { - _D("such pkg no found"); - exit(-1); - } - - app_path = _get_app_path(menu_info); - - if (app_path == NULL) { - _E("app_path is NULL"); - exit(-1); - } - - if (app_path[0] != '/') { - _E("app_path is not absolute path"); - exit(-1); - } - - __modify_bundle(kb, /*cr.pid - unused parameter*/ 0, menu_info, pkt->cmd); - pkg_name = _get_pkgname(menu_info); - SECURE_LOGD("pkg name : %s", pkg_name); - - __wrt_prepare_exec(pkg_name, app_path, menu_info, kb); - - if (out_app_path != NULL && out_argc != NULL && out_argv != NULL) - { - int i; - - sprintf(out_app_path, "%s", app_path); - - *out_argv = __create_argc_argv(kb, out_argc); - (*out_argv)[0] = out_app_path; - - for (i = 0; i < *out_argc; i++) - { - _D("input argument %d : %s##", i, (*out_argv)[i]); - } - } - else - { - exit(-1); - } - - -#if 0 // intentional - if (menu_info != NULL) { - _free_app_info_from_db(menu_info); - } - - if (kb != NULL) { - bundle_free(kb); - } -#endif -} - #endif // __LAUNCHPAD_UTIL_H_ diff --git a/src/wrt-launchpad-daemon/include/process_pool_launchpad_util.h b/src/wrt-launchpad-daemon/include/process_pool_launchpad_util.h new file mode 100644 index 0000000..0026e2b --- /dev/null +++ b/src/wrt-launchpad-daemon/include/process_pool_launchpad_util.h @@ -0,0 +1,149 @@ +/* + * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ +/** + * @file process_pool_launchpad_util.h + * @author Tae-Jeong Lee (taejeong.lee@samsung.com) + * @version 0.1 + * @brief Api library to support launchpad operation. + */ + +#ifndef __PROCESS_POOL_LAUNCHPAD_UTIL_H_ +#define __PROCESS_POOL_LAUNCHPAD_UTIL_H_ + +#include +#include + +// Prototype +_static_ int __process_pool_prepare_exec(const char *pkg_name, const char *app_path, app_info_from_db * menu_info, bundle * kb); +_static_ void process_pool_launchpad_main_loop(app_pkt_t* pkt, char* out_app_path, int* out_argc, char ***out_argv); + +// Implementation +_static_ int __process_pool_prepare_exec(const char *pkg_name, + const char *app_path, app_info_from_db * menu_info, + bundle * kb) +{ + const char *file_name; + char process_name[WRT_AUL_PR_NAME]; + + /* SET PRIVILEGES*/ + char pkg_id[PKG_ID_LENGTH]; + memset(pkg_id, '\0', PKG_ID_LENGTH); + snprintf(pkg_id, PKG_ID_LENGTH, "%s", pkg_name); + + if (set_app_smack_label(app_path) != 0) + { + _E("set_app_smack_label() failed"); + } + + if (__set_access(pkg_id, menu_info->pkg_type, app_path) < 0) { + _D("fail to set privileges - check your package's credential\n"); + return -1; + } + + /* SET PROCESS NAME*/ + if (app_path == NULL) { + _D("app_path should not be NULL - check menu db"); + return -1; + } + file_name = strrchr(app_path, '/') + 1; + if (file_name == NULL) { + _D("can't locate file name to execute"); + return -1; + } + memset(process_name, '\0', WRT_AUL_PR_NAME); + snprintf(process_name, WRT_AUL_PR_NAME, "%s", file_name); + prctl(PR_SET_NAME, process_name); + + /* SET ENVIROMENT*/ + __set_env(menu_info, kb); + + return 0; +} + +_static_ void process_pool_launchpad_main_loop(app_pkt_t* pkt, char* out_app_path, int* out_argc, char ***out_argv) + +{ + bundle *kb = NULL; + app_info_from_db *menu_info = NULL; + + const char *pkg_name = NULL; + const char *app_path = NULL; + + kb = bundle_decode(pkt->data, pkt->len); + if (!kb) { + _E("bundle decode error"); + exit(-1); + } + + pkg_name = bundle_get_val(kb, AUL_K_PKG_NAME); + SECURE_LOGD("pkg name : %s", pkg_name); + + menu_info = _get_app_info_from_bundle_by_pkgname(pkg_name, kb); + if (menu_info == NULL) { + _D("such pkg no found"); + exit(-1); + } + + app_path = _get_app_path(menu_info); + + if (app_path == NULL) { + _E("app_path is NULL"); + exit(-1); + } + + if (app_path[0] != '/') { + _E("app_path is not absolute path"); + exit(-1); + } + + __modify_bundle(kb, /*cr.pid - unused parameter*/ 0, menu_info, pkt->cmd); + pkg_name = _get_pkgname(menu_info); + SECURE_LOGD("pkg name : %s", pkg_name); + + __process_pool_prepare_exec(pkg_name, app_path, menu_info, kb); + + if (out_app_path != NULL && out_argc != NULL && out_argv != NULL) + { + int i; + + sprintf(out_app_path, "%s", app_path); + + *out_argv = __create_argc_argv(kb, out_argc); + (*out_argv)[0] = out_app_path; + + for (i = 0; i < *out_argc; i++) + { + _D("input argument %d : %s##", i, (*out_argv)[i]); + } + } + else + { + exit(-1); + } + + +#if 0 // intentional + if (menu_info != NULL) { + _free_app_info_from_db(menu_info); + } + + if (kb != NULL) { + bundle_free(kb); + } +#endif +} + +#endif // __PROCESS_POOL_LAUNCHPAD_UTIL_H_ \ No newline at end of file diff --git a/src/wrt-launchpad-daemon/legacy/preload.h b/src/wrt-launchpad-daemon/legacy/preload.h index a988f74..bca51d2 100644 --- a/src/wrt-launchpad-daemon/legacy/preload.h +++ b/src/wrt-launchpad-daemon/legacy/preload.h @@ -37,9 +37,6 @@ typedef struct handle_list_t { static inline void __preload_init(int argc, char **argv) { - char soname[MAX_LOCAL_BUFSZ] = { 0, }; - FILE *preload_list; - int (*func)() = NULL; int i; g_argc = argc; diff --git a/wrt_env.sh b/wrt_env.sh index a751121..a489dad 100644 --- a/wrt_env.sh +++ b/wrt_env.sh @@ -1,3 +1,3 @@ -export WRT_PROCESS_POOL_DISABLE=ON +#export WRT_PROCESS_POOL_DISABLE=ON #export WRT_WILL_SEND_REQUEST_LOG_ENABLE=ON #export WRT_LOAD_PLUGINS_LOG_ENABLE=ON -- 2.7.4