From 52486cd55fa4189878fe000b1943b02ef1d5a804 Mon Sep 17 00:00:00 2001 From: Yongseop Kim Date: Fri, 10 Jul 2015 12:06:32 +0900 Subject: [PATCH] Apply WidgetConfigParser from Manifest-parser Change-Id: I60cc7496a5ab848d160319710cd5baf9fb1d1642 --- src/common/application_data.cc | 123 ++++++++++++++++------------------------- 1 file changed, 47 insertions(+), 76 deletions(-) diff --git a/src/common/application_data.cc b/src/common/application_data.cc index ddaafd3..66bc516 100755 --- a/src/common/application_data.cc +++ b/src/common/application_data.cc @@ -17,8 +17,9 @@ #include "common/application_data.h" #include -#include #include +#include +#include #include @@ -155,122 +156,92 @@ bool ApplicationData::LoadManifestData() { return false; } - enum ManifestHandlerType { - APP_CONTROL_HANDLER = 0, - CATEGORY_HANDLER, - META_DATA_HANDLER, - NAVIGATION_HANDLER, - PERMISSIONS_HANDLER, - SETTING_HANDLER, - SPLASH_SCREEN_HANDLER, - TIZEN_APPLICATION_HANDLER, - WIDGET_HANDLER, - CONTENT_HANDLER, - WARP_HANDLER, - CSP_HANDLER, - CSP_REPORT_HANDLER - }; - - std::vector handlers = { - new wgt::parse::AppControlHandler, // APP_CONTROL_HANDLER - new wgt::parse::CategoryHandler, // CATEGORY_HANDLER - new wgt::parse::MetaDataHandler, // META_DATA_HANDLER - new wgt::parse::NavigationHandler, // NAVIGATION_HANDLER - new wgt::parse::PermissionsHandler, // PERMISSIONS_HANDLER - new wgt::parse::SettingHandler, // SETTING_HANDLER - new wgt::parse::SplashScreenHandler, // SPLASH_SCREEN_HANDLER - new wgt::parse::TizenApplicationHandler, // TIZEN_APPLICATION_HANDLER - new wgt::parse::WidgetHandler, // WIDGET_HANDLER - new wgt::parse::ContentHandler, // CONTENT_HANDLER - new wgt::parse::WarpHandler, // WARP_HANDLER - // CSP_HANDLER - new wgt::parse::CSPHandler(wgt::parse::CSPHandler::SecurityType::CSP), - // CSP_REPORT_HANDLER - new wgt::parse::CSPHandler( - wgt::parse::CSPHandler::SecurityType::CSP_REPORT_ONLY) - }; - - std::unique_ptr registry; - registry.reset(new parser::ManifestHandlerRegistry(handlers)); - - parser::ManifestParser manifest_parser(std::move(registry)); - if (!manifest_parser.ParseManifest(config_xml_path)) { - for (auto iter = handlers.begin(); iter != handlers.end(); ++iter) { - delete *iter; - } - LOGGER(ERROR) << "Failed to load manifest data : " - << manifest_parser.GetErrorMessage(); + std::unique_ptr widget_config_parser; + widget_config_parser.reset(new wgt::parse::WidgetConfigParser()); + if (!widget_config_parser->ParseManifest(config_xml_path)) { + LOGGER(ERROR) << "Failed to load widget config parser data: " + << widget_config_parser->GetErrorMessage(); return false; } app_control_info_list_ = std::static_pointer_cast( - manifest_parser.GetManifestData( - handlers[ManifestHandlerType::APP_CONTROL_HANDLER]->Key())); + widget_config_parser->GetManifestData( + wgt::application_widget_keys::kTizenApplicationAppControlsKey)); category_info_list_ = std::static_pointer_cast( - manifest_parser.GetManifestData( - handlers[ManifestHandlerType::CATEGORY_HANDLER]->Key())); + widget_config_parser->GetManifestData( + wgt::application_widget_keys::kTizenCategoryKey)); meta_data_info_ = std::static_pointer_cast( - manifest_parser.GetManifestData( - handlers[ManifestHandlerType::META_DATA_HANDLER]->Key())); + widget_config_parser->GetManifestData( + wgt::application_widget_keys::kTizenMetaDataKey)); allowed_navigation_info_ = std::static_pointer_cast( - manifest_parser.GetManifestData( - handlers[ManifestHandlerType::NAVIGATION_HANDLER]->Key())); + widget_config_parser->GetManifestData( + wgt::application_widget_keys::kAllowNavigationKey)); permissions_info_ = std::static_pointer_cast( - manifest_parser.GetManifestData( - handlers[ManifestHandlerType::PERMISSIONS_HANDLER]->Key())); + widget_config_parser->GetManifestData( + wgt::application_widget_keys::kTizenPermissionsKey)); setting_info_ = std::static_pointer_cast( - manifest_parser.GetManifestData( - handlers[ManifestHandlerType::SETTING_HANDLER]->Key())); + widget_config_parser->GetManifestData( + wgt::application_widget_keys::kTizenSettingKey)); splash_screen_info_ = std::static_pointer_cast( - manifest_parser.GetManifestData( - handlers[ManifestHandlerType::SPLASH_SCREEN_HANDLER]->Key())); + widget_config_parser->GetManifestData( + wgt::application_widget_keys::kTizenSplashScreenKey)); tizen_application_info_ = std::static_pointer_cast( - manifest_parser.GetManifestData( - handlers[ManifestHandlerType::TIZEN_APPLICATION_HANDLER]->Key())); + widget_config_parser->GetManifestData( + wgt::application_widget_keys::kTizenApplicationKey)); widget_info_ = std::static_pointer_cast( - manifest_parser.GetManifestData( - handlers[ManifestHandlerType::WIDGET_HANDLER]->Key())); + widget_config_parser->GetManifestData( + wgt::application_widget_keys::kTizenWidgetKey)); content_info_ = std::static_pointer_cast( - manifest_parser.GetManifestData( - handlers[ManifestHandlerType::CONTENT_HANDLER]->Key())); + widget_config_parser->GetManifestData( + wgt::application_widget_keys::kTizenContentKey)); warp_info_ = std::static_pointer_cast( - manifest_parser.GetManifestData( - handlers[ManifestHandlerType::WARP_HANDLER]->Key())); + widget_config_parser->GetManifestData( + wgt::application_widget_keys::kAccessKey)); + + std::unique_ptr csp_registry; + csp_registry.reset(new parser::ManifestHandlerRegistry({ + new wgt::parse::CSPHandler(wgt::parse::CSPHandler::SecurityType::CSP), + new wgt::parse::CSPHandler( + wgt::parse::CSPHandler::SecurityType::CSP_REPORT_ONLY) + })); + + parser::ManifestParser csp_parser(std::move(csp_registry)); + if (!csp_parser.ParseManifest(config_xml_path)) { + LOGGER(ERROR) << "Failed to load manifest data : " + << csp_parser.GetErrorMessage(); + return false; + } csp_info_ = std::static_pointer_cast( - manifest_parser.GetManifestData( - handlers[ManifestHandlerType::CSP_HANDLER]->Key())); + csp_parser.GetManifestData( + wgt::application_widget_keys::kCSPKey)); csp_report_info_ = std::static_pointer_cast( - manifest_parser.GetManifestData( - handlers[ManifestHandlerType::CSP_REPORT_HANDLER]->Key())); - - for (auto iter = handlers.begin(); iter != handlers.end(); ++iter) { - delete *iter; - } + csp_parser.GetManifestData( + wgt::application_widget_keys::kCSPReportOnlyKey)); // Set default empty object if (widget_info_.get() == NULL) { -- 2.7.4