michael@0: /* michael@0: * Copyright (C) 2012 Mozilla Foundation michael@0: * michael@0: * Licensed under the Apache License, Version 2.0 (the "License"); michael@0: * you may not use this file except in compliance with the License. michael@0: * You may obtain a copy of the License at michael@0: * michael@0: * http://www.apache.org/licenses/LICENSE-2.0 michael@0: * michael@0: * Unless required by applicable law or agreed to in writing, software michael@0: * distributed under the License is distributed on an "AS IS" BASIS, michael@0: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. michael@0: * See the License for the specific language governing permissions and michael@0: * limitations under the License. michael@0: */ michael@0: #ifndef GONKPERMISSION_H michael@0: #define GONKPERMISSION_H michael@0: michael@0: #include michael@0: #include "nsString.h" michael@0: #include "nsTArray.h" michael@0: michael@0: namespace mozilla { michael@0: class PermissionGrant michael@0: { michael@0: public: michael@0: PermissionGrant(const char* perm, int32_t p) : mPid(p) michael@0: { michael@0: mPermission.Assign(perm); michael@0: } michael@0: michael@0: PermissionGrant(const nsACString& permission, int32_t pid) : mPid(pid), michael@0: mPermission(permission) michael@0: { michael@0: } michael@0: michael@0: bool operator==(const PermissionGrant& other) const michael@0: { michael@0: return (mPid == other.pid() && mPermission.Equals(other.permission())); michael@0: } michael@0: michael@0: int32_t pid() const michael@0: { michael@0: return mPid; michael@0: } michael@0: michael@0: const nsACString& permission() const michael@0: { michael@0: return mPermission; michael@0: } michael@0: michael@0: private: michael@0: int32_t mPid; michael@0: nsCString mPermission; michael@0: }; michael@0: michael@0: class PermissionGrant; michael@0: michael@0: class GonkPermissionService : michael@0: public android::BinderService, michael@0: public android::BnPermissionController michael@0: { michael@0: public: michael@0: virtual ~GonkPermissionService() {} michael@0: static GonkPermissionService* GetInstance(); michael@0: static const char *getServiceName() { michael@0: return "permission"; michael@0: } michael@0: michael@0: static void instantiate(); michael@0: michael@0: virtual android::status_t dump(int fd, const android::Vector& args) { michael@0: return android::NO_ERROR; michael@0: } michael@0: virtual bool checkPermission(const android::String16& permission, int32_t pid, michael@0: int32_t uid); michael@0: michael@0: void addGrantInfo(const char* permission, int32_t pid); michael@0: private: michael@0: GonkPermissionService(): android::BnPermissionController() {} michael@0: nsTArray mGrantArray; michael@0: }; michael@0: } // namespace mozilla michael@0: #endif // GONKPERMISSION_H