网页网站您现在的位置是:首页 > 博客日志 > 网页网站

Chrome扩展程序开发 declare permissions 声明权限

<a href='mailto:'>微wx笑</a>的头像微wx笑 2022-09-30网页网站 5 0关键字: Chrome  扩展程序  extensions  

为了能够使用更多chrome.* APIs,您的扩展必须在清单的权限字段中声明其意图。扩展可以请求三类权限,这些权限是使用清单中的相应键指定的:

为了能够使用更多chrome.* APIs,您的扩展必须在清单的权限字段中声明其意图。扩展可以请求三类权限,这些权限是使用清单中的相应键指定的:wW0无知


wW0无知

  • permissions contain items from a list of known strings (such as "geolocation")wW0无知

  • optional_permissions are like regular permissions, but are granted by the extension's user at runtime, rather than in advancewW0无知

  • host_permissions contain one or more match patterns that give access to one or more hostswW0无知

Permissions help to limit damage if your extension is compromised by malware. Some permissions are displayed to users for their consent before installation or at runtime as needed, as detailed in Permission Warnings.wW0无知

You should use optional permissions wherever the functionality of your extension permits, to provide users with informed control over access to resources and data. See the platform vision to better understand this recommendation.wW0无知

If an API requires you to declare a permission in the manifest, then its documentation tells you how to do so. For example, the Storage page shows you how to declare the "storage" permission.wW0无知

Here's an example of the permissions part of a manifest file:wW0无知

"permissions": [  "tabs",  "bookmarks",  "unlimitedStorage"],"optional_permissions": [  "unlimitedStorage"],"host_permissions": [  "http://www.blogger.com/",  "http://*.google.com/"],

The following table lists the currently available permissions:wW0无知

PermissionDescription
"activeTab"Requests that the extension be granted permissions according to the activeTab specification.
"alarms"Gives your extension access to the chrome.alarms API.
"background"

Makes Chrome start up early and shut down late, so that extensions can have a longer life.wW0无知

When any installed extension has "background" permission, Chrome runs (invisibly) as soon as the user logs into their computer—before the user launches Chrome. The "background" permission also makes Chrome continue running (even after its last window is closed) until the user explicitly quits Chrome.wW0无知

Note: Disabled extensions are treated as if they aren't installed.

You should use the "background" permission with background scripts.wW0无知

"bookmarks"
  • 读取和更改您的书签wW0无知

Gives your extension access to the chrome.bookmarks API.wW0无知

"browsingData"Gives your extension access to the chrome.browsingData API.
"certificateProvider"Gives your extension access to the chrome.certificateProvider API.
"clipboardRead"
  • 读取您复制和粘贴的数据wW0无知

Required if the extension uses document.execCommand('paste').wW0无知

"clipboardWrite"
  • 修改您复制和粘贴的数据wW0无知

Required if the extension uses document.execCommand('copy') or document.execCommand('cut').wW0无知

"contentSettings"
  • 更改您用于控制以下权限的设置:网站对 Cookie、JavaScript、插件、地理位置信息、麦克风、摄像头等功能的使用权限。wW0无知

Gives your extension access to the chrome.contentSettings API.wW0无知

"contextMenus"Gives your extension access to the chrome.contextMenus API.
"cookies"Gives your extension access to the chrome.cookies API.
"debugger"
  • 访问页面调试程序后端wW0无知

  • 读取和更改您在所有网站上的数据wW0无知

Gives your extension access to the chrome.debugger API.wW0无知

"declarativeContent"Gives your extension access to the chrome.declarativeContent API.
"declarativeNetRequest"Gives your extension access to the chrome.declarativeNetRequest API.
"declarativeNetRequestFeedback"Grants the extension access to events and methods within the chrome.declarativeNetRequest API which return information on declarative rules matched.
"declarativeWebRequest"Gives your extension access to the chrome.declarativeWebRequest API.
"desktopCapture"
  • 截取您屏幕上的内容wW0无知

Gives your extension access to the chrome.desktopCapture API.wW0无知

"documentScan"Gives your extension access to the chrome.documentScan API.
"downloads"
  • 管理您的下载内容wW0无知

Gives your extension access to the chrome.downloads API.wW0无知

