1 /* 2 * Copyright (c) 2023 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 "ohos_adapter/bridge/ark_location_instance_wrapper.h" 17 18 #include "ohos_adapter/bridge/ark_location_proxy_adapter_wrapper.h" 19 #include "ohos_adapter/bridge/ark_location_request_config_wrapper.h" 20 21 #include "base/bridge/ark_web_bridge_macros.h" 22 23 namespace OHOS::NWeb { GetInstance()24LocationInstance& LocationInstance::GetInstance() 25 { 26 static ArkWeb::ArkLocationInstanceWrapper instance(ArkWeb::ArkLocationInstance::GetInstance()); 27 return instance; 28 } 29 30 } // namespace OHOS::NWeb 31 32 namespace OHOS::ArkWeb { 33 ArkLocationInstanceWrapper(ArkWebRefPtr<ArkLocationInstance> ref)34ArkLocationInstanceWrapper::ArkLocationInstanceWrapper(ArkWebRefPtr<ArkLocationInstance> ref) : ctocpp_(ref) {} 35 CreateLocationProxyAdapter()36std::shared_ptr<NWeb::LocationProxyAdapter> ArkLocationInstanceWrapper::CreateLocationProxyAdapter() 37 { 38 ArkWebRefPtr<ArkLocationProxyAdapter> ref = ctocpp_->CreateLocationProxyAdapter(); 39 if (CHECK_REF_PTR_IS_NULL(ref)) { 40 return nullptr; 41 } 42 43 return std::make_shared<ArkLocationProxyAdapterWrapper>(ref); 44 } 45 CreateLocationRequestConfig()46std::shared_ptr<NWeb::LocationRequestConfig> ArkLocationInstanceWrapper::CreateLocationRequestConfig() 47 { 48 ArkWebRefPtr<ArkLocationRequestConfig> ref = ctocpp_->CreateLocationRequestConfig(); 49 if (CHECK_REF_PTR_IS_NULL(ref)) { 50 return nullptr; 51 } 52 53 return std::make_shared<ArkLocationRequestConfigWrapper>(ref); 54 } 55 56 } // namespace OHOS::ArkWeb 57