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 #include <unistd.h>
16
17 #include "napi/native_api.h"
18 #include "napi/native_node_api.h"
19 #include "napi_geolocation_permission.h"
20 #include "napi_native_media_player.h"
21 #include "napi_web_adsblock_manager.h"
22 #include "napi_web_async_controller.h"
23 #include "napi_webview_controller.h"
24 #include "napi_webview_function.h"
25 #include "napi_web_cookie_manager.h"
26 #include "napi_web_data_base.h"
27 #include "napi_web_storage.h"
28
29 #include "napi_web_download_manager.h"
30 #include "napi_web_download_item.h"
31 #include "napi_web_download_delegate.h"
32 #include "napi_web_scheme_handler_request.h"
33 #include "napi_back_forward_cache_options.h"
34
35 namespace OHOS {
36 namespace NWeb {
37 EXTERN_C_START
WebViewExport(napi_env env,napi_value exports)38 static napi_value WebViewExport(napi_env env, napi_value exports)
39 {
40 NapiWebDataBase::Init(env, exports);
41 NapiWebStorage::Init(env, exports);
42 NapiWebAsyncController::Init(env, exports);
43 NapiWebviewController::Init(env, exports);
44 NapiWebCookieManager::Init(env, exports);
45 NapiGeolocationPermission::Init(env, exports);
46 NapiWebDownloadItem::Init(env, exports);
47 NapiWebDownloadManager::Init(env, exports);
48 NapiWebDownloadDelegate::Init(env, exports);
49 NapiWebSchemeHandlerRequest::Init(env, exports);
50 NapiWebSchemeHandlerResponse::Init(env, exports);
51 NapiWebSchemeHandler::Init(env, exports);
52 NapiWebAdsBlockManager::Init(env, exports);
53 WebFunctionInit(env, exports);
54 NapiNativeMediaPlayerHandler::Init(env, exports);
55 NapiBackForwardCacheOptions::Init(env, exports);
56 NapiBackForwardCacheSupportedFeatures::Init(env, exports);
57 return exports;
58 }
59 EXTERN_C_END
60
61 /*
62 * module define
63 */
64 static napi_module _module = {
65 .nm_version = 1,
66 .nm_flags = 0,
67 .nm_filename = nullptr,
68 .nm_register_func = WebViewExport,
69 .nm_modname = "web.webview",
70 .nm_priv = ((void *)0),
71 .reserved = {0}
72 };
73
74 /*
75 * module register
76 */
Register()77 extern "C" __attribute__((constructor)) void Register()
78 {
79 napi_module_register(&_module);
80 }
81 } // namespace NWeb
82 } // namesapce OHOS
83