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 "napi_back_forward_cache_options.h"
17 
18 #include <js_native_api.h>
19 #include <js_native_api_types.h>
20 #include <napi/native_api.h>
21 #include <securec.h>
22 
23 #include "business_error.h"
24 #include "nweb_log.h"
25 #include "napi_parse_utils.h"
26 #include "napi/native_node_api.h"
27 #include "web_errors.h"
28 
29 using namespace OHOS::NWebError;
30 
31 namespace OHOS {
32 namespace NWeb {
33 
34 const std::string BACK_FORWARD_CACHE_OPTIONS = "BackForwardCacheOptions";
35 const std::string BACK_FORWARD_CACHE_SUPPORTED_FEATURES = "BackForwardCacheSupportedFeatures";
36 
JS_Constructor(napi_env env,napi_callback_info info)37 napi_value NapiBackForwardCacheOptions::JS_Constructor(napi_env env, napi_callback_info info)
38 {
39     napi_value thisVar = nullptr;
40     void *data = nullptr;
41     napi_get_cb_info(env, info, nullptr, nullptr, &thisVar, &data);
42 
43     return thisVar;
44 }
45 
JS_Constructor(napi_env env,napi_callback_info info)46 napi_value NapiBackForwardCacheSupportedFeatures::JS_Constructor(napi_env env, napi_callback_info info)
47 {
48     napi_value thisVar = nullptr;
49     void *data = nullptr;
50     napi_get_cb_info(env, info, nullptr, nullptr, &thisVar, &data);
51 
52     return thisVar;
53 }
54 
Init(napi_env env,napi_value exports)55 napi_value NapiBackForwardCacheOptions::Init(napi_env env, napi_value exports)
56 {
57     WVLOG_D("NapiBackForwardCacheOptions::Init");
58     napi_value backForwardCacheOptions = nullptr;
59     napi_define_class(env, BACK_FORWARD_CACHE_OPTIONS.c_str(),
60         BACK_FORWARD_CACHE_OPTIONS.length(),
61         JS_Constructor, nullptr, 0, nullptr, &backForwardCacheOptions);
62     napi_set_named_property(env, exports, BACK_FORWARD_CACHE_OPTIONS.c_str(),
63         backForwardCacheOptions);
64     return exports;
65 }
66 
Init(napi_env env,napi_value exports)67 napi_value NapiBackForwardCacheSupportedFeatures::Init(napi_env env, napi_value exports)
68 {
69     WVLOG_D("NapiBackForwardCacheSupportedFeatures::Init");
70     napi_value backForwardCacheSupportedFeatures = nullptr;
71     napi_define_class(env, BACK_FORWARD_CACHE_SUPPORTED_FEATURES.c_str(),
72         BACK_FORWARD_CACHE_SUPPORTED_FEATURES.length(),
73         JS_Constructor, nullptr, 0, nullptr, &backForwardCacheSupportedFeatures);
74     napi_set_named_property(env, exports, BACK_FORWARD_CACHE_SUPPORTED_FEATURES.c_str(),
75         backForwardCacheSupportedFeatures);
76     return exports;
77 }
78 
79 }
80 }