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 "ohos_nweb/bridge/ark_web_native_embed_data_info_impl.h"
17 
18 #include "ohos_nweb/bridge/ark_web_native_embed_info_impl.h"
19 
20 #include "base/bridge/ark_web_bridge_macros.h"
21 
22 namespace OHOS::ArkWeb {
23 
ArkWebNativeEmbedDataInfoImpl(std::shared_ptr<OHOS::NWeb::NWebNativeEmbedDataInfo> nweb_native_embed_data_info)24 ArkWebNativeEmbedDataInfoImpl::ArkWebNativeEmbedDataInfoImpl(
25     std::shared_ptr<OHOS::NWeb::NWebNativeEmbedDataInfo> nweb_native_embed_data_info)
26     : nweb_native_embed_data_info_(nweb_native_embed_data_info)
27 {}
28 
GetStatus()29 int ArkWebNativeEmbedDataInfoImpl::GetStatus()
30 {
31     return static_cast<int>(nweb_native_embed_data_info_->GetStatus());
32 }
33 
GetEmbedId()34 ArkWebString ArkWebNativeEmbedDataInfoImpl::GetEmbedId()
35 {
36     return ArkWebStringClassToStruct(nweb_native_embed_data_info_->GetEmbedId());
37 }
38 
GetSurfaceId()39 ArkWebString ArkWebNativeEmbedDataInfoImpl::GetSurfaceId()
40 {
41     return ArkWebStringClassToStruct(nweb_native_embed_data_info_->GetSurfaceId());
42 }
43 
GetNativeEmbedInfo()44 ArkWebRefPtr<ArkWebNativeEmbedInfo> ArkWebNativeEmbedDataInfoImpl::GetNativeEmbedInfo()
45 {
46     std::shared_ptr<OHOS::NWeb::NWebNativeEmbedInfo> nweb_native_embed_info =
47         nweb_native_embed_data_info_->GetNativeEmbedInfo();
48     if (CHECK_SHARED_PTR_IS_NULL(nweb_native_embed_info)) {
49         return nullptr;
50     }
51 
52     return new ArkWebNativeEmbedInfoImpl(nweb_native_embed_info);
53 }
54 
55 } // namespace OHOS::ArkWeb
56