diff --git a/zh-cn/application-dev/reference/apis/Readme-CN.md b/zh-cn/application-dev/reference/apis/Readme-CN.md index 65b7259c43d51c7a0e5bfe68dfb9258137947bb8..ae703d68b1dd7ece1ba100e589daa62ff56627de 100644 --- a/zh-cn/application-dev/reference/apis/Readme-CN.md +++ b/zh-cn/application-dev/reference/apis/Readme-CN.md @@ -1,4 +1,4 @@ -# 接口 +# 接口 - [开发说明](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) diff --git a/zh-cn/application-dev/reference/apis/enterpriseDeviceManagement-overview.md b/zh-cn/application-dev/reference/apis/enterpriseDeviceManagement-overview.md index 927d323ef285e6544935a94d8b890252b3096b06..be99f3a246431e7ae135cbca06607e6f9bea7da4 100644 --- a/zh-cn/application-dev/reference/apis/enterpriseDeviceManagement-overview.md +++ b/zh-cn/application-dev/reference/apis/enterpriseDeviceManagement-overview.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 diff --git a/zh-cn/application-dev/reference/apis/js-apis-enterprise-browser.md b/zh-cn/application-dev/reference/apis/js-apis-enterprise-browser.md new file mode 100644 index 0000000000000000000000000000000000000000..6fb74fb06c82f4870d00f778b1b9a4c2649b9bbc --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-enterprise-browser.md @@ -0,0 +1,205 @@ +# @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<void>): 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<void> | 是 | 回调函数。当接口调用成功,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<void>; + +指定设备管理员应用设置指定浏览器的策略,使用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<void> | 无返回结果的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<string>): void; + +指定管理员应用获取指定浏览器的策略,使用callback形式返回获取浏览器策略。 + +**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager + +**系统API**: 此接口为系统接口。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ------------------------------- | +| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 | +| appId | string | 是 | 应用ID,用于指定浏览器。 | +| callback | AsyncCallback<string> | 是 | 回调函数,当接口调用成功,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<string>; + +指定管理员应用获取指定浏览器的策略,使用promise形式返回获取的浏览器策略。 + +**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager + +**系统API**: 此接口为系统接口。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ----- | ----------------------------------- | ---- | ------- | +| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 | +| appId | string | 是 | 应用ID,用于指定浏览器。 | + +**返回值:** + +| 类型 | 说明 | +| --------------------- | ------------------------- | +| Promise<string> | 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}`); +}); +``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-enterprise-deviceSetings.md b/zh-cn/application-dev/reference/apis/js-apis-enterprise-deviceSettings.md similarity index 100% rename from zh-cn/application-dev/reference/apis/js-apis-enterprise-deviceSetings.md rename to zh-cn/application-dev/reference/apis/js-apis-enterprise-deviceSettings.md