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_APP_MODULE_CHECKER_H 17 #define OHOS_FORM_FWK_APP_MODULE_CHECKER_H 18 19 #include <unordered_map> 20 #include <unordered_set> 21 22 #include "module_checker_delegate.h" 23 24 namespace { 25 constexpr int32_t EXTENSION_TYPE_UNKNOWN = 255; 26 } 27 28 /** 29 * @brief Form module load checker. check whether module can be loaded in form 30 * 31 */ 32 class AppModuleChecker : public ModuleCheckerDelegate { 33 public: AppModuleChecker(int32_t extensionType,std::unordered_map<int32_t,std::unordered_set<std::string>> && blocklist)34 AppModuleChecker(int32_t extensionType, std::unordered_map<int32_t, std::unordered_set<std::string>> &&blocklist) 35 : processExtensionType_(extensionType), moduleBlocklist_(std::move(blocklist)) {} 36 ~AppModuleChecker() override = default; 37 38 bool CheckModuleLoadable(const char* moduleName, 39 std::unique_ptr<ApiAllowListChecker>& apiAllowListChecker) override; 40 bool DiskCheckOnly() override; 41 protected: 42 int32_t processExtensionType_{EXTENSION_TYPE_UNKNOWN}; 43 std::unordered_map<int32_t, std::unordered_set<std::string>> moduleBlocklist_; 44 }; 45 46 #endif /* OHOS_FORM_FWK_APP_MODULE_CHECKER_H */