10826e83eSopenharmony_ci/* 20826e83eSopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd. 30826e83eSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 40826e83eSopenharmony_ci * you may not use this file except in compliance with the License. 50826e83eSopenharmony_ci * You may obtain a copy of the License at 60826e83eSopenharmony_ci * 70826e83eSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 80826e83eSopenharmony_ci * 90826e83eSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 100826e83eSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 110826e83eSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 120826e83eSopenharmony_ci * See the License for the specific language governing permissions and 130826e83eSopenharmony_ci * limitations under the License. 140826e83eSopenharmony_ci */ 150826e83eSopenharmony_ci 160826e83eSopenharmony_ci#ifndef NWEB_CONFIG_HELPER_H 170826e83eSopenharmony_ci#define NWEB_CONFIG_HELPER_H 180826e83eSopenharmony_ci 190826e83eSopenharmony_ci#include "libxml/parser.h" 200826e83eSopenharmony_ci#include "libxml/tree.h" 210826e83eSopenharmony_ci#include "nweb_init_params.h" 220826e83eSopenharmony_ci#include "nweb_helper.h" 230826e83eSopenharmony_cinamespace OHOS::NWeb { 240826e83eSopenharmony_ci 250826e83eSopenharmony_ciclass OHOS_NWEB_EXPORT NWebConfigHelper { 260826e83eSopenharmony_cipublic: 270826e83eSopenharmony_ci static NWebConfigHelper &Instance(); 280826e83eSopenharmony_ci ~NWebConfigHelper() = default; 290826e83eSopenharmony_ci 300826e83eSopenharmony_ci void ParseConfig(std::shared_ptr<NWebEngineInitArgsImpl> initArgs); 310826e83eSopenharmony_ci void ReadConfigIfNeeded(); 320826e83eSopenharmony_ci std::string ParsePerfConfig(const std::string &configNodeName, const std::string &argsNodeName); 330826e83eSopenharmony_ci std::vector<FrameRateSetting> GetPerfConfig(const std::string& settingName); 340826e83eSopenharmony_ci bool IsLTPODynamicApp(const std::string& bundleName); 350826e83eSopenharmony_ci int32_t GetLTPOStrategy(); 360826e83eSopenharmony_ci 370826e83eSopenharmony_ciprivate: 380826e83eSopenharmony_ci NWebConfigHelper() = default; 390826e83eSopenharmony_ci std::string GetConfigPath(const std::string &configFileName); 400826e83eSopenharmony_ci void ParseNWebLTPOConfig(xmlNodePtr nodePtr); 410826e83eSopenharmony_ci void ReadConfig(const xmlNodePtr &rootPtr, std::shared_ptr<NWebEngineInitArgsImpl> initArgs); 420826e83eSopenharmony_ci xmlNodePtr GetChildrenNode(xmlNodePtr NodePtr, const std::string &childrenNodeName); 430826e83eSopenharmony_ci void ParsePerfConfig(xmlNodePtr NodePtr); 440826e83eSopenharmony_ci void ParseWebConfigXml(const std::string &configFilePath, std::shared_ptr<NWebEngineInitArgsImpl> initArgs); 450826e83eSopenharmony_ci void WriteConfigValueToSysPara(const std::string &configName, const std::string &value); 460826e83eSopenharmony_ci void ParseDeleteConfig(const xmlNodePtr &rootPtr, std::shared_ptr<NWebEngineInitArgsImpl> initArgs); 470826e83eSopenharmony_ci void ParseNWebLTPOApp(xmlNodePtr nodePtr); 480826e83eSopenharmony_ci void ParseNWebLTPOStrategy(xmlNodePtr nodePtr); 490826e83eSopenharmony_ci 500826e83eSopenharmony_ci std::map<std::string, std::string> perfConfig_; 510826e83eSopenharmony_ci std::map<std::string, std::vector<FrameRateSetting>> ltpoConfig_; 520826e83eSopenharmony_ci std::set<std::string> ltpoAllowedApps_ {}; 530826e83eSopenharmony_ci int32_t ltpoStrategy_ {0}; 540826e83eSopenharmony_ci}; 550826e83eSopenharmony_ci} // namespace OHOS 560826e83eSopenharmony_ci 570826e83eSopenharmony_ci#endif // NWEB_CONFIG_HELPER_H