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 #include "napi_proxy_controller.h"
36 #include "napi_proxy_config.h"
37 #include "napi_proxy_rule.h"
38
39 namespace OHOS {
40 namespace NWeb {
41 EXTERN_C_START
WebViewExport(napi_env env,napi_value exports)42 static napi_value WebViewExport(napi_env env, napi_value exports)
43 {
44 NapiWebDataBase::Init(env, exports);
45 NapiWebStorage::Init(env, exports);
46 NapiWebAsyncController::Init(env, exports);
47 NapiWebviewController::Init(env, exports);
48 NapiWebCookieManager::Init(env, exports);
49 NapiGeolocationPermission::Init(env, exports);
50 NapiWebDownloadItem::Init(env, exports);
51 NapiWebDownloadManager::Init(env, exports);
52 NapiWebDownloadDelegate::Init(env, exports);
53 NapiWebSchemeHandlerRequest::Init(env, exports);
54 NapiWebSchemeHandlerResponse::Init(env, exports);
55 NapiWebSchemeHandler::Init(env, exports);
56 NapiWebAdsBlockManager::Init(env, exports);
57 WebFunctionInit(env, exports);
58 NapiNativeMediaPlayerHandler::Init(env, exports);
59 NapiBackForwardCacheOptions::Init(env, exports);
60 NapiBackForwardCacheSupportedFeatures::Init(env, exports);
61 NapiProxyController::Init(env, exports);
62 NapiProxyConfig::Init(env, exports);
63 NapiProxyRule::Init(env, exports);
64 return exports;
65 }
66 EXTERN_C_END
67
68 /*
69 * module define
70 */
71 static napi_module _module = {
72 .nm_version = 1,
73 .nm_flags = 0,
74 .nm_filename = nullptr,
75 .nm_register_func = WebViewExport,
76 .nm_modname = "web.webview",
77 .nm_priv = ((void *)0),
78 .reserved = {0}
79 };
80
81 /*
82 * module register
83 */
Register()84 extern "C" __attribute__((constructor)) void Register()
85 {
86 napi_module_register(&_module);
87 }
88 } // namespace NWeb
89 } // namesapce OHOS
90