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 #include "frameworks/bridge/common/manifest/manifest_parser.h" 17 18 namespace OHOS::Ace::Framework { 19 ManifestParser()20ManifestParser::ManifestParser() 21 : manifestAppInfo_(Referenced::MakeRefPtr<ManifestAppInfo>()), 22 manifestRouter_(Referenced::MakeRefPtr<ManifestRouter>()), 23 manifestWidget_(Referenced::MakeRefPtr<ManifestWidgetGroup>()), 24 manifestWindow_(Referenced::MakeRefPtr<ManifestWindow>()) 25 {} 26 GetAppInfo() const27const RefPtr<ManifestAppInfo>& ManifestParser::GetAppInfo() const 28 { 29 return manifestAppInfo_; 30 } 31 GetRouter() const32const RefPtr<ManifestRouter>& ManifestParser::GetRouter() const 33 { 34 return manifestRouter_; 35 } 36 GetWidget() const37const RefPtr<ManifestWidgetGroup>& ManifestParser::GetWidget() const 38 { 39 return manifestWidget_; 40 } 41 GetWindowConfig()42WindowConfig& ManifestParser::GetWindowConfig() 43 { 44 return manifestWindow_->GetWindowConfig(); 45 } 46 Parse(const std::string & contents)47void ManifestParser::Parse(const std::string& contents) 48 { 49 auto rootJson = JsonUtil::ParseJsonString(contents); 50 if (!rootJson || !rootJson->IsValid()) { 51 return; 52 } 53 manifestAppInfo_->AppInfoParse(rootJson); 54 manifestRouter_->RouterParse(rootJson); 55 manifestWidget_->WidgetParse(rootJson); 56 manifestWindow_->WindowParse(rootJson); 57 webFeature_ = rootJson->GetBool("webFeature", false); 58 auto deviceTypes = rootJson->GetValue("deviceType"); 59 if (deviceTypes && deviceTypes->IsArray()) { 60 for (int32_t index = 0; index < deviceTypes->GetArraySize(); ++index) { 61 auto device = deviceTypes->GetArrayItem(index); 62 if (device && device->IsString() && device->GetString() == "liteWearable") { 63 useLiteStyle_ = true; 64 break; 65 } 66 } 67 } 68 } 69 Printer()70void ManifestParser::Printer() {} 71 72 } // namespace OHOS::Ace::Framework 73