manifest_handler.cc
manifest_handlers/category_handler.cc
manifest_handlers/ime_handler.cc
+ manifest_handlers/metadata_handler.cc
+ manifest_handlers/navigation_handler.cc
manifest_handlers/permissions_handler.cc
manifest_handlers/setting_handler.cc
+ manifest_handlers/splash_screen_handler.cc
manifest_handlers/tizen_application_handler.cc
manifest_handlers/widget_handler.cc
manifest_util.cc
#include "widget-manifest-parser/manifest_handlers/permissions_handler.h"
#include "widget-manifest-parser/manifest_handlers/category_handler.h"
#include "widget-manifest-parser/manifest_handlers/ime_handler.h"
+#include "widget-manifest-parser/manifest_handlers/metadata_handler.h"
+#include "widget-manifest-parser/manifest_handlers/navigation_handler.h"
#include "widget-manifest-parser/manifest_handlers/setting_handler.h"
+#include "widget-manifest-parser/manifest_handlers/splash_screen_handler.h"
#include "widget-manifest-parser/manifest_handlers/tizen_application_handler.h"
#include "widget-manifest-parser/manifest_handlers/widget_handler.h"
// TODO(t.iwanek): add following handlers
// #include "widget-manifest-parser/manifest_handlers/tizen_appwidget_handler.h"
-// #include "widget-manifest-parser/manifest_handlers/tizen_metadata_handler.h"
-// #include "widget-manifest-parser/manifest_handlers/tizen_navigation_handler.h"
-// #include "widget-manifest-parser/manifest_handlers/tizen_splash_screen_handler.h"
namespace common_installer {
namespace widget_manifest_parser {
handlers.push_back(new CategoryHandler);
handlers.push_back(new ImeHandler);
handlers.push_back(new SettingHandler);
+ handlers.push_back(new MetaDataHandler);
+ handlers.push_back(new NavigationHandler);
+ handlers.push_back(new SplashScreenHandler);
+
widget_registry_ = new ManifestHandlerRegistry(handlers);
return widget_registry_;
--- /dev/null
+// Copyright (c) 2014 Intel Corporation. All rights reserved.
+// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE-xwalk file.
+
+#include "widget-manifest-parser/manifest_handlers/metadata_handler.h"
+
+#include <cassert>
+#include <map>
+#include <utility>
+
+#include "utils/values.h"
+#include "widget-manifest-parser/application_manifest_constants.h"
+
+namespace common_installer {
+namespace widget_manifest_parser {
+
+namespace keys = application_widget_keys;
+
+typedef std::pair<std::string, std::string> MetaDataPair;
+typedef std::map<std::string, std::string> MetaDataMap;
+typedef std::map<std::string, std::string>::const_iterator MetaDataIter;
+
+namespace {
+
+MetaDataPair ParseMetaDataItem(const utils::DictionaryValue* dict,
+ std::string* error) {
+ assert(dict && dict->IsType(utils::Value::TYPE_DICTIONARY));
+ MetaDataPair result;
+ if (!dict->GetString(keys::kTizenMetaDataNameKey, &result.first) ||
+ !dict->GetString(keys::kTizenMetaDataValueKey, &result.second)) {
+ *error = "Invalid key/value of tizen metaData.";
+ }
+
+ return result;
+}
+
+} // namespace
+
+MetaDataInfo::MetaDataInfo() {}
+
+MetaDataInfo::~MetaDataInfo() {}
+
+bool MetaDataInfo::HasKey(const std::string& key) const {
+ return metadata_.find(key) != metadata_.end();
+}
+
+std::string MetaDataInfo::GetValue(const std::string& key) const {
+ MetaDataIter it = metadata_.find(key);
+ if (it != metadata_.end())
+ return it->second;
+ return std::string("");
+}
+
+void MetaDataInfo::SetValue(const std::string& key,
+ const std::string& value) {
+ metadata_.insert(MetaDataPair(key, value));
+}
+
+MetaDataHandler::MetaDataHandler() {}
+
+MetaDataHandler::~MetaDataHandler() {}
+
+bool MetaDataHandler::Parse(std::shared_ptr<ApplicationData> application,
+ std::string* error) {
+ std::shared_ptr<MetaDataInfo> metadata_info(new MetaDataInfo);
+ const Manifest* manifest = application->GetManifest();
+ assert(manifest);
+
+ utils::Value* metadata_value = NULL;
+ if (!manifest->Get(keys::kTizenMetaDataKey, &metadata_value)) {
+ *error = "Failed to get value of tizen metaData";
+ }
+
+ MetaDataPair metadata_item;
+ if (metadata_value && metadata_value->IsType(utils::Value::TYPE_DICTIONARY)) {
+ utils::DictionaryValue* dict;
+ metadata_value->GetAsDictionary(&dict);
+ metadata_item = ParseMetaDataItem(dict, error);
+ metadata_info->SetValue(metadata_item.first, metadata_item.second);
+ } else if (metadata_value &&
+ metadata_value->IsType(utils::Value::TYPE_LIST)) {
+ utils::ListValue* list;
+ metadata_value->GetAsList(&list);
+
+ for (utils::ListValue::iterator it = list->begin();
+ it != list->end(); ++it) {
+ utils::DictionaryValue* dict;
+ (*it)->GetAsDictionary(&dict);
+ metadata_item = ParseMetaDataItem(dict, error);
+ metadata_info->SetValue(metadata_item.first, metadata_item.second);
+ }
+ }
+
+ application->SetManifestData(keys::kTizenMetaDataKey,
+ metadata_info);
+ return true;
+}
+
+std::vector<std::string> MetaDataHandler::Keys() const {
+ return std::vector<std::string>(1, keys::kTizenMetaDataKey);
+}
+
+} // namespace widget_manifest_parser
+} // namespace common_installer
--- /dev/null
+// Copyright (c) 2014 Intel Corporation. All rights reserved.
+// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE-xwalk file.
+
+#ifndef WIDGET_MANIFEST_PARSER_MANIFEST_HANDLERS_METADATA_HANDLER_H_
+#define WIDGET_MANIFEST_PARSER_MANIFEST_HANDLERS_METADATA_HANDLER_H_
+
+#include <map>
+#include <memory>
+#include <string>
+#include <vector>
+
+#include "utils/values.h"
+#include "widget-manifest-parser/application_data.h"
+#include "widget-manifest-parser/manifest_handler.h"
+
+namespace common_installer {
+namespace widget_manifest_parser {
+
+class MetaDataInfo : public ApplicationData::ManifestData {
+ public:
+ MetaDataInfo();
+ virtual ~MetaDataInfo();
+
+ bool HasKey(const std::string& key) const;
+ std::string GetValue(const std::string& key) const;
+ void SetValue(const std::string& key, const std::string& value);
+ const std::map<std::string, std::string>& metadata() const {
+ return metadata_;
+ }
+
+ private:
+ std::map<std::string, std::string> metadata_;
+};
+
+class MetaDataHandler : public ManifestHandler {
+ public:
+ MetaDataHandler();
+ virtual ~MetaDataHandler();
+
+ bool Parse(std::shared_ptr<ApplicationData> application,
+ std::string* error) override;
+ std::vector<std::string> Keys() const override;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(MetaDataHandler);
+};
+
+} // namespace widget_manifest_parser
+} // namespace common_installer
+
+#endif // WIDGET_MANIFEST_PARSER_MANIFEST_HANDLERS_METADATA_HANDLER_H_
--- /dev/null
+// Copyright (c) 2014 Intel Corporation. All rights reserved.
+// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE-xwalk file.
+
+#include "widget-manifest-parser/manifest_handlers/navigation_handler.h"
+
+#include <boost/tokenizer.hpp>
+
+#include "widget-manifest-parser/application_manifest_constants.h"
+
+namespace common_installer {
+namespace widget_manifest_parser {
+
+namespace keys = application_widget_keys;
+
+namespace {
+
+const boost::char_separator<char> navigation_separator(" ");
+
+} // namespace
+
+NavigationInfo::NavigationInfo(const std::string& allowed_domains) {
+ boost::tokenizer<boost::char_separator<char>> tokens(
+ allowed_domains, navigation_separator);
+ for (auto& item : tokens) {
+ allowed_domains_.push_back(item);
+ }
+}
+
+NavigationInfo::~NavigationInfo() {
+}
+
+NavigationHandler::NavigationHandler() {
+}
+
+NavigationHandler::~NavigationHandler() {
+}
+
+bool NavigationHandler::Parse(
+ std::shared_ptr<ApplicationData> application_data,
+ std::string* error) {
+ if (!application_data->GetManifest()->HasPath(keys::kAllowNavigationKey))
+ return true;
+ std::string allowed_domains;
+ if (!application_data->GetManifest()->GetString(keys::kAllowNavigationKey,
+ &allowed_domains)) {
+ *error = "Invalid value of allow-navigation.";
+ return false;
+ }
+ if (allowed_domains.empty())
+ return true;
+
+ application_data->SetManifestData(keys::kAllowNavigationKey,
+ std::shared_ptr<ApplicationData::ManifestData>(
+ new NavigationInfo(allowed_domains)));
+
+ return true;
+}
+
+std::vector<std::string> NavigationHandler::Keys() const {
+ return std::vector<std::string>(1, keys::kAllowNavigationKey);
+}
+
+} // namespace widget_manifest_parser
+} // namespace common_installer
--- /dev/null
+// Copyright (c) 2014 Intel Corporation. All rights reserved.
+// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE-xwalk file.
+
+#ifndef WIDGET_MANIFEST_PARSER_MANIFEST_HANDLERS_NAVIGATION_HANDLER_H_
+#define WIDGET_MANIFEST_PARSER_MANIFEST_HANDLERS_NAVIGATION_HANDLER_H_
+
+#include <memory>
+#include <string>
+#include <vector>
+
+#include "widget-manifest-parser/application_data.h"
+#include "widget-manifest-parser/manifest_handler.h"
+
+namespace common_installer {
+namespace widget_manifest_parser {
+
+class NavigationInfo : public ApplicationData::ManifestData {
+ public:
+ explicit NavigationInfo(const std::string& allowed_domains);
+ virtual ~NavigationInfo();
+
+ const std::vector<std::string>& GetAllowedDomains() const {
+ return allowed_domains_;
+ }
+
+ private:
+ std::vector<std::string> allowed_domains_;
+};
+
+class NavigationHandler : public ManifestHandler {
+ public:
+ NavigationHandler();
+ virtual ~NavigationHandler();
+
+ bool Parse(std::shared_ptr<ApplicationData> application_data,
+ std::string* error) override;
+ std::vector<std::string> Keys() const override;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(NavigationHandler);
+};
+
+} // namespace widget_manifest_parser
+} // namespace common_installer
+
+#endif // WIDGET_MANIFEST_PARSER_MANIFEST_HANDLERS_NAVIGATION_HANDLER_H_
--- /dev/null
+// Copyright (c) 2014 Intel Corporation. All rights reserved.
+// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE-xwalk file.
+
+#include "widget-manifest-parser/manifest_handlers/splash_screen_handler.h"
+
+#include <boost/filesystem/path.hpp>
+#include <boost/filesystem/operations.hpp>
+
+#include <cassert>
+#include <map>
+#include <utility>
+
+#include "widget-manifest-parser/application_manifest_constants.h"
+
+namespace bf = boost::filesystem;
+
+namespace common_installer {
+namespace widget_manifest_parser {
+
+namespace keys = application_widget_keys;
+
+SplashScreenInfo::SplashScreenInfo() {}
+SplashScreenInfo::~SplashScreenInfo() {}
+
+SplashScreenHandler::SplashScreenHandler() {}
+
+SplashScreenHandler::~SplashScreenHandler() {}
+
+bool SplashScreenHandler::Parse(std::shared_ptr<ApplicationData> application,
+ std::string* error) {
+ std::shared_ptr<SplashScreenInfo> ss_info(new SplashScreenInfo);
+ const Manifest* manifest = application->GetManifest();
+ assert(manifest);
+
+ utils::Value* splash_screen = NULL;
+ manifest->Get(keys::kTizenSplashScreenKey, &splash_screen);
+ if (splash_screen && splash_screen->IsType(utils::Value::TYPE_DICTIONARY)) {
+ utils::DictionaryValue* ss_dict = NULL;
+ splash_screen->GetAsDictionary(&ss_dict);
+ std::string src;
+ ss_dict->GetString(keys::kTizenSplashScreenSrcKey, &src);
+ ss_info->set_src(src);
+ }
+ application->SetManifestData(keys::kTizenSplashScreenKey, ss_info);
+ return true;
+}
+
+bool SplashScreenHandler::Validate(
+ std::shared_ptr<const ApplicationData> application,
+ std::string* error) const {
+ const Manifest* manifest = application->GetManifest();
+ assert(manifest);
+ utils::Value* splash_screen = NULL;
+ manifest->Get(keys::kTizenSplashScreenKey, &splash_screen);
+ if (!splash_screen || !splash_screen->IsType(utils::Value::TYPE_DICTIONARY)) {
+ *error = "The splash-screen attribute is not set correctly.";
+ return false;
+ }
+ utils::DictionaryValue* ss_dict = NULL;
+ splash_screen->GetAsDictionary(&ss_dict);
+ std::string ss_src;
+ ss_dict->GetString(keys::kTizenSplashScreenSrcKey, &ss_src);
+ bf::path path = application->path() / bf::path(ss_src);
+ if (!bf::exists(path)) {
+ *error = "The splash screen image does not exist";
+ return false;
+ }
+ return true;
+}
+
+std::vector<std::string> SplashScreenHandler::Keys() const {
+ return std::vector<std::string>(1, keys::kTizenSplashScreenKey);
+}
+
+} // namespace widget_manifest_parser
+} // namespace common_installer
--- /dev/null
+// Copyright (c) 2014 Intel Corporation. All rights reserved.
+// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE-xwalk file.
+
+#ifndef WIDGET_MANIFEST_PARSER_MANIFEST_HANDLERS_SPLASH_SCREEN_HANDLER_H_
+#define WIDGET_MANIFEST_PARSER_MANIFEST_HANDLERS_SPLASH_SCREEN_HANDLER_H_
+
+#include <map>
+#include <memory>
+#include <string>
+#include <vector>
+
+#include "utils/values.h"
+#include "widget-manifest-parser/application_data.h"
+#include "widget-manifest-parser/manifest_handler.h"
+
+namespace common_installer {
+namespace widget_manifest_parser {
+
+class SplashScreenInfo : public ApplicationData::ManifestData {
+ public:
+ SplashScreenInfo();
+ virtual ~SplashScreenInfo();
+
+ void set_src(const std::string &src) { src_ = src; }
+ const std::string& src() const { return src_; }
+
+ private:
+ std::string src_;
+};
+
+class SplashScreenHandler : public ManifestHandler {
+ public:
+ SplashScreenHandler();
+ virtual ~SplashScreenHandler();
+
+ bool Parse(std::shared_ptr<ApplicationData> application,
+ std::string* error) override;
+ bool Validate(std::shared_ptr<const ApplicationData> application,
+ std::string* error) const override;
+ std::vector<std::string> Keys() const override;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(SplashScreenHandler);
+};
+
+} // namespace widget_manifest_parser
+} // namespace common_installer
+
+#endif // WIDGET_MANIFEST_PARSER_MANIFEST_HANDLERS_SPLASH_SCREEN_HANDLER_H_