X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2FPlugin%2FAppBoxPlugin%2FAppBoxManager.cpp;h=ea71ad13ab3513952940b7287a33d42ba329a953;hb=f643ede34758c7f17ad764651ce7461bca776af1;hp=539b956268fab4182b399c67a9c4deb24b7dd022;hpb=00c1db44f3aa098c3668306acaf8b4266523e9e9;p=platform%2Fframework%2Fweb%2Fweb-provider.git diff --git a/src/Plugin/AppBoxPlugin/AppBoxManager.cpp b/src/Plugin/AppBoxPlugin/AppBoxManager.cpp index 539b956..ea71ad1 100644 --- a/src/Plugin/AppBoxPlugin/AppBoxManager.cpp +++ b/src/Plugin/AppBoxPlugin/AppBoxManager.cpp @@ -1,11 +1,11 @@ /* * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved * - * Licensed under the Flora License, Version 1.0 (the "License"); + * Licensed under the Flora License, Version 1.1 (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.tizenopensource.org/license + * http://floralicense.org/license/ * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -17,15 +17,18 @@ * @file AppBoxManager.cpp * @author Yunchan Cho (yunchan.cho@samsung.com) */ +#include #include #include #include #include #include +#include +#include #include "AppBoxObserver.h" #include "AppBoxManager.h" -static const std::string bundlePath("/usr/lib/wrt-wk2-bundles/libwrt-wk2-bundle.so"); +static const std::string bundlePath("/usr/lib/libwrt-injected-bundle.so"); AppBoxManager::AppBoxManager(IBoxPluginFactoryPtr factory) : BoxManager(factory) @@ -34,8 +37,6 @@ AppBoxManager::AppBoxManager(IBoxPluginFactoryPtr factory) if (!ret) { throw; // throw exeception } - m_defaultEwkContext.reset( - ewk_context_new_with_injected_bundle_path(bundlePath.c_str())); AppBoxObserver::Instance()->initialize(); } @@ -47,12 +48,30 @@ AppBoxManager::~AppBoxManager() bool AppBoxManager::requestAddBox(BoxInfoPtr boxInfo, EwkContextPtr ewkContext) { - ewkContext = getAvailableEwkContext(); + + const char* appId = + web_provider_livebox_get_app_id(boxInfo->boxId.c_str()); + + if (!appId) { + LogD("no appid of %s", boxInfo->boxId.c_str()); + return false; + } + + std::string appIdStr(appId); + delete appId; + + auto it = m_ewkContextMap.find(appIdStr); + if (it == m_ewkContextMap.end()) { + ewkContext = getAvailableEwkContext(); + insertContextMap(appIdStr, ewkContext); + } else { + ewkContext = it->second; + } + if (!BoxManager::requestAddBox(boxInfo, ewkContext)) { return false; } - insertContextMap(ewkContext, boxInfo->instanceId); return true; } @@ -62,26 +81,22 @@ bool AppBoxManager::requestRemoveBox(std::string& instanceId) return false; } - eraseContextMap(instanceId); return true; } EwkContextPtr AppBoxManager::getAvailableEwkContext() { - // TODO make proper Ewk_Context instance, and update context map - // std::shared_ptr context( - // ewk_context_new(), - // BoxManager::deleteDefaultEwkContext); - - return m_defaultEwkContext; + return EwkContextPtr( + ewk_context_new_with_injected_bundle_path(bundlePath.c_str()), + BoxManager::EwkContextDeleter()); } -void AppBoxManager::insertContextMap(EwkContextPtr ewkContext, std::string& instanceId) +void AppBoxManager::insertContextMap(std::string& appId, EwkContextPtr ewkContext) { - // not implemented + m_ewkContextMap.insert(EwkContextMapPair(appId, ewkContext)); } -void AppBoxManager::eraseContextMap(std::string& instanceId) +void AppBoxManager::eraseContextMap(std::string& appId) { - // not implemented + m_ewkContextMap.erase(appId); }