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 "navigation_controller.h"
17 
18 
19 #include "ace_forward_compatibility.h"
20 #include "utils.h"
21 
22 namespace OHOS {
23 namespace Ace {
24 using GetNavigationControllerFunc = NavigationController* (*)(UIContent*, const char*);
25 constexpr char GET_NAVIGATION_CONTROL_FUNC[] = "OHOS_ACE_GetNavigationController";
26 
GetNavigationController( UIContent* uiContent, const std::string& navigationId)27 NavigationController* NavigationController::GetNavigationController(
28     UIContent* uiContent, const std::string& navigationId)
29 {
30     LIBHANDLE handle = LOADLIB(AceForwardCompatibility::GetAceLibName());
31     if (handle == nullptr) {
32         return nullptr;
33     }
34 
35     auto entry = reinterpret_cast<GetNavigationControllerFunc>(LOADSYM(handle, GET_NAVIGATION_CONTROL_FUNC));
36     if (entry == nullptr) {
37         FREELIB(handle);
38         return nullptr;
39     }
40 
41     auto contain = entry(uiContent, navigationId.c_str());
42     FREELIB(handle);
43     return contain;
44 }
45 } // namespace Ace
46 } // namespace OHOS
47