"enterprise.deviceAttributes"Gives your extension access to the chrome.enterprise.deviceAttributes API.
"enterprise.hardwarePlatform"Gives your extension access to the chrome.enterprise.hardwarePlatform API.
"enterprise.networkingAttributes"Gives your extension access to the chrome.enterprise.networkingAttributes API.
"enterprise.platformKeys"Gives your extension access to the chrome.enterprise.platformKeys API.
"experimental"Required if the extension uses any chrome.experimental.* APIs.
"fileBrowserHandler"Gives your extension access to the chrome.fileBrowserHandler API.
"fileSystemProvider"Gives your extension access to the chrome.fileSystemProvider API.
"fontSettings"Gives your extension access to the chrome.fontSettings API.
"gcm"Gives your extension access to the chrome.gcm API.
"geolocation"Allows the extension to use the geolocation API without prompting the user for permission.
"history"
  • 读取和更改您的浏览记录wW0无知

Gives your extension access to the chrome.history API.wW0无知

"identity"Gives your extension access to the chrome.identity API.
"idle"Gives your extension access to the chrome.idle API.
"loginState"Gives your extension access to the chrome.loginState API.
"management"Gives your extension access to the chrome.management API.
"nativeMessaging"
  • 与协作的本机应用通信wW0无知

Gives your extension access to the native messaging API.wW0无知

"notifications"
  • 显示通知wW0无知

Gives your extension access to the chrome.notifications API.wW0无知

"pageCapture"Gives your extension access to the chrome.pageCapture API.
"platformKeys"Gives your extension access to the chrome.platformKeys API.
"power"Gives your extension access to the chrome.power API.
"printerProvider"Gives your extension access to the chrome.printerProvider API.
"printing"Gives your extension access to the chrome.printing API.
"printingMetrics"Gives your extension access to the chrome.printingMetrics API.
"privacy"Gives your extension access to the chrome.privacy API.
"processes"Gives your extension access to the chrome.processes API.
"proxy"Gives your extension access to the chrome.proxy API.
"scripting"Gives your extension access to the chrome.scripting API.
"search"Gives your extension access to the chrome.search API.
"sessions"Gives your extension access to the chrome.sessions API.
"signedInDevices"Gives your extension access to the chrome.signedInDevices API.
"storage"Gives your extension access to the chrome.storage API.
"system.cpu"Gives your extension access to the chrome.system.cpu API.
"system.display"Gives your extension access to the chrome.system.display API.
"system.memory"Gives your extension access to the chrome.system.memory API.
"system.storage"Gives your extension access to the chrome.system.storage API.
"tabCapture"Gives your extension access to the chrome.tabCapture API.
"tabGroups"Gives your extension access to the chrome.tabGroups API.
"tabs"Gives your extension access to privileged fields of the Tab objects used by several APIs including chrome.tabs and chrome.windows. In many circumstances your extension will not need to declare the "tabs" permission to make use of these APIs.
"topSites"Gives your extension access to the chrome.topSites API.
"tts"Gives your extension access to the chrome.tts API.
"ttsEngine"Gives your extension access to the chrome.ttsEngine API.
"unlimitedStorage"Provides an unlimited quota for storing client-side data, such as databases and local storage files. Without this permission, the extension is limited to 5 MB of local storage.
Note: This permission applies only to Web SQL Database and application cache (see issue 58985). Also, it doesn't currently work with wildcard subdomains such as http://*.example.com.
"vpnProvider"Gives your extension access to the chrome.vpnProvider API.
"wallpaper"Gives your extension access to the chrome.wallpaper API.
"webNavigation"Gives your extension access to the chrome.webNavigation API.
"webRequest"Gives your extension access to the chrome.webRequest API.
"webRequestBlocking"Required if the extension uses the chrome.webRequest API in a blocking fashion.

Last updated: Wednesday, May 21, 2014 Improve articlewW0无知


wW0无知

原文:https://developer.chrome.com/extensions/declare_permissionswW0无知


wW0无知

本文由 微wx笑 创作,采用 署名-非商业性使用-相同方式共享 4.0 许可协议,转载请附上原文出处链接及本声明。
原文链接:https://www.ivu4e.cn/blog/web/2022-09-30/1395.html

很赞哦! () 有话说 ()