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 "auto_fill_extension_context.h"
17 
18 #include "hilog_tag_wrapper.h"
19 
20 namespace OHOS {
21 namespace AbilityRuntime {
SetAutoFillExtensionCallback(const std::weak_ptr<IAutoFillExtensionCallback> & autoFillExtensionCallback)22 void AutoFillExtensionContext::SetAutoFillExtensionCallback(
23     const std::weak_ptr<IAutoFillExtensionCallback> &autoFillExtensionCallback)
24 {
25     autoFillExtensionCallback_ = autoFillExtensionCallback;
26 }
27 
SetSessionInfo(const sptr<AAFwk::SessionInfo> & sessionInfo)28 void AutoFillExtensionContext::SetSessionInfo(const sptr<AAFwk::SessionInfo> &sessionInfo)
29 {
30     sessionInfo_ = sessionInfo;
31 }
32 
ReloadInModal(const CustomData & customData)33 int32_t AutoFillExtensionContext::ReloadInModal(const CustomData &customData)
34 {
35     TAG_LOGD(AAFwkTag::AUTOFILL_EXT, "called");
36     if (sessionInfo_ == nullptr) {
37         TAG_LOGE(AAFwkTag::AUTOFILL_EXT, "null sessionInfo_");
38         return ERR_NULL_OBJECT;
39     }
40     auto autoFillExtensionCallback = autoFillExtensionCallback_.lock();
41     if (autoFillExtensionCallback == nullptr) {
42         TAG_LOGE(AAFwkTag::AUTOFILL_EXT, "null autoFillExtensionCallback");
43         return ERR_NULL_OBJECT;
44     }
45     return autoFillExtensionCallback->OnReloadInModal(sessionInfo_, customData);
46 }
47 } // namespace AbilityRuntime
48 } // namespace OHOS
49