2 * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Flora License, Version 1.1 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 * @file AppBoxManager.cpp
18 * @author Yunchan Cho (yunchan.cho@samsung.com)
20 #include <core_module.h>
21 #include <Plugin/IBoxPluginFactory.h>
22 #include <Core/BoxData.h>
23 #include <Core/BoxManager.h>
24 #include <Core/IBox.h>
25 #include "AppBoxObserver.h"
26 #include "AppBoxManager.h"
28 static const std::string bundlePath("/usr/lib/libwrt-injected-bundle.so");
30 AppBoxManager::AppBoxManager(IBoxPluginFactoryPtr factory)
33 bool ret = WRT::CoreModuleSingleton::Instance().Init();
35 throw; // throw exeception
37 m_defaultEwkContext.reset(
38 ewk_context_new_with_injected_bundle_path(bundlePath.c_str()));
39 AppBoxObserver::Instance()->initialize();
42 AppBoxManager::~AppBoxManager()
44 AppBoxObserver::Instance()->shutdown();
45 WRT::CoreModuleSingleton::Instance().Terminate();
48 bool AppBoxManager::requestAddBox(BoxInfoPtr boxInfo, EwkContextPtr ewkContext)
50 ewkContext = getAvailableEwkContext();
51 if (!BoxManager::requestAddBox(boxInfo, ewkContext)) {
55 insertContextMap(ewkContext, boxInfo->instanceId);
59 bool AppBoxManager::requestRemoveBox(std::string& instanceId)
61 if (!BoxManager::requestRemoveBox(instanceId)) {
65 eraseContextMap(instanceId);
69 EwkContextPtr AppBoxManager::getAvailableEwkContext()
71 // TODO make proper Ewk_Context instance, and update context map
72 // std::shared_ptr<Ewk_Context> context(
74 // BoxManager::deleteDefaultEwkContext);
76 return m_defaultEwkContext;
79 void AppBoxManager::insertContextMap(EwkContextPtr ewkContext, std::string& instanceId)
84 void AppBoxManager::eraseContextMap(std::string& instanceId)