[Notification] Moved checking privileges to JS layer.
authorTomasz Marciniak <t.marciniak@samsung.com>
Mon, 4 May 2015 07:01:11 +0000 (09:01 +0200)
committerPawel Andruszkiewicz <p.andruszkie@samsung.com>
Mon, 4 May 2015 07:39:55 +0000 (16:39 +0900)
[Verification] Code compiles without errors.

Change-Id: If73090dced65523ce1f4391f0d71ca364bccf629
Signed-off-by: Tomasz Marciniak <t.marciniak@samsung.com>
src/notification/notification_api.js
src/notification/notification_instance.cc

index 1b42396..52c17c9 100644 (file)
@@ -7,6 +7,7 @@ var type_ = utils_.type;
 var converter_ = utils_.converter;
 var validator_ = utils_.validator;
 var types_ = validator_.Types;
+var privilege_ = xwalk.utils.privilege;
 var native_ = new xwalk.utils.NativeManager(extension);
 
 function convertColorToInt(rgbaColor) {
@@ -69,6 +70,8 @@ function NotificationManager() {}
 
 
 NotificationManager.prototype.post = function(notification) {
+  xwalk.utils.checkPrivilegeAccess(privilege_.NOTIFICATION);
+
   var args = validator_.validateArgs(arguments, [
     {name: 'notification', type: types_.PLATFORM_OBJECT, values: StatusNotification}
   ]);
@@ -92,6 +95,8 @@ NotificationManager.prototype.post = function(notification) {
 };
 
 NotificationManager.prototype.update = function(notification) {
+  xwalk.utils.checkPrivilegeAccess(privilege_.NOTIFICATION);
+
   var args = validator_.validateArgs(arguments, [
     {name: 'notification', type: types_.PLATFORM_OBJECT, values: StatusNotification}
   ]);
@@ -116,6 +121,8 @@ NotificationManager.prototype.update = function(notification) {
 };
 
 NotificationManager.prototype.remove = function(id) {
+  xwalk.utils.checkPrivilegeAccess(privilege_.NOTIFICATION);
+
   var args = validator_.validateArgs(arguments, [
     {name: 'id', type: types_.STRING}
   ]);
@@ -137,6 +144,8 @@ NotificationManager.prototype.remove = function(id) {
 };
 
 NotificationManager.prototype.removeAll = function() {
+  xwalk.utils.checkPrivilegeAccess(privilege_.NOTIFICATION);
+
   var result = native_.callSync('NotificationManager_removeAll', {});
 
   if (native_.isFailure(result)) {
index 01790d1..68c81d7 100644 (file)
 namespace extension {
 namespace notification {
 
-namespace {
-// The privileges that required in Notification API
-const std::string kPrivilegeNotification = "http://tizen.org/privilege/notification";
-}  // namespace
-
 using namespace common;
 
 NotificationInstance::NotificationInstance() {
@@ -53,7 +48,6 @@ NotificationInstance::~NotificationInstance() {
 
 void NotificationInstance::NotificationManagerPost(const picojson::value& args,
                                                    picojson::object& out) {
-  CHECK_PRIVILEGE_ACCESS(kPrivilegeNotification, &out);
 
   picojson::value val{picojson::object{}};
   PlatformResult status =
@@ -68,7 +62,6 @@ void NotificationInstance::NotificationManagerPost(const picojson::value& args,
 void NotificationInstance::NotificationManagerUpdate(
     const picojson::value& args,
     picojson::object& out) {
-  CHECK_PRIVILEGE_ACCESS(kPrivilegeNotification, &out);
 
   PlatformResult status = manager_->Update(args.get<picojson::object>());
 
@@ -81,7 +74,6 @@ void NotificationInstance::NotificationManagerUpdate(
 void NotificationInstance::NotificationManagerRemove(
     const picojson::value& args,
     picojson::object& out) {
-  CHECK_PRIVILEGE_ACCESS(kPrivilegeNotification, &out);
 
   PlatformResult status = manager_->Remove(args.get<picojson::object>());
 
@@ -94,7 +86,6 @@ void NotificationInstance::NotificationManagerRemove(
 void NotificationInstance::NotificationManagerRemoveAll(
     const picojson::value& args,
     picojson::object& out) {
-  CHECK_PRIVILEGE_ACCESS(kPrivilegeNotification, &out);
 
   PlatformResult status = manager_->RemoveAll();