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_history_item_impl.h"
17 
18 #include "include/nweb.h"
19 
20 #include "base/bridge/ark_web_bridge_macros.h"
21 
22 namespace OHOS::ArkWeb {
23 
24 using ArkWebImageColorType = OHOS::NWeb::ImageColorType;
25 using ArkWebImageAlphaType = OHOS::NWeb::ImageAlphaType;
26 
ArkWebHistoryItemImpl(std::shared_ptr<OHOS::NWeb::NWebHistoryItem> nweb_history_item)27 ArkWebHistoryItemImpl::ArkWebHistoryItemImpl(std::shared_ptr<OHOS::NWeb::NWebHistoryItem> nweb_history_item)
28     : nweb_history_item_(nweb_history_item)
29 {}
30 
GetFavicon(void ** data,int & width,int & height,int & color_type,int & alpha_type)31 bool ArkWebHistoryItemImpl::GetFavicon(void** data, int& width, int& height, int& color_type, int& alpha_type)
32 {
33     ArkWebImageColorType enum_color_type = ArkWebImageColorType::COLOR_TYPE_UNKNOWN;
34     ArkWebImageAlphaType enum_alpha_type = ArkWebImageAlphaType::ALPHA_TYPE_UNKNOWN;
35     bool result = nweb_history_item_->GetFavicon(data, width, height, enum_color_type, enum_alpha_type);
36     color_type = static_cast<int>(enum_color_type);
37     alpha_type = static_cast<int>(enum_alpha_type);
38     return result;
39 }
40 
GetHistoryUrl()41 ArkWebString ArkWebHistoryItemImpl::GetHistoryUrl()
42 {
43     return ArkWebStringClassToStruct(nweb_history_item_->GetHistoryUrl());
44 }
45 
GetHistoryTitle()46 ArkWebString ArkWebHistoryItemImpl::GetHistoryTitle()
47 {
48     return ArkWebStringClassToStruct(nweb_history_item_->GetHistoryTitle());
49 }
50 
GetHistoryRawUrl()51 ArkWebString ArkWebHistoryItemImpl::GetHistoryRawUrl()
52 {
53     return ArkWebStringClassToStruct(nweb_history_item_->GetHistoryRawUrl());
54 }
55 
56 } // namespace OHOS::ArkWeb
57