1 /*
2  * Copyright (c) 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 
16 #ifndef OHOS_ABILITY_RUNTIME_URI_UTILS_H
17 #define OHOS_ABILITY_RUNTIME_URI_UTILS_H
18 
19 #include <string>
20 #include <vector>
21 
22 #include "ability_record.h"
23 #include "nocopyable.h"
24 #include "uri.h"
25 #include "want.h"
26 
27 namespace OHOS {
28 namespace AAFwk {
29 class UriUtils {
30 public:
31     static UriUtils &GetInstance();
32 
33     void FilterUriWithPermissionDms(Want &want, uint32_t tokenId);
34 
35     bool CheckNonImplicitShareFileUri(const AbilityRequest &abilityRequest);
36 
37     std::vector<Uri> GetPermissionedUriList(const std::vector<std::string> &uriVec,
38         const std::vector<bool> &checkResults, Want &want);
39 
40     bool GetUriListFromWant(Want &want, std::vector<std::string> &uriVec);
41 
42     bool IsGrantUriPermissionFlag(const Want &want);
43 
44     void CheckUriPermissionForServiceExtension(Want &want, AppExecFwk::ExtensionAbilityType extensionAbilityType);
45 
46     void CheckUriPermissionForUIExtension(Want &want, AppExecFwk::ExtensionAbilityType extensionAbilityType,
47         uint32_t tokenId = 0);
48 
49     bool IsPermissionPreCheckedType(AppExecFwk::ExtensionAbilityType extensionAbilityType);
50 private:
51     UriUtils();
52     ~UriUtils();
53 
54     std::vector<std::string> GetUriListFromWantDms(const Want &want);
55 
56     void CheckUriPermissionForExtension(Want &want, uint32_t tokenId);
57 
58     DISALLOW_COPY_AND_MOVE(UriUtils);
59 };
60 } // namespace AAFwk
61 } // namespace OHOS
62 #endif // OHOS_ABILITY_RUNTIME_URI_UTILS_H