[MediaController] Privilege checks moved to C++.
authorPawel Andruszkiewicz <p.andruszkie@samsung.com>
Thu, 5 Nov 2015 10:10:42 +0000 (11:10 +0100)
committerHyunJin Park <hj.na.park@samsung.com>
Wed, 9 Dec 2015 06:14:57 +0000 (15:14 +0900)
[Verification] Code compiles, pass rate did not change.

Change-Id: Icd50f235e58fa6e4f979fd11ca41e9a79daa9f6e
Signed-off-by: Pawel Andruszkiewicz <p.andruszkie@samsung.com>
src/mediacontroller/mediacontroller_api.js
src/mediacontroller/mediacontroller_instance.cc

index 7af9b64..c5a8197 100755 (executable)
@@ -161,8 +161,6 @@ var MediaControllerPlaybackState = {
 function MediaControllerManager() {}
 
 MediaControllerManager.prototype.getClient = function() {
-  xwalk.utils.checkPrivilegeAccess(xwalk.utils.privilege.MEDIACONTROLLER_CLIENT);
-
   var result = native_.callSync('MediaControllerManager_getClient', {});
 
   if (native_.isFailure(result)) {
@@ -173,8 +171,6 @@ MediaControllerManager.prototype.getClient = function() {
 };
 
 MediaControllerManager.prototype.createServer = function() {
-  xwalk.utils.checkPrivilegeAccess(xwalk.utils.privilege.MEDIACONTROLLER_SERVER);
-
   var result = native_.callSync('MediaControllerManager_createServer', {});
   if (native_.isFailure(result)) {
     throw native_.getErrorObject(result);
index e4af4f2..3c8ebcb 100755 (executable)
 #include "common/picojson.h"
 #include "common/platform_result.h"
 #include "common/task-queue.h"
+#include "common/tools.h"
 
 #include "mediacontroller/mediacontroller_types.h"
 
 namespace extension {
 namespace mediacontroller {
 
+namespace {
+
+const std::string kPrivilegeMediaControllerClient = "http://tizen.org/privilege/mediacontroller.client";
+const std::string kPrivilegeMediaControllerServer = "http://tizen.org/privilege/mediacontroller.server";
+
+}  // namespace
+
 using common::ErrorCode;
 using common::PlatformResult;
 using common::TaskQueue;
@@ -110,8 +118,10 @@ MediaControllerInstance::~MediaControllerInstance() {
 void MediaControllerInstance::MediaControllerManagerCreateServer(
     const picojson::value& args,
     picojson::object& out) {
-
   LoggerD("Enter");
+
+  CHECK_PRIVILEGE_ACCESS(kPrivilegeMediaControllerServer, &out);
+
   if (server_) {
     ReportSuccess(out);
     return;
@@ -356,8 +366,10 @@ void MediaControllerInstance::MediaControllerServerRemoveCommandListener(
 void MediaControllerInstance::MediaControllerManagerGetClient(
     const picojson::value& args,
     picojson::object& out) {
-
   LoggerD("Enter");
+
+  CHECK_PRIVILEGE_ACCESS(kPrivilegeMediaControllerClient, &out);
+
   if (client_) {
     ReportSuccess(out);
     return;