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 #include "web_storage_ffi.h"
17
18 #include "nweb_helper.h"
19 #include "nweb_init_params.h"
20 #include "web_storage.h"
21
22 using namespace OHOS::FFI;
23 using namespace OHOS::NWeb;
24
25 namespace OHOS {
26 namespace Webview {
27 extern "C" {
28 // web_storage
FfiWebStorageDeleteOrigin(char * corigin)29 int32_t FfiWebStorageDeleteOrigin(char* corigin)
30 {
31 std::string origin(corigin);
32 return OHOS::NWeb::WebStorage::CJdeleteOrigin(origin);
33 }
34
FfiWebStorageDeleteAllData(bool incognito)35 void FfiWebStorageDeleteAllData(bool incognito)
36 {
37 OHOS::NWeb::WebStorage::CJdeleteAllData(incognito);
38 }
39
FfiWebStorageGetOriginQuota(char * corigin,int32_t * errCode)40 int64_t FfiWebStorageGetOriginQuota(char* corigin, int32_t* errCode)
41 {
42 std::string origin(corigin);
43 return OHOS::NWeb::WebStorage::CjGetOriginUsageOrQuota(origin, errCode, true);
44 }
45
FfiWebStorageGetOriginUsage(char * corigin,int32_t * errCode)46 int64_t FfiWebStorageGetOriginUsage(char* corigin, int32_t* errCode)
47 {
48 std::string origin(corigin);
49 return OHOS::NWeb::WebStorage::CjGetOriginUsageOrQuota(origin, errCode, false);
50 }
51
FfiWebStorageGetOrigins(int32_t * errCode)52 CArrWebStorageOrigin FfiWebStorageGetOrigins(int32_t* errCode)
53 {
54 return OHOS::NWeb::WebStorage::CjGetOrigins(errCode);
55 }
56 }
57 } // namespace Webview
58 } // namespace OHOS