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 24 class OhosWebDataBaseAdapter { 25 public: 26 OhosWebDataBaseAdapter() = default; 27 28 virtual ~OhosWebDataBaseAdapter() = default; 29 30 virtual bool ExistHttpAuthCredentials() = 0; 31 32 virtual void DeleteHttpAuthCredentials() = 0; 33 34 virtual void SaveHttpAuthCredentials( 35 const std::string& host, const std::string& realm, const std::string& username, const char* password) = 0; 36 37 virtual void GetHttpAuthCredentials(const std::string& host, const std::string& realm, std::string& username, 38 char* password, uint32_t passwordSize) = 0; 39 }; 40 41 enum class WebPermissionType : int32_t { NONE_TYPE, GEOLOCATION }; 42 43 class OhosWebPermissionDataBaseAdapter { 44 public: 45 OhosWebPermissionDataBaseAdapter() = default; 46 47 virtual ~OhosWebPermissionDataBaseAdapter() = default; 48 49 virtual bool ExistPermissionByOrigin(const std::string& origin, const WebPermissionType& key) = 0; 50 51 virtual bool GetPermissionResultByOrigin(const std::string& origin, const WebPermissionType& key, bool& result) = 0; 52 53 virtual void SetPermissionByOrigin(const std::string& origin, const WebPermissionType& key, bool result) = 0; 54 55 virtual void ClearPermissionByOrigin(const std::string& origin, const WebPermissionType& key) = 0; 56 57 virtual void ClearAllPermission(const WebPermissionType& key) = 0; 58 59 virtual void GetOriginsByPermission(const WebPermissionType& key, std::vector<std::string>& origins) = 0; 60 }; 61 62 } // namespace OHOS::NWeb 63 64 #endif // OHOS_WEB_DATA_BASE_ADAPTER_H 65