提交 be5d0db6 编写于 作者: F fangyun

新增设置浏览器策略接口文档

Signed-off-by: Nfangyun <fangyun2@huawei.com>
上级 af50b0f1
# 接口
# 接口
- [开发说明](development-intro.md)
......@@ -414,11 +414,12 @@
- [@ohos.enterprise.accountManager (帐户管理)](js-apis-enterprise-accountManager.md)
- [@ohos.enterprise.adminManager (企业设备管理)](js-apis-enterprise-adminManager.md)
- [@ohos.enterprise.applicationManager (应用管理)](js-apis-enterprise-applicationManager.md)
- [@ohos.enterprise.browser (浏览器管理)](js-apis-enterprise-browser.md)
- [@ohos.enterprise.bundleManager (包管理)](js-apis-enterprise-bundleManager.md)
- [@ohos.enterprise.dateTimeManager (系统时间管理)](js-apis-enterprise-dateTimeManager.md)
- [@ohos.enterprise.deviceControl (设备控制管理)](js-apis-enterprise-deviceControl.md)
- [@ohos.enterprise.deviceInfo (设备信息管理)](js-apis-enterprise-deviceInfo.md)
- [@ohos.enterprise.deviceSettings (设备设置管理)](js-apis-enterprise-deviceSetings.md)
- [@ohos.enterprise.deviceSettings (设备设置管理)](js-apis-enterprise-deviceSettings.md)
- [@ohos.enterprise.EnterpriseAdminExtensionAbility (企业设备管理扩展能力)](js-apis-EnterpriseAdminExtensionAbility.md)
- [@ohos.enterprise.networkManager (网络管理)](js-apis-enterprise-networkManager.md)
- [@ohos.enterprise.wifiManager (WiFi管理)](js-apis-enterprise-wifiManager.md)
......
......@@ -30,10 +30,12 @@ OpenHarmony通过企业设备管理(Enterprise Device Management)API支持
- [@ohos.enterprise.accountManager (帐户管理)](js-apis-enterprise-accountManager.md)
- [@ohos.enterprise.adminManager (企业设备管理)](js-apis-enterprise-adminManager.md)
- [@ohos.enterprise.applicationManager (应用管理)](js-apis-enterprise-applicationManager.md)
- [@ohos.enterprise.browser (浏览器管理)](js-apis-enterprise-browser.md)
- [@ohos.enterprise.bundleManager (包管理)](js-apis-enterprise-bundleManager.md)
- [@ohos.enterprise.dateTimeManager (系统时间管理)](js-apis-enterprise-dateTimeManager.md)
- [@ohos.enterprise.deviceControl (设备控制管理)](js-apis-enterprise-deviceControl.md)
- [@ohos.enterprise.deviceInfo (设备信息管理)](js-apis-enterprise-deviceInfo.md)
- [@ohos.enterprise.deviceSettings (设备设置管理)](js-apis-enterprise-deviceSettings.md)
- [@ohos.enterprise.EnterpriseAdminExtensionAbility (企业设备管理扩展能力)](js-apis-EnterpriseAdminExtensionAbility.md)
- [@ohos.enterprise.networkManager (网络管理)](js-apis-enterprise-networkManager.md)
- [@ohos.enterprise.wifiManager (WiFi管理)](js-apis-enterprise-wifiManager.md)
\ No newline at end of file
# @ohos.enterprise.browser(浏览器管理)
本模块提供浏览器管理能力,包括设置/取消浏览器策略、获取浏览器策略等。
> **说明:**
>
> 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
>
> 本模块接口仅对[设备管理员应用](enterpriseDeviceManagement-overview.md#基本概念)开放,需将[设备管理员应用激活](js-apis-enterprise-adminManager.md#adminmanagerenableadmin)后调用,实现相应功能。
## 导入模块
```js
import browser from '@ohos.enterprise.browser';
```
## browser.setPolicies
setPolicies(admin: Want, appId: string, policies: string, callback: AsyncCallback&lt;void&gt;): void;
指定设备管理员应用设置指定浏览器的策略,使用callback形式返回是否设置成功。
**需要权限:** ohos.permission.ENTERPRISE_SET_BROWSER_POLICY
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | ------------------------------- |
| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 |
| appId | string | 是 | 应用ID,用于指定浏览器。 |
| policies | string | 是 | 浏览器策略,当参数policies为空字符串时,表示取消指定浏览器的策略。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。当接口调用成功,err为null,否则为错误对象。 |
**错误码**
以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
**示例:**
```js
let wantTemp = {
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility',
};
let appId: string = 'com.example.myapplication';
let policies: string = '{"InsecurePrivateNetworkRequestsAllowed":{"level":"mandatory","scope":"machine","source":"platform","value":true},"LegacySameSiteCookieBehaviorEnabledForDomainList":{"level":"mandatory","scope":"machine","source":"platform","value":["[*.]"]}}'
browser.setPolicies(wantTemp, appId, policies, (err) => {
if (err) {
console.error(`Failed to set browser policies. Code is ${err.code}, message is ${err.message}`);
return;
}
console.info('Succeeded in setting browser policies');
});
```
## browser.setPolicies
setPolicies(admin: Want, appId: string, policies: string): Promise&lt;void&gt;;
指定设备管理员应用设置指定浏览器的策略,使用promise形式返回是否设置成功。
**需要权限:** ohos.permission.ENTERPRISE_SET_BROWSER_POLICY
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 |
| appId | string | 是 | 应用ID,用于指定浏览器。 |
| policies | string | 是 | 浏览器策略,当参数policies为空字符串时,表示取消指定浏览器的策略。 |
**返回值:**
| 类型 | 说明 |
| --------------------- | ------------------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。当指定设备管理员应用设置浏览器策略失败时会抛出错误对象。 |
**错误码**
以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
**示例:**
```js
let wantTemp = {
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility',
};
let appId: string = 'com.example.myapplication';
let policies: string = '{"InsecurePrivateNetworkRequestsAllowed":{"level":"mandatory","scope":"machine","source":"platform","value":true},"LegacySameSiteCookieBehaviorEnabledForDomainList":{"level":"mandatory","scope":"machine","source":"platform","value":["[*.]"]}}'
browser.setPolicies(wantTemp, appId, policies).then(() => {
console.info('Succeeded in setting browser policies');
}).catch((err) => {
console.error(`Failed to set browser policies. Code is ${err.code}, message is ${err.message}`);
});
```
## browser.getPolicies
getPolicies(admin: Want, appId: string, callback: AsyncCallback&lt;string&gt;): void;
指定管理员应用获取指定浏览器的策略,使用callback形式返回获取浏览器策略。
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | ------------------------------- |
| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 |
| appId | string | 是 | 应用ID,用于指定浏览器。 |
| callback | AsyncCallback&lt;string&gt; | 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 |
**错误码**
以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
**示例:**
```js
let wantTemp = {
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility',
};
let appId: string = 'com.example.myapplication';
browser.getPolicies(wantTemp, appId, (err, result) => {
if (err) {
console.error(`Failed to get browser policies. Code is ${err.code}, message is ${err.message}`);
return;
}
console.info(`Succeeded in getting browser policies, result : ${JSON.stringify(result)}`);
});
```
## browser.getPolicies
getPolicies(admin: Want, appId: string): Promise&lt;string&gt;;
指定管理员应用获取指定浏览器的策略,使用promise形式返回获取的浏览器策略。
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 |
| appId | string | 是 | 应用ID,用于指定浏览器。 |
**返回值:**
| 类型 | 说明 |
| --------------------- | ------------------------- |
| Promise&lt;string&gt; | Promise对象,返回浏览器策略。 |
**错误码**
以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
**示例:**
```js
let wantTemp = {
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility',
};
let appId: string = 'com.example.myapplication';
browser.getPolicies(wantTemp, appId).then((result) => {
console.info(`Succeeded in getting browser policies, result : ${JSON.stringify(result)}`);
}).catch((err) => {
console.error(`Failed to get browser policies. Code is ${err.code}, message is ${err.message}`);
});
```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册