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 ARK_WEB_DATA_BASE_H_ 17 #define ARK_WEB_DATA_BASE_H_ 18 #pragma once 19 20 #include "base/include/ark_web_base_ref_counted.h" 21 #include "base/include/ark_web_types.h" 22 23 namespace OHOS::ArkWeb { 24 25 /*--ark web(source=webcore)--*/ 26 class ArkWebDataBase : public virtual ArkWebBaseRefCounted { 27 public: 28 /** 29 * @brief delete all specifies permission type. 30 * 31 * @param type specifies permission type. 32 * @param incognito true if web is in the incognito mode, flase otherwise. 33 */ 34 /*--ark web()--*/ 35 virtual void ClearAllPermission(int type, bool incognito) = 0; 36 37 /** 38 * @brief get username and password. 39 * 40 * @param host the host to which the credentials apply. 41 * @param realm the realm to which the credentials apply. 42 * @param user_name the username. 43 * @param password the password. 44 * @param password_size the password array size. 45 */ 46 /*--ark web()--*/ 47 virtual void GetHttpAuthCredentials(const ArkWebString& host, const ArkWebString& realm, ArkWebString& user_name, 48 char* password, uint32_t password_size) = 0; 49 50 /** 51 * @brief save http authentication credentials. 52 * 53 * @param host the host to which the credentials apply. 54 * @param realm the realm to which the credentials apply. 55 * @param username the user_name. 56 * @param password the password. 57 */ 58 /*--ark web()--*/ 59 virtual void SaveHttpAuthCredentials( 60 const ArkWebString& host, const ArkWebString& realm, const ArkWebString& user_name, const char* password) = 0; 61 62 /** 63 * @brief Get whether instances holds any http authentication credentials. 64 * 65 * @return true if instances saved any http authentication credentials. 66 */ 67 /*--ark web()--*/ 68 virtual bool ExistHttpAuthCredentials() = 0; 69 70 /** 71 * @brief clear all saved authentication credentials. 72 * 73 */ 74 /*--ark web()--*/ 75 virtual void DeleteHttpAuthCredentials() = 0; 76 77 /** 78 * @brief obtains all origins of a specified permission type. 79 * 80 * @param type specifies permission type. 81 * @param incognito true if web is in the incognito mode, flase otherwise. 82 * 83 * @return return all origin. 84 */ 85 /*--ark web()--*/ 86 virtual ArkWebStringVector GetOriginsByPermission(int type, bool incognito) = 0; 87 88 /** 89 * @brief get specifies permission type result by origin. 90 * 91 * @param origin url source. 92 * @param type specifies permission type. 93 * @param result saved result. 94 * @param incognito true if web is in the incognito mode, flase otherwise. 95 * 96 * @return return Whether there is a saved result. 97 */ 98 /*--ark web()--*/ 99 virtual bool GetPermissionByOrigin(const ArkWebString& origin, int type, bool& result, bool incognito) = 0; 100 101 /** 102 * @brief set specifies permission type result by origin. 103 * 104 * @param origin url source. 105 * @param type specifies permission type. 106 * @param result set result. 107 * @param incognito true if web is in the incognito mode, flase otherwise. 108 * 109 * @return 0 if successfully set specifies permission type result by origin 110 * other return error id. 111 */ 112 /*--ark web()--*/ 113 virtual int SetPermissionByOrigin(const ArkWebString& origin, int type, bool result, bool incognito) = 0; 114 115 /** 116 * @brief gets whether the instance holds the specified permissions for the 117 * specified source. 118 * 119 * @param origin url source. 120 * @param type specifies permission type. 121 * @param incognito true if web is in the incognito mode, flase otherwise. 122 * 123 * @return true if instances saved origin specified permissions. 124 */ 125 /*--ark web()--*/ 126 virtual bool ExistPermissionByOrigin(const ArkWebString& origin, int type, bool incognito) = 0; 127 128 /** 129 * @brief delete specifies permission type by origin. 130 * 131 * @param origin url source. 132 * @param type specifies permission type. 133 * @param incognito true if web is in the incognito mode, flase otherwise. 134 * 135 * @return 0 if successfully delete specifies permission type result by origin 136 * other return error id. 137 */ 138 /*--ark web()--*/ 139 virtual int ClearPermissionByOrigin(const ArkWebString& origin, int type, bool incognito) = 0; 140 }; 141 142 } // namespace OHOS::ArkWeb 143 144 #endif // ARK_WEB_DATA_BASE_H_ 145