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 #ifndef FOUNDATION_ACE_ADAPTER_OHOS_OSAL_NAVIGATION_ROUTE_OHOS_H 17 #define FOUNDATION_ACE_ADAPTER_OHOS_OSAL_NAVIGATION_ROUTE_OHOS_H 18 #include <cstdint> 19 20 #include "bundlemgr/bundle_mgr_interface.h" 21 22 #include "frameworks/core/components_ng/pattern/navigation/navigation_route.h" 23 24 namespace OHOS::Ace { 25 26 class ACE_EXPORT NavigationRouteOhos : public NG::NavigationRoute { 27 DECLARE_ACE_TYPE(NavigationRouteOhos, NG::NavigationRoute); 28 29 public: NavigationRouteOhos(const std::string & bundleName)30 explicit NavigationRouteOhos(const std::string& bundleName) 31 { 32 InitRouteMap(); 33 } 34 ~NavigationRouteOhos() = default; 35 36 bool GetRouteItem(const std::string& name, NG::RouteItem& info) override; 37 HasLoaded(const std::string & name)38 bool HasLoaded(const std::string& name) override 39 { 40 return std::find(names_.begin(), names_.end(), name) != names_.end(); 41 } 42 43 int32_t LoadPage(const std::string& name) override; 44 45 bool IsNavigationItemExits(const std::string& name) override; 46 47 void InitRouteMap() override; 48 49 private: 50 bool GetRouteItemFromBundle(const std::string& name, AppExecFwk::RouterItem& routeItem); 51 sptr<AppExecFwk::IBundleMgr> GetBundleManager(); 52 AppExecFwk::RouterItem GetRouteItem(const std::string name); 53 std::vector<AppExecFwk::RouterItem> allRouteItems_; 54 std::vector<std::string> names_; 55 }; 56 } // namespace OHOS::Ace 57 #endif