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_ABILITY_RUNTIME_EXTENSION_CONFIG_HANDLER_H 17 #define OHOS_ABILITY_RUNTIME_EXTENSION_CONFIG_HANDLER_H 18 19 #include <string> 20 #include <unordered_map> 21 #include <unordered_set> 22 23 #include "bundle_info.h" 24 #include "extension_ability_info.h" 25 #include "native_engine/native_engine.h" 26 27 namespace OHOS::AbilityRuntime { 28 namespace ExtensionConfigItem { 29 constexpr char ITEM_NAME_BLOCKLIST[] = "blocklist"; 30 } 31 32 /** 33 * @brief Manage extension configuration. 34 */ 35 class ExtensionConfigMgr { 36 public: 37 ExtensionConfigMgr() = default; 38 39 virtual ~ExtensionConfigMgr() = default; 40 41 /** 42 * @brief ExtensionConfigMgr initialization 43 * 44 */ 45 void Init(); 46 47 /** 48 * @brief Update bundle extension information 49 * 50 * @param engine JS NativeEngine 51 */ 52 void UpdateBundleExtensionInfo(NativeEngine &engine, AppExecFwk::BundleInfo &bundleInfo); 53 54 /** 55 * @brief Add extension blocklist item 56 * 57 * @param name Extension name 58 * @param type Extension type 59 */ 60 void AddBlockListItem(const std::string &name, int32_t type); 61 62 /** 63 * @brief Update extension blocklist to native engine 64 * 65 * @param engine JS NativeEngine 66 */ 67 void UpdateBlockListToEngine(NativeEngine &engine); 68 69 private: 70 std::unordered_map<std::string, std::unordered_set<std::string>> blocklistConfig_; 71 std::unordered_map<int32_t, std::unordered_set<std::string>> extensionBlocklist_; 72 }; 73 } // namespace OHOS::AbilityRuntime 74 75 #endif // OHOS_ABILITY_RUNTIME_EXTENSION_CONFIG_HANDLER_H 76