const char kDataControlTypeKey[] = "@type";
const char kDataControlTrustedKey[] = "@trusted";
+// privilege
+const char kPrivilegeTextKey[] = "#text";
+const char kPrivilegeKey[] = "privilege";
+const char kPrivilegeTypeDefault[] = "tpk";
+
// icon
const char kIconKey[] = "icon";
const char kIconTextKey[] = "#text";
extern const char kDataControlTypeKey[];
extern const char kDataControlTrustedKey[];
+// privilege
+extern const char kPrivilegeTextKey[];
+extern const char kPrivilegeKey[];
+extern const char kPrivilegeTypeDefault[];
+
// icon
extern const char kIconKey[];
extern const char kIconTextKey[];
dict.GetString(tpk_app_keys::kDataControlTypeKey, &type);
std::string trusted;
dict.GetString(tpk_app_keys::kDataControlTrustedKey, &trusted);
- info->data_control.emplace_back(access, providerid, type, trusted);
+
+ std::shared_ptr<PrivilegesInfo> privileges_info(new PrivilegesInfo());
+ for (auto& item : parser::GetOneOrMany(&dict,
+ tpk_app_keys::kPrivilegeKey, "")) {
+ std::string privilege;
+ std::string type = tpk_app_keys::kPrivilegeTypeDefault;
+ if (!item->GetString(tpk_app_keys::kPrivilegeTextKey, &privilege) ||
+ privilege.empty())
+ continue;
+
+ privileges_info->AddPrivilege(privilege, type);
+ }
+
+ info->data_control.emplace_back(access, providerid, type, trusted,
+ privileges_info);
return true;
}
#include "manifest_parser/manifest_handler.h"
#include "manifest_parser/values.h"
+#include "tpk_manifest_handlers/privileges_handler.h"
namespace tpk {
namespace parse {
DataControlInfo(const std::string& access,
const std::string& providerid,
const std::string& type,
- const std::string& trusted)
+ const std::string& trusted,
+ const std::shared_ptr<PrivilegesInfo>& privileges)
: access_(access),
providerid_(providerid),
type_(type),
- trusted_(trusted) {}
+ trusted_(trusted),
+ privileges_(privileges) {}
const std::string& access() const {
return access_;
const std::string& trusted() const {
return trusted_;
}
+ const std::shared_ptr<PrivilegesInfo> privileges() const {
+ return privileges_;
+ }
private:
std::string access_;
std::string providerid_;
std::string type_;
std::string trusted_;
+ std::shared_ptr<PrivilegesInfo> privileges_;
};
// MetaData