• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 NWEB_NAPI_GEOLOCATION_PERMISSION_H
17 #define NWEB_NAPI_GEOLOCATION_PERMISSION_H
18 
19 #include <cstddef>
20 #include <iosfwd>
21 #include <string>
22 
23 #include "napi/native_api.h"
24 #include "napi/native_node_api.h"
25 
26 namespace OHOS {
27 namespace NWeb {
28 class NapiGeolocationPermission {
29 public:
NapiGeolocationPermission()30     NapiGeolocationPermission() {}
31 
32     ~NapiGeolocationPermission() = default;
33 
34     static napi_value Init(napi_env env, napi_value exports);
35 
36 private:
37     static napi_value ProcessActionByType(napi_env env, napi_callback_info info, int32_t operationType);
38 
39     static napi_value JsAllowGeolocation(napi_env env, napi_callback_info info);
40 
41     static napi_value JsDeleteGeolocation(napi_env env, napi_callback_info info);
42 
43     static napi_value JsDeleteAllGeolocation(napi_env env, napi_callback_info info);
44 
45     static void GetPermissionStateComplete(napi_env env, napi_status status, void *data);
46 
47     static void GetPermissionStatePromiseComplete(napi_env env, napi_status status, void *data);
48 
49     static void ExecuteGetPermissionState(napi_env env, void *data);
50 
51     static napi_value GetPermissionStateAsync(napi_env env, napi_value *argv, const std::string& origin);
52 
53     static napi_value GetPermissionStatePromise(napi_env env, napi_value *argv, const std::string& origin);
54 
55     static napi_value JsGetAccessibleGeolocation(napi_env env, napi_callback_info info);
56 
57     static void GetOriginComplete(napi_env env, napi_status status, void *data);
58 
59     static void GetOriginsPromiseComplete(napi_env env, napi_status status, void *data);
60 
61     static void ExecuteGetOrigins(napi_env env, void *data);
62 
63     static napi_value GetOriginsAsync(napi_env env, napi_value *argv);
64 
65     static napi_value GetOriginsPromise(napi_env env);
66 
67     static napi_value JsGetStoredGeolocation(napi_env env, napi_callback_info info);
68 
69     static napi_value JsConstructor(napi_env env, napi_callback_info info);
70 
71     static bool GetStringPara(napi_env env, napi_value argv, std::string& outValue);
72 };
73 } // namespace NWeb
74 } // namespace OHOS
75 
76 #endif // NWEB_NAPI_GEOLOCATION_PERMISSION_H