mirror of
https://github.com/openharmony/ace_ace_engine.git
synced 2026-07-21 09:55:23 -04:00
@@ -288,6 +288,8 @@ void AceAbility::OnStart(const Want& want)
|
||||
aceResCfg.SetDeviceType(SystemProperties::GetDeviceType());
|
||||
container->SetResourceConfiguration(aceResCfg);
|
||||
container->SetPackagePathStr(resPath);
|
||||
container->SetBundlePath(abilityContext->GetBundleCodeDir());
|
||||
container->SetFilesDataPath(abilityContext->GetFilesDir());
|
||||
}
|
||||
container->SetWindowName(window->GetWindowName());
|
||||
SubwindowManager::GetInstance()->AddContainerId(window->GetWindowId(), abilityId_);
|
||||
|
||||
@@ -456,6 +456,8 @@ void UIContentImpl::CommonInitialize(OHOS::Rosen::Window* window, const std::str
|
||||
container->SetResourceConfiguration(aceResCfg);
|
||||
container->SetPackagePathStr(resPath);
|
||||
container->SetAssetManager(flutterAssetManager);
|
||||
container->SetBundlePath(context->GetBundleCodeDir());
|
||||
container->SetFilesDataPath(context->GetFilesDir());
|
||||
|
||||
if (window_->IsDecorEnable()) {
|
||||
LOGI("Container modal is enabled.");
|
||||
|
||||
@@ -147,6 +147,22 @@ public:
|
||||
return settings_;
|
||||
}
|
||||
|
||||
void SetBundlePath(const std::string& path) {
|
||||
bundlePath_ = path;
|
||||
}
|
||||
|
||||
const std::string& GetBundlePath() const {
|
||||
return bundlePath_;
|
||||
}
|
||||
|
||||
void SetFilesDataPath(const std::string& path) {
|
||||
filesDataPath_ = path;
|
||||
}
|
||||
|
||||
const std::string& GetFilesDataPath() const {
|
||||
return filesDataPath_;
|
||||
}
|
||||
|
||||
virtual void SetViewFirstUpdating(std::chrono::time_point<std::chrono::high_resolution_clock> time) {}
|
||||
|
||||
virtual void UpdateResourceConfiguration(const std::string& jsonStr) {}
|
||||
@@ -163,6 +179,8 @@ protected:
|
||||
|
||||
private:
|
||||
std::string moduleName_;
|
||||
std::string bundlePath_;
|
||||
std::string filesDataPath_;
|
||||
Settings settings_;
|
||||
ACE_DISALLOW_COPY_AND_MOVE(Container);
|
||||
};
|
||||
|
||||
@@ -657,7 +657,25 @@ void WebDelegate::InitWebEvent()
|
||||
void WebDelegate::InitOHOSWeb(const WeakPtr<PipelineContext>& context, sptr<Surface> surface)
|
||||
{
|
||||
state_ = State::CREATING;
|
||||
// obtain hap data path
|
||||
auto container = Container::Current();
|
||||
if (container == nullptr) {
|
||||
LOGE("Fail to get container");
|
||||
return;
|
||||
}
|
||||
const std::string& bundlePath = container->GetBundlePath();
|
||||
const std::string& filesDataPath = container->GetFilesDataPath();
|
||||
std::string baseDir = "base";
|
||||
std::size_t baseIndex = filesDataPath.find(baseDir);
|
||||
if (baseIndex == std::string::npos) {
|
||||
LOGE("Fail to parse hap data base path");
|
||||
return;
|
||||
}
|
||||
std::string dataPath = filesDataPath.substr(0, baseIndex + baseDir.length());
|
||||
bundlePath_ = bundlePath;
|
||||
bundleDataPath_ = dataPath;
|
||||
// load webview so
|
||||
OHOS::NWeb::NWebHelper::Instance().SetBundlePath(bundlePath_);
|
||||
if (!OHOS::NWeb::NWebHelper::Instance().Init()) {
|
||||
LOGE("Fail to init NWebHelper");
|
||||
return;
|
||||
@@ -992,10 +1010,10 @@ void WebDelegate::InitWebViewWithSurface(sptr<Surface> surface)
|
||||
return;
|
||||
}
|
||||
OHOS::NWeb::NWebInitArgs initArgs;
|
||||
const std::string& app_path = GetDataPath();
|
||||
if (!app_path.empty()) {
|
||||
initArgs.web_engine_args_to_add.push_back(std::string("--user-data-dir=").append(app_path));
|
||||
}
|
||||
initArgs.web_engine_args_to_add.push_back(
|
||||
std::string("--user-data-dir=").append(delegate->bundleDataPath_));
|
||||
initArgs.web_engine_args_to_add.push_back(
|
||||
std::string("--bundle-installation-dir=").append(delegate->bundlePath_));
|
||||
sptr<Surface> surface = surfaceWeak.promote();
|
||||
if (surface == nullptr) {
|
||||
LOGE("surface is nullptr or has expired");
|
||||
|
||||
@@ -241,6 +241,9 @@ private:
|
||||
EventCallbackV2 onDownloadStartV2_;
|
||||
EventCallbackV2 onFocusV2_;
|
||||
|
||||
std::string bundlePath_;
|
||||
std::string bundleDataPath_;
|
||||
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
@@ -1467,6 +1467,7 @@ private:
|
||||
std::unordered_map<int32_t, std::string> restoreNodeInfo_;
|
||||
|
||||
bool isSubPipeline_ = false;
|
||||
|
||||
ACE_DISALLOW_COPY_AND_MOVE(PipelineContext);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user