1 /*
2  * Copyright (c) 2024-2024 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 #ifndef OHOS_FORM_FWK_FORM_BUNDLE_FORBID_MGR_H
16 #define OHOS_FORM_FWK_FORM_BUNDLE_FORBID_MGR_H
17 
18 #include <map>
19 #include <shared_mutex>
20 #include <singleton.h>
21 #include <string>
22 
23 #include "want.h"
24 #include "form_rdb_data_mgr.h"
25 
26 namespace OHOS {
27 namespace AppExecFwk {
28 /**
29  * @class FormBundleForbidMgr
30  * Form bundle forbid manager.
31  */
32 class FormBundleForbidMgr final : public DelayedRefSingleton<FormBundleForbidMgr> {
33     DECLARE_DELAYED_REF_SINGLETON(FormBundleForbidMgr)
34 public:
35     DISALLOW_COPY_AND_MOVE(FormBundleForbidMgr);
36 
37     /**
38      * @brief Init form bundle forbid mgr.
39      * @return True fot sucessful init, false for failed init.
40      */
41     bool Init();
42 
43     /**
44      * @brief Get whether bundle is forbidden.
45      * @param bundleName Bundle name to be check.
46      * @return True fot forbidden, false for not forbidden.
47      */
48     bool IsBundleForbidden(const std::string &bundleName);
49 
50     /**
51      * @brief Set whether bundle is forbidden.
52      * @param bundleName Bundle name to be set.
53      * @param isForbidden True fot forbidden, false for not forbidden.
54      */
55     void SetBundleForbiddenStatus(const std::string &bundleName, bool isForbidden);
56 private:
57     bool isInitialized_ = false;
58     std::set<std::string> formBundleForbiddenSet_;
59     mutable std::shared_mutex bundleForbiddenSetMutex_;
60 };
61 }  // namespace AppExecFwk
62 }  // namespace OHOS
63 
64 #endif // OHOS_FORM_FWK_FORM_BUNDLE_FORBID_MGR_H
65