1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef OHOS_FORM_FWK_FORM_MODULE_CHECKER_H 17 #define OHOS_FORM_FWK_FORM_MODULE_CHECKER_H 18 19 #include "module_checker_delegate.h" 20 21 /** 22 * @brief Form module load checker. check whether module can be loaded in form 23 * 24 */ 25 class FormModuleChecker : public ModuleCheckerDelegate { 26 public: 27 FormModuleChecker() = default; 28 ~FormModuleChecker() override = default; 29 30 /** 31 * @brief Check whether the module is allowed to be loaded in form 32 * @param moduleName module name 33 * @return return true if the module can be loaded, false can not be loaded 34 */ 35 bool CheckModuleLoadable(const char* moduleName, 36 std::unique_ptr<ApiAllowListChecker>& apiAllowListChecker, bool isAppModule) override; 37 38 bool DiskCheckOnly() override; 39 private: 40 static bool CheckApiAllowList(const std::string& apiPath); 41 static bool IsModuelAllowToLoad(const std::string& moduleName); 42 static bool CheckApiWithSuffix(const std::string& apiPath, const std::string& item); 43 static std::vector<std::string> GetModuleAllowList(); 44 static std::vector<std::string> modulesFromCfg_; 45 }; 46 #endif /* OHOS_FORM_FWK_FORM_MODULE_CHECKER_H */ 47