[英]Chrome Extension Declare Permissions confusion
Simple extension to assign a keyboard shortcut to the high contrast setting so as to toggle it without going through menu's. 简单扩展,可将键盘快捷方式分配给高对比度设置,从而无需通过菜单即可切换它。 Problem: The code below is producing this error
问题:下面的代码正在产生此错误
ChromeSetting.get: You do not have permission to access the preference 'highContrast'.
ChromeSetting.get:您无权访问首选项“ highContrast”。 Be sure to declare in your manifest what permissions you need.
确保在清单中声明所需的权限。
The intro to this API https://developer.chrome.com/extensions/accessibilityFeatures#property-highContrast says to declare accessibilityFeatures.modify
and accessibilityFeatures.read
which I've done, however both these permissions are not on the declared permissions list https://developer.chrome.com/extensions/declare_permissions so I'm not sure where to go from here... 该API的简介https://developer.chrome.com/extensions/accessibilityFeatures#property-highContrast声明了我已经完成的
accessibilityFeatures.modify
和accessibilityFeatures.read
声明,但是这两个权限都不在声明的权限列表中https ://developer.chrome.com/extensions/declare_permissions,所以我不确定从这里去哪里...
manifest.json 的manifest.json
{
"name": "High Contrast Shortcut",
"description": "Press Ctrl+Shift+Y to send an event.",
"version": "1.0",
"default_locale": "en",
"manifest_version": 2,
"background": {
"scripts": ["src/bg/background.js"],
"persistent": true
},
"permissions": [
"accessibilityFeatures.read",
"accessibilityFeatures.modify"
],
"commands": {
"toggle-feature": {
"suggested_key": { "default": "Ctrl+Shift+Y" },
"description": "Send a 'toggle-feature' event to the extension"
}
}
}
background.js background.js
chrome.commands.onCommand.addListener(function(command) {
if (command == "toggle-feature") {
var value = chrome.accessibilityFeatures.highContrast.get({'incognito': false}, function (callback) {
console.log(callback);
});
}
});
"accessibilityFeatures.read"
and "accessibilityFeatures.modify"
are currently only supported in Chrome OS, not on other operating systems, as seen in https://chromium.googlesource.com/chromium/src/+/7c61e0145f3e598ae7a9ac69159234d6ec7f6008/chrome/common/extensions/api/_permission_features.json : "accessibilityFeatures.read"
和"accessibilityFeatures.modify"
目前仅支持Chrome操作系统,而不是在其它操作系统上,如看到https://chromium.googlesource.com/chromium/src/+/7c61e0145f3e598ae7a9ac69159234d6ec7f6008/chrome/common/ extensions / api / _permission_features.json :
"accessibilityFeatures.modify": {
"channel": "stable",
"extension_types": ["extension", "platform_app"],
"platforms": ["chromeos"]
},
"accessibilityFeatures.read": {
"channel": "stable",
"extension_types": ["extension", "platform_app"],
"platforms": ["chromeos"]
},
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.