2014-10-03 156 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