From: Piotr Kosko Date: Mon, 4 May 2015 07:10:50 +0000 (+0200) Subject: [Push] Privilege checks moved to JS layer X-Git-Tag: submit/tizen_tv/20150603.064601~1^2~97 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ad01927f6992eb1f5866ce0b015de19e74ab4c1a;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [Push] Privilege checks moved to JS layer Change-Id: I893855bb255593d55134e9b96ea499c5e3182781 Signed-off-by: Piotr Kosko --- diff --git a/src/push/push_api.js b/src/push/push_api.js index 181b2ed1..eb6bc43f 100644 --- a/src/push/push_api.js +++ b/src/push/push_api.js @@ -8,7 +8,7 @@ var native = new xwalk.utils.NativeManager(extension); var validator = xwalk.utils.validator; var validatorType = xwalk.utils.type; - +var Privilege = xwalk.utils.privilege; /** * @const @@ -40,6 +40,7 @@ function PushManager() { } PushManager.prototype.registerService = function(appControl, successCallback, errorCallback) { + xwalk.utils.checkPrivilegeAccess(Privilege.PUSH); var data = validator.validateArgs(arguments, [ { name: 'appControl', @@ -78,6 +79,7 @@ PushManager.prototype.registerService = function(appControl, successCallback, er }; PushManager.prototype.unregisterService = function(successCallback, errorCallback) { + xwalk.utils.checkPrivilegeAccess(Privilege.PUSH); var data = validator.validateArgs(arguments, [ { name: 'successCallback', @@ -104,6 +106,7 @@ PushManager.prototype.unregisterService = function(successCallback, errorCallbac }; PushManager.prototype.connectService = function(notificationCallback) { + xwalk.utils.checkPrivilegeAccess(Privilege.PUSH); var data = validator.validateArgs(arguments, [ { name: 'notificationCallback', @@ -120,6 +123,7 @@ PushManager.prototype.connectService = function(notificationCallback) { }; PushManager.prototype.disconnectService = function() { + xwalk.utils.checkPrivilegeAccess(Privilege.PUSH); var ret = native.callSync('Push_disconnectService', {}); if (native.isFailure(ret)) { throw native.getErrorObject(ret); @@ -128,6 +132,7 @@ PushManager.prototype.disconnectService = function() { }; PushManager.prototype.getRegistrationId = function() { + xwalk.utils.checkPrivilegeAccess(Privilege.PUSH); var ret = native.callSync('Push_getRegistrationId', {}); if (native.isFailure(ret)) { throw native.getErrorObject(ret); @@ -136,6 +141,7 @@ PushManager.prototype.getRegistrationId = function() { }; PushManager.prototype.getUnreadNotifications = function() { + xwalk.utils.checkPrivilegeAccess(Privilege.PUSH); var ret = native.callSync('Push_getUnreadNotifications', {}); if (native.isFailure(ret)) { throw native.getErrorObject(ret); diff --git a/src/push/push_instance.cc b/src/push/push_instance.cc index fc169368..376d9675 100644 --- a/src/push/push_instance.cc +++ b/src/push/push_instance.cc @@ -11,12 +11,6 @@ namespace extension { namespace push { -namespace { - -const std::string kPrivilegePush = "http://tizen.org/privilege/push"; - -} // namespace - PushInstance::PushInstance(): m_ignoreNotificationEvents(true) { LoggerD("Enter"); using std::placeholders::_1; @@ -49,8 +43,6 @@ void PushInstance::registerService(const picojson::value& args, picojson::object& out) { LoggerD("Enter"); - CHECK_PRIVILEGE_ACCESS(kPrivilegePush, &out); - PushManager::ApplicationControl appControl; appControl.operation = args.get("operation").get(); if (args.get("uri").is()) { @@ -90,8 +82,6 @@ void PushInstance::unregisterService(const picojson::value& args, picojson::object& out) { LoggerD("Enter"); - CHECK_PRIVILEGE_ACCESS(kPrivilegePush, &out); - common::PlatformResult result = PushManager::getInstance() .unregisterService(args.get("callbackId").get()); if (result.IsError()) { @@ -107,8 +97,6 @@ void PushInstance::connectService(const picojson::value& args, picojson::object& out) { LoggerD("Enter"); - CHECK_PRIVILEGE_ACCESS(kPrivilegePush, &out); - m_ignoreNotificationEvents = false; picojson::value result; ReportSuccess(result, out); @@ -118,8 +106,6 @@ void PushInstance::disconnectService(const picojson::value& args, picojson::object& out) { LoggerD("Enter"); - CHECK_PRIVILEGE_ACCESS(kPrivilegePush, &out); - m_ignoreNotificationEvents = true; picojson::value result; ReportSuccess(result, out); @@ -129,8 +115,6 @@ void PushInstance::getRegistrationId(const picojson::value& args, picojson::object& out) { LoggerD("Enter"); - CHECK_PRIVILEGE_ACCESS(kPrivilegePush, &out); - std::string id; common::PlatformResult result = PushManager::getInstance() .getRegistrationId(id); @@ -148,8 +132,6 @@ void PushInstance::getUnreadNotifications(const picojson::value& args, picojson::object& out) { LoggerD("Enter"); - CHECK_PRIVILEGE_ACCESS(kPrivilegePush, &out); - common::PlatformResult result = PushManager::getInstance() .getUnreadNotifications(); if (result.IsError()) {