1 /* 2 * Copyright (c) 2022 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_WEB_DATA_BASE_ADAPTER_H 17 #define OHOS_WEB_DATA_BASE_ADAPTER_H 18 19 #include <string> 20 #include <vector> 21 22 namespace OHOS::NWeb { 23 class OhosWebDataBaseAdapter { 24 public: 25 OhosWebDataBaseAdapter() = default; 26 27 virtual ~OhosWebDataBaseAdapter() = default; 28 29 virtual bool ExistHttpAuthCredentials() const = 0; 30 31 virtual void DeleteHttpAuthCredentials() = 0; 32 33 virtual void SaveHttpAuthCredentials(const std::string& host, const std::string& realm, 34 const std::string& username, const char* password) = 0; 35 36 virtual void GetHttpAuthCredentials(const std::string& host, const std::string& realm, 37 std::string& username, char* password, uint32_t passwordSize) const = 0; 38 }; 39 40 enum class WebPermissionType: int32_t { 41 NONE_TYPE, 42 GEOLOCATION 43 }; 44 45 class OhosWebPermissionDataBaseAdapter { 46 public: 47 OhosWebPermissionDataBaseAdapter() = default; 48 49 virtual ~OhosWebPermissionDataBaseAdapter() = default; 50 51 virtual bool ExistPermissionByOrigin(const std::string& origin, const WebPermissionType& key) const = 0; 52 53 virtual bool GetPermissionResultByOrigin(const std::string& origin, const WebPermissionType& key, 54 bool& result) const = 0; 55 56 virtual void SetPermissionByOrigin(const std::string& origin, const WebPermissionType& key, bool result) = 0; 57 58 virtual void ClearPermissionByOrigin(const std::string& origin, const WebPermissionType& key) = 0; 59 60 virtual void ClearAllPermission(const WebPermissionType& key) = 0; 61 62 virtual void GetOriginsByPermission(const WebPermissionType& key, std::vector<std::string>& origins) const = 0; 63 }; 64 65 class OhosWebDnsDataBaseAdapter { 66 public: 67 OhosWebDnsDataBaseAdapter() = default; 68 69 virtual ~OhosWebDnsDataBaseAdapter() = default; 70 71 virtual bool ExistHostname(const std::string& hostname) const = 0; 72 73 virtual void InsertHostname(const std::string& hostname) = 0; 74 75 virtual void GetHostnames(std::vector<std::string>& hostnames) const = 0; 76 77 virtual void ClearAllHostname() = 0; 78 }; 79 } // namespace OHOS::NWeb 80 #endif // OHOS_WEB_DATA_BASE_ADAPTER_H