PrivacyPrivilege API
Deprecated. Deprecated Since 8.0.
A Tizen Web application has privileges defined in config.xml file, but for legal purposes, in case of privacy-related privileges, there could be a need of asking user directly with proper pop-up. List of privacy-related privileges is available on Security and API Privileges page. Privacy Privilege API allows:
- Checking if user granted permission for using a privacy-related privilege.
- Requesting pop-up about giving permission for using privacy-related privilege.
Since: 4.0
Table of Contents
- 1. Type Definitions
- 1.1. PermissionType
- 1.2. PermissionRequestResult
- 2. Interfaces
- 2.1. PrivacyPrivilegeManagerObject
- 2.2. PrivacyPrivilegeManager
- 2.3. PrivilegeStatus
- 2.4. RequestStatus
- 2.5. PermissionSuccessCallback
- 2.6. PermissionRequestSuccessCallback
- 3. Full WebIDL
Summary of Interfaces and Methods
Interface | Method |
---|
1. Type Definitions
1.1. PermissionType
Deprecated. Deprecated Since 8.0.
enum PermissionType { "PPM_ALLOW", "PPM_DENY", "PPM_ASK" };
Since: 4.0
The following types are supported:
- PPM_ALLOW - The application has been granted permission to use a privacy-related privilege.
- PPM_DENY - The application has not been granted permission to use a privacy-related privilege.
- PPM_ASK - The user has to be asked whether to grant permission to use a privacy-related privilege.
1.2. PermissionRequestResult
Deprecated. Deprecated Since 8.0.
enum PermissionRequestResult { "PPM_ALLOW_FOREVER", "PPM_DENY_FOREVER", "PPM_DENY_ONCE" };
Since: 4.0
The following types are supported:
- PPM_ALLOW_FOREVER - The user granted permission to use a privacy-related privilege for an indefinite period of time.
- PPM_DENY_FOREVER - The user denied granting permission to use a privacy-related privilege for an indefinite period of time.
- PPM_DENY_ONCE - The user denied granting permission to use a privacy-related privilege once.
2. Interfaces
2.1. PrivacyPrivilegeManagerObject
Deprecated. Deprecated Since 8.0.
[NoInterfaceObject] interface PrivacyPrivilegeManagerObject {
readonly attribute PrivacyPrivilegeManager ppm;
};
Tizen implements PrivacyPrivilegeManagerObject;
Since: 4.0
tizen.ppm object is available to manage the user permissions to use privacy-related privileges in your Web application.
Attributes
-
readonly
PrivacyPrivilegeManager ppmObject representing a privacy privilege manager.
Deprecated. Deprecated Since 8.0.
Since: 4.0
2.2. PrivacyPrivilegeManager
Deprecated. Deprecated Since 8.0.
[NoInterfaceObject] interface PrivacyPrivilegeManager {
PermissionType checkPermission(DOMString privilege) raises(WebAPIException);
PrivilegeStatus[] checkPermissions(DOMString[] privileges) raises(WebAPIException);
void requestPermission(DOMString privilege, PermissionSuccessCallback successCallback, optional ErrorCallback? errorCallback)
raises(WebAPIException);
void requestPermissions(DOMString[] privileges, PermissionRequestSuccessCallback successCallback,
optional ErrorCallback? errorCallback) raises(WebAPIException);
};
Since: 4.0
Methods
-
checkPermission
-
Method allows checking current state of user's permission for using a privilege.
Deprecated. Deprecated Since 8.0.
PermissionType checkPermission(DOMString privilege);
Since: 4.0
For privileges not listed in application's config.xml file (or not privacy-related), always returns PPM_DENY.
Parameters:
- privilege: Privilege to be checked against user's permission.
Return value:
-
PermissionType:
State of user's permission for using specified privilege.
Exceptions:
- WebAPIException
with error type AbortError, if any platform error occurs.
with error type InvalidValuesError, if the input parameter contains an invalid value, for example empty string.
Code example:
var permission = tizen.ppm.checkPermission("http://tizen.org/privilege/contact.read"); console.log("Current state of permission is: " + permission);
Output example:
Current state of permission is: PPM_ALLOW
-
checkPermissions
-
Method allows checking current state of user's permission for using privileges.
Deprecated. Deprecated Since 8.0.
PrivilegeStatus[] checkPermissions(DOMString[] privileges);
Since: 5.0
For privileges not listed in application's config.xml file (or not privacy-related), always returns PPM_DENY. Maximum number of privileges that can be passed to array is 100.
Parameters:
- privileges: List of privileges to be checked against user's permission.
Return value:
-
PrivilegeStatus[]:
The array of status of user's permission for using specified privileges.
Exceptions:
- WebAPIException
with error type AbortError, if any platform error occurs.
with error type InvalidValuesError, if the input parameter contains an invalid value, for example if there is more than 100 privileges in privileges array.
Code example:
var privileges = ["http://tizen.org/privilege/filesystem.read", "http://tizen.org/privilege/alarm"]; var state = tizen.ppm.checkPermissions(privileges); for (v in state) { console.log("Current state of " + state[v].privilege + " is " + state[v].type); }
Output example:
Current state of http://tizen.org/privilege/filesystem.read is PPM_ALLOW Current state of http://tizen.org/privilege/alarm is PPM_DENY
-
requestPermission
-
This method allows launching pop-up for asking user to directly grant permission for given privilege.
Deprecated. Deprecated Since 8.0.
void requestPermission(DOMString privilege, PermissionSuccessCallback successCallback, optional ErrorCallback? errorCallback);
Since: 4.0
Requesting permission for privileges not listed in application's config.xml file (or not privacy-related) will not trigger any pop-up, instead the successCallback will be executed with PPM_DENY_FOREVER.
When the user has already decided to permanently allow or deny access to use a given privilege, subsequent calls of this function will result in immediate invocation of successCallback with an appropriate result: PPM_ALLOW_FOREVER or PPM_DENY_FOREVER. Additionally the asking pop-up will not be shown.
The errorCallback is launched with these error types:
- AbortError - If any platform error occurs.
Parameters:
- privilege: Privilege to be asked about user's permission.
- successCallback: Function to be invoked, if the request operation succeeded.
- errorCallback [optional] [nullable]: Function to be invoked, if the request operation failed.
Exceptions:
- WebAPIException
with error type AbortError, if any platform error occurs.
with error type InvalidValuesError, if any of the input parameters contain an invalid value, for example empty string.
with error type TypeMismatchError, if any of the input parameters is not compatible with the expected type for that parameter.
Code example:
/* Defines the error callback. */ function errorCallback(error) { console.log("The following error occurred: " + error.name); } /* Defines PermissionSuccessCallback. */ function permissionSuccess(result, privilege) { console.log("User's action for privilege " + privilege + " was to: " + result); } tizen.ppm.requestPermission( "http://tizen.org/privilege/contact.read", permissionSuccess, errorCallback);
Output example:
User's action for privilege http://tizen.org/privilege/contact.read was to: PPM_ALLOW_FOREVER
-
requestPermissions
-
This method allows launching pop-up for asking user to directly grant permission for given privileges.
Deprecated. Deprecated Since 8.0.
void requestPermissions(DOMString[] privileges, PermissionRequestSuccessCallback successCallback, optional ErrorCallback? errorCallback);
Since: 5.0
Requesting permission for privileges not listed in application's config.xml file (or not privacy-related) will not trigger any pop-up, instead the successCallback will be executed with PPM_DENY_FOREVER.
When the user has already decided to permanently allow or deny access to use a given privilege, subsequent calls of this function will result in immediate invocation of successCallback with an appropriate result: PPM_ALLOW_FOREVER or PPM_DENY_FOREVER. Additionally the asking pop-up will not be shown.
Maximum number of privileges that can be passed to array is 100.
The errorCallback is launched with these error types:
- AbortError - If any platform error occurs.
Parameters:
- privileges: List of privileges to be asked about user's permission.
- successCallback: Function to be invoked, if the request operation succeeded.
- errorCallback [optional] [nullable]: Function to be invoked, if the request operation failed.
Exceptions:
- WebAPIException
with error type AbortError, if any platform error occurs.
with error type InvalidValuesError, if any of the input parameters contain an invalid value, for example if there is more than 100 privileges in privileges array.
with error type TypeMismatchError, if any of the input parameters is not compatible with the expected type for that parameter.
Code example:
/* Defines the error callback. */ function errorCallback(error) { console.log("The following error occurred: " + error.name); } /* Defines PermissionRequestSuccessCallback. */ function permissionRequestSuccess(result) { for (v in result) { console.log( "User's action for privilege " + result[v].privilege + " was to: " + result[v].result); } } var privileges = ["http://tizen.org/privilege/contact.read", "http://tizen.org/privilege/contact.write"]; tizen.ppm.requestPermissions(privileges, permissionRequestSuccess, errorCallback);
Output example:
User's action for privilege http://tizen.org/privilege/contact.read was to: PPM_ALLOW_FOREVER User's action for privilege http://tizen.org/privilege/contact.write was to: PPM_ALLOW_FOREVER
2.3. PrivilegeStatus
Deprecated. Deprecated Since 8.0.
[NoInterfaceObject] interface PrivilegeStatus {
readonly attribute DOMString privilege;
readonly attribute PermissionType type;
};
Since: 5.0
Attributes
-
readonly
DOMString privilegePrivilege which was checked against user's permission.
Deprecated. Deprecated Since 8.0.
Since: 5.0
-
readonly
PermissionType typeState of user's permission for using specified privilege.
Deprecated. Deprecated Since 8.0.
Since: 5.0
2.4. RequestStatus
Deprecated. Deprecated Since 8.0.
[NoInterfaceObject] interface RequestStatus {
readonly attribute DOMString privilege;
readonly attribute PermissionRequestResult result;
};
Since: 5.0
Attributes
-
readonly
DOMString privilegeThe requested privilege.
Deprecated. Deprecated Since 8.0.
Since: 5.0
-
readonly
PermissionRequestResult resultResult of the action performed by user.
Deprecated. Deprecated Since 8.0.
Since: 5.0
2.5. PermissionSuccessCallback
Deprecated. Deprecated Since 8.0.
[Callback=FunctionOnly, NoInterfaceObject] interface PermissionSuccessCallback {
void onsuccess(PermissionRequestResult result, DOMString privilege);
};
Since: 4.0
Methods
-
onsuccess
-
Called when the permission for using privilege was requested successfully.
Deprecated. Deprecated Since 8.0.
void onsuccess(PermissionRequestResult result, DOMString privilege);
Since: 4.0
Parameters:
- result: Result of the action performed by user.
- privilege: The requested privilege.
Code example:
/* Defines PermissionSuccessCallback. */ function permissionSuccess(result, privilege) { console.log("User's action for privilege " + privilege + " was to: " + result); } tizen.ppm.requestPermission("http://tizen.org/privilege/callhistory.read", permissionSuccess);
Output example:
User's action for privilege http://tizen.org/privilege/callhistory.read was to: PPM_DENY_ONCE
2.6. PermissionRequestSuccessCallback
Deprecated. Deprecated Since 8.0.
[Callback=FunctionOnly, NoInterfaceObject] interface PermissionRequestSuccessCallback {
void onsuccess(RequestStatus[] result);
};
Since: 5.0
Methods
-
onsuccess
-
Called when the permission for privileges was requested successfully.
Deprecated. Deprecated Since 8.0.
void onsuccess(RequestStatus[] result);
Since: 5.0
Parameters:
- result: Result of the action performed by user.
Code example:
/* Defines the error callback. */ function errorCallback(error) { console.log("The following error occurred: " + error.name); } /* Defines PermissionRequestSuccessCallback. */ function permissionRequestSuccess(result) { for (v in result) { console.log( "User's action for privilege " + result[v].privilege + " was to: " + result[v].result); } } var privileges = ["http://tizen.org/privilege/contact.read", "http://tizen.org/privilege/contact.write"]; tizen.ppm.requestPermissions(privileges, permissionRequestSuccess, errorCallback);
Output example:
User's action for privilege http://tizen.org/privilege/contact.read was to: PPM_ALLOW_FOREVER User's action for privilege http://tizen.org/privilege/contact.write was to: PPM_ALLOW_FOREVER
3. Full WebIDL
module PrivacyPrivilege { Tizen implements PrivacyPrivilegeManagerObject; };