Google chrome extension “起源”是什么意思;chrome.permissions.request“;?
我正在开发谷歌浏览器的扩展 我需要的是可选权限 根据文档,用户可以根据需要请求权限。代码是这样的:Google chrome extension “起源”是什么意思;chrome.permissions.request“;?,google-chrome-extension,Google Chrome Extension,我正在开发谷歌浏览器的扩展 我需要的是可选权限 根据文档,用户可以根据需要请求权限。代码是这样的: document.querySelector('#my-button').addEventListener('click', function(event) { // Permissions must be requested from inside a user gesture, like a button's // click handler. chrome.permissions
document.querySelector('#my-button').addEventListener('click', function(event) {
// Permissions must be requested from inside a user gesture, like a button's
// click handler.
chrome.permissions.request({
permissions: ['tabs'],
origins: ['http://www.google.com/']
}, function(granted) {
// The callback argument will be true if the user granted the permissions.
if (granted) {
doSomething();
} else {
doSomethingElse();
}
});
});
的起源是什么:['http://www.google.com/“]
是指传递给chrome.permissions.request的对象中的“]
?来源是URL的一部分,如protocol://hostnameWhat 如果我将www.google.com
更改为其他域,如www.yahoo.com
,会发生什么情况?1)您将在对话框中看到不同的站点,2)将允许扩展访问不同的站点。这与我的扩展有关吗?我还是很困惑。该权限用于“选项卡”,与谷歌或任何详细网站无关。然后指定”
,或者根本不指定来源
参数。