Revert "[Badge] Privilege checks moved to JS."
authorTomasz Marciniak <t.marciniak@samsung.com>
Wed, 4 Nov 2015 12:45:37 +0000 (13:45 +0100)
committerPawel Andruszkiewicz <p.andruszkie@samsung.com>
Fri, 6 Nov 2015 10:37:44 +0000 (11:37 +0100)
This reverts commit 442cdabd8e361635d635bca8d49cd18e53bde064.

[Verification] Code compiles. TCT pass rate 100%

Change-Id: If9762b1d8f1722b9a5fe377b91aced50bd009493
Signed-off-by: Tomasz Marciniak <t.marciniak@samsung.com>
src/badge/badge_api.js
src/badge/badge_instance.cc

index 4a2ab7c1373effeeec0d0d3662f6214297914cb1..dcd666b867a841ad32b5c5fe3ed3079c9896c56b 100755 (executable)
@@ -56,8 +56,6 @@ function BadgeManager() {
  * Sets the badge count for the designated application.
  */
 BadgeManager.prototype.setBadgeCount = function() {
-  xwalk.utils.checkPrivilegeAccess(xwalk.utils.privilege.NOTIFICATION);
-
   var args = validator_.validateArgs(arguments, [
     {name: 'appId', type: types_.STRING},
     {name: 'count', type: types_.LONG}
@@ -84,8 +82,6 @@ BadgeManager.prototype.setBadgeCount = function() {
  * @return {number} long Count of the badge
  */
 BadgeManager.prototype.getBadgeCount = function() {
-  xwalk.utils.checkPrivilegeAccess(xwalk.utils.privilege.NOTIFICATION);
-
   var args = validator_.validateArgs(arguments, [
     {name: 'appId', type: types_.STRING}
   ]);
@@ -106,8 +102,6 @@ BadgeManager.prototype.getBadgeCount = function() {
  * Gets the badge count for the designated application.
  */
 BadgeManager.prototype.addChangeListener = function() {
-  xwalk.utils.checkPrivilegeAccess(xwalk.utils.privilege.NOTIFICATION);
-
   var args = validator_.validateArgs(arguments, [
     {
       name: 'appIdList',
@@ -147,8 +141,6 @@ BadgeManager.prototype.addChangeListener = function() {
  * Gets the badge count for the designated application.
  */
 BadgeManager.prototype.removeChangeListener = function() {
-  xwalk.utils.checkPrivilegeAccess(xwalk.utils.privilege.NOTIFICATION);
-
   var args = validator_.validateArgs(arguments, [
     {
       name: 'appIdList',
index 9984e21eb05adacba9d33f7a05aedc18456f7f6c..79a6d115c2053e99ba8867c22ebe1b7093ef5831 100755 (executable)
 #include "badge/badge_instance.h"
 
 #include "common/converter.h"
+#include "common/tools.h"
 
 namespace extension {
 namespace badge {
 
+namespace {
+// The privileges that required in Badge API
+const std::string kPrivilegeNotification = "http://tizen.org/privilege/notification";
+
+}  // namespace
+
 using namespace common;
 using namespace extension::badge;
 
@@ -47,6 +54,8 @@ BadgeInstance::~BadgeInstance() {
 void BadgeInstance::BadgeManagerSetBadgeCount(const JsonValue& args,
                                               JsonObject& out) {
   LoggerD("Enter");
+  CHECK_PRIVILEGE_ACCESS(kPrivilegeNotification, &out);
+
   std::string app_id =
       common::FromJson<std::string>(args.get<JsonObject>(), "appId");
   const double count = args.get("count").get<double>();
@@ -62,6 +71,8 @@ void BadgeInstance::BadgeManagerSetBadgeCount(const JsonValue& args,
 void BadgeInstance::BadgeManagerGetBadgeCount(const JsonValue& args,
                                               JsonObject& out) {
   LoggerD("Enter");
+  CHECK_PRIVILEGE_ACCESS(kPrivilegeNotification, &out);
+
   std::string app_id =
       common::FromJson<std::string>(args.get<JsonObject>(), "appId");
 
@@ -77,6 +88,8 @@ void BadgeInstance::BadgeManagerGetBadgeCount(const JsonValue& args,
 void BadgeInstance::BadgeManagerAddChangeListener(const JsonValue& args,
                                                   JsonObject& out) {
   LoggerD("Enter");
+  CHECK_PRIVILEGE_ACCESS(kPrivilegeNotification, &out);
+
   PlatformResult status =
       manager_.AddChangeListener(args.get<JsonObject>());
 
@@ -89,6 +102,8 @@ void BadgeInstance::BadgeManagerAddChangeListener(const JsonValue& args,
 void BadgeInstance::BadgeManagerRemoveChangeListener(const JsonValue& args,
                                                      JsonObject& out) {
   LoggerD("Enter");
+  CHECK_PRIVILEGE_ACCESS(kPrivilegeNotification, &out);
+
   PlatformResult status =
       manager_.RemoveChangeListener(args.get<JsonObject>());