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