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_IMPL_H 17 #define OHOS_WEB_DATA_BASE_ADAPTER_IMPL_H 18 19 #include "ohos_web_data_base_adapter.h" 20 21 #include <string> 22 23 #include "rdb_errno.h" 24 #include "rdb_helper.h" 25 #include "rdb_open_callback.h" 26 #include "rdb_store.h" 27 #include "rdb_store_config.h" 28 #include "rdb_types.h" 29 30 namespace OHOS::NWeb { 31 class DataBaseRdbOpenCallBack : public OHOS::NativeRdb::RdbOpenCallback { 32 public: 33 int32_t OnCreate(OHOS::NativeRdb::RdbStore& rdbStore) override; 34 35 int32_t OnUpgrade(OHOS::NativeRdb::RdbStore& rdbStore, int32_t currentVersion, int32_t targetVersion) override; 36 }; 37 38 class OhosWebDataBaseAdapterImpl : public OhosWebDataBaseAdapter { 39 public: 40 static OhosWebDataBaseAdapterImpl& GetInstance(); 41 42 ~OhosWebDataBaseAdapterImpl() override = default; 43 44 bool ExistHttpAuthCredentials() override; 45 46 void DeleteHttpAuthCredentials() override; 47 48 void SaveHttpAuthCredentials(const std::string& host, const std::string& realm, 49 const std::string& username, const char* password) override; 50 51 void GetHttpAuthCredentials(const std::string& host, const std::string& realm, 52 std::string& username, char* password, uint32_t passwordSize) override; 53 54 private: 55 OhosWebDataBaseAdapterImpl(); 56 57 OhosWebDataBaseAdapterImpl(const OhosWebDataBaseAdapterImpl& other) = delete; 58 59 OhosWebDataBaseAdapterImpl& operator=(const OhosWebDataBaseAdapterImpl&) = delete; 60 61 std::shared_ptr<OHOS::NativeRdb::RdbStore> rdbStore_; 62 }; 63 } // namespace 64 #endif // OHOS_WEB_DATA_BASE_ADAPTER_IMPL_H 65