2014-10-03 119 views
1

简单扩展键盘快捷方式分配给高对比度设置,以便将其切换,而无需通过菜单的打算。问题:以下代码产生此错误Chrome扩展声明权限混乱

ChromeSetting.get:您无权访问首选项'highContrast'。一定要在你的清单中声明你需要的权限。

前奏这个API https://developer.chrome.com/extensions/accessibilityFeatures#property-highContrast说申报accessibilityFeatures.modifyaccessibilityFeatures.read我已经做了,但是这两种权限都没有申报的权限列表https://developer.chrome.com/extensions/declare_permissions上,所以我不知道在哪里何去何从?

的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

chrome.commands.onCommand.addListener(function(command) { 
    if (command == "toggle-feature") { 

    var value = chrome.accessibilityFeatures.highContrast.get({'incognito': false}, function (callback) { 
     console.log(callback); 
    }); 
    } 
}); 

回答

0

"accessibilityFeatures.read""accessibilityFeatures.modify"目前仅支持在Chrome OS,而不是在其它操作系统上,如在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"] 
    }, 
+0

如何适当提高有关文档的错误?因为这是一个严重的失误。 – Xan 2014-10-03 09:17:05

+0

@Xan在问题跟踪,就像这样:https://code.google.com/p/chromium/issues/detail?id=420014 – 2014-10-03 09:23:13

+0

我在Chromebook因此编辑设置应为我工作,但在哪里我添加了这个代码?到权限标签? – 2014-10-03 18:12:09