1 /*
2  * Copyright (c) 2021 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_FRAMEWORKS_BRIDGE_COMMON_MANIFEST_MANIFEST_PARSER_H
17 #define FOUNDATION_ACE_FRAMEWORKS_BRIDGE_COMMON_MANIFEST_MANIFEST_PARSER_H
18 
19 #include <string>
20 
21 #include "base/log/log.h"
22 #include "base/memory/referenced.h"
23 #include "base/utils/noncopyable.h"
24 #include "frameworks/bridge/common/manifest/manifest_appinfo.h"
25 #include "frameworks/bridge/common/manifest/manifest_router.h"
26 #include "frameworks/bridge/common/manifest/manifest_widget.h"
27 #include "frameworks/bridge/common/manifest/manifest_window.h"
28 
29 namespace OHOS::Ace::Framework {
30 
31 class ACE_FORCE_EXPORT ManifestParser : public Referenced {
32 public:
33     ManifestParser();
34     ~ManifestParser() override = default;
35 
36     const RefPtr<ManifestAppInfo>& GetAppInfo() const;
37     const RefPtr<ManifestRouter>& GetRouter() const;
38     const RefPtr<ManifestWidgetGroup>& GetWidget() const;
39     WindowConfig& GetWindowConfig();
40 
IsWebFeature()41     bool IsWebFeature() const
42     {
43         return webFeature_;
44     }
IsUseLiteStyle()45     bool IsUseLiteStyle() const
46     {
47         return useLiteStyle_;
48     }
GetMinPlatformVersion()49     int32_t GetMinPlatformVersion() const
50     {
51         return manifestAppInfo_->GetMinPlatformVersion();
52     }
53 
SetPagePath(const std::string & pagePath)54     void SetPagePath(const std::string& pagePath)
55     {
56         if (manifestRouter_) {
57             manifestRouter_->InsertPageList(pagePath);
58         }
59     }
60 
61     void Parse(const std::string& url);
62     void Printer();
63 
64 private:
65     RefPtr<ManifestAppInfo> manifestAppInfo_;
66     RefPtr<ManifestRouter> manifestRouter_;
67     RefPtr<ManifestWidgetGroup> manifestWidget_;
68     RefPtr<ManifestWindow> manifestWindow_;
69     bool webFeature_ = false;
70     bool useLiteStyle_ = false;
71 
72     ACE_DISALLOW_COPY_AND_MOVE(ManifestParser);
73 };
74 
75 } // namespace OHOS::Ace::Framework
76 
77 #endif // FOUNDATION_ACE_FRAMEWORKS_BRIDGE_COMMON_MANIFEST_MANIFEST_PARSER_H
78