使用大多数 Chrome。*API 集成时,您的扩展程序或应用必须在清单的“权限”字段中声明其 intent。每项权限可以是已知字符串列表之一(例如“地理定位”),也可以是提供对一个或多个主机的访问权限的匹配模式。如果您的扩展程序或应用受到恶意软件入侵,权限有助于限制损害。系统还会在安装前向用户显示一些权限,详见权限警告。
如果某个 API 要求您在清单中声明某项权限,其文档会告诉您如何执行此操作。例如,存储页面介绍了如何声明“存储”权限。
以下示例展示了清单文件的权限部分:
"permissions": [
"tabs",
"bookmarks",
"http://www.blogger.com/",
"http://*.google.com/",
"unlimitedStorage"
],
下表列出了当前可用的权限:
权限 | 说明 |
---|---|
"activeTab" |
请求根据 activeTab 规范向扩展程序授予权限。 |
"alarms" |
向扩展程序授予对 chrome.alarms API 的访问权限。 |
"background" |
让 Chrome 提前启动并延迟关闭,以便延长应用和扩展程序的使用寿命。 如果任何已安装的托管应用、打包应用或扩展程序具有“后台”权限,Chrome 会在用户登录计算机后立即运行(不可见),在用户启动 Chrome 之前运行。“后台”权限还会让 Chrome 继续运行(即使是在关闭最后一个窗口之后),直至用户明确退出 Chrome。 注意:已停用的应用和扩展程序会被视为未安装。
|
"bookmarks" |
向扩展程序授予对 chrome.bookmarks API 的访问权限。 |
"browsingData" |
向您的扩展程序授予对 chrome.browsingData API 的访问权限。 |
"certificateProvider" |
向扩展程序授予对 chrome.certificateProvider API 的访问权限。 |
"clipboardRead" |
如果扩展程序或应用使用 document.execCommand('paste') ,则必须提供此属性。 |
"clipboardWrite" |
表示扩展程序或应用使用 document.execCommand('copy') 或 document.execCommand('cut') 。托管应用需要此权限;对于扩展程序和打包应用,建议此权限。 |
"contentSettings" |
向扩展程序授予对 chrome.contentSettings API 的访问权限。 |
"contextMenus" |
向扩展程序授予对 chrome.contextMenus API 的访问权限。 |
"cookies" |
向扩展程序授予对 chrome.cookies API 的访问权限。 |
"debugger" |
向扩展程序授予对 chrome.debugger API 的访问权限。 |
"declarativeContent" |
向扩展程序授予对 chrome.declarativeContent API 的访问权限。 |
"declarativeNetRequest" |
向扩展程序授予对 chrome.declarativeNetRequest API 的访问权限。 |
"declarativeNetRequestFeedback" |
向扩展程序授予对 chrome.declarativeNetRequest API 中返回有关匹配的声明式规则的信息的事件和方法的访问权限。 |
"declarativeWebRequest" |
向扩展程序授予对 chrome.declarativeWebRequest API 的访问权限。 |
"desktopCapture" |
向扩展程序授予对 chrome.desktopCapture API 的访问权限。 |
"documentScan" |
向扩展程序授予对 chrome.documentScan API 的访问权限。 |
"downloads" |
向扩展程序授予对 chrome.downloads API 的访问权限。 |
"enterprise.deviceAttributes" |
向您的扩展程序授予对 chrome.enterprise.deviceAttributes API 的访问权限。 |
"enterprise.hardwarePlatform" |
向扩展程序授予对 chrome.enterprise.hardwarePlatform API 的访问权限。 |
"enterprise.networkingAttributes" |
向您的扩展程序授予对 chrome.enterprise.networkingAttributes API 的访问权限。 |
"enterprise.platformKeys" |
向您的扩展程序授予对 chrome.enterprise.platformKeys API 的访问权限。 |
"experimental" |
如果扩展程序或应用使用任何 chrome.experimental.* API 相关联。 |
"fileBrowserHandler" |
向扩展程序授予对 chrome.fileBrowserHandler API 的访问权限。 |
"fileSystemProvider" |
向扩展程序授予对 chrome.fileSystemProvider API 的访问权限。 |
"fontSettings" |
向扩展程序授予对 chrome.fontSettings API 的访问权限。 |
"gcm" |
向扩展程序授予对 chrome.gcm API 的访问权限。 |
"geolocation" |
允许扩展程序或应用在不提示用户授予权限的情况下使用 geolocation API。 |
"history" |
向扩展程序授予对 chrome.history API 的访问权限。 |
"identity" |
向扩展程序授予对 chrome.identity API 的访问权限。 |
"idle" |
向扩展程序授予对 chrome.idle API 的访问权限。 |
"loginState" |
向扩展程序授予对 chrome.loginState API 的访问权限。 |
"management" |
向扩展程序授予对 chrome.management API 的访问权限。 |
"nativeMessaging" |
向扩展程序授予对原生消息传递 API 的访问权限。 |
"notifications" |
向扩展程序授予对 chrome.notifications API 的访问权限。 |
"pageCapture" |
向扩展程序授予对 chrome.pageCapture API 的访问权限。 |
"platformKeys" |
向扩展程序授予对 chrome.platformKeys API 的访问权限。 |
"power" |
向扩展程序授予对 chrome.power API 的访问权限。 |
"printerProvider" |
向扩展程序授予对 chrome.printerProvider API 的访问权限。 |
"printing" |
向扩展程序授予对 chrome.printing API 的访问权限。 |
"printingMetrics" |
向扩展程序授予对 chrome.printingMetrics API 的访问权限。 |
"privacy" |
向扩展程序授予对 chrome.privacy API 的访问权限。 |
"processes" |
向扩展程序授予对 chrome.processes API 的访问权限。 |
"proxy" |
向扩展程序授予对 chrome.proxy API 的访问权限。 |
"scripting" |
向扩展程序授予对 chrome.scripting API 的访问权限。 |
"search" |
向扩展程序授予对 chrome.search API 的访问权限。 |
"sessions" |
向扩展程序授予对 chrome.sessions API 的访问权限。 |
"signedInDevices" |
向扩展程序授予对 chrome.signedInDevices API 的访问权限。 |
"storage" |
向扩展程序授予对 chrome.storage API 的访问权限。 |
"system.cpu" |
向扩展程序授予对 chrome.system.cpu API 的访问权限。 |
"system.display" |
向扩展程序授予对 chrome.system.display API 的访问权限。 |
"system.memory" |
向扩展程序授予对 chrome.system.memory API 的访问权限。 |
"system.storage" |
向扩展程序授予对 chrome.system.storage API 的访问权限。 |
"tabCapture" |
向扩展程序授予对 chrome.tabCapture API 的访问权限。 |
"tabGroups" |
向扩展程序授予对 chrome.tabGroups API 的访问权限。 |
"tabs" |
向扩展程序授予对多个 API(包括 chrome.tabs 和 chrome.windows)使用的 Tab 对象的特权字段的访问权限。在许多情况下,您的扩展程序无需声明 "tabs" 权限即可使用这些 API。 |
"topSites" |
向扩展程序授予对 chrome.topSites API 的访问权限。 |
"tts" |
向扩展程序授予对 chrome.tts API 的访问权限。 |
"ttsEngine" |
向扩展程序授予对 chrome.ttsEngine API 的访问权限。 |
"unlimitedStorage" |
提供无限配额来存储客户端数据,例如数据库和本地存储文件。
如果没有此权限,扩展程序或应用的本地存储空间上限为 5 MB。 注意:此权限仅适用于 Web SQL 数据库和应用缓存(请参阅问题 58985)。此外,它目前也不支持
http://*.example.com 等通配符子网域。 |
"vpnProvider" |
向扩展程序授予对 chrome.vpnProvider API 的访问权限。 |
"wallpaper" |
向扩展程序授予对 chrome.wallpaper API 的访问权限。 |
"webNavigation" |
向扩展程序授予对 chrome.webNavigation API 的访问权限。 |
"webRequest" |
向扩展程序授予对 chrome.webRequest API 的访问权限。 |
"webRequestBlocking" |
如果该扩展程序以阻塞方式使用 chrome.webRequest API,则必须使用此 API。 |