X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=popup.js;h=742962dd074def469fca2bed4e2743b8b7176888;hb=5268e625c576d5a92915e8eb32c587fbc9cab673;hp=640aa5bb0c03ea23440fabdb54a3e2351106cec8;hpb=8191f7e7ff96c3ce118c29d285f89fc9835ad281;p=chrome-ext%2Fweb-power-switch.git diff --git a/popup.js b/popup.js index 640aa5b..742962d 100644 --- a/popup.js +++ b/popup.js @@ -166,6 +166,24 @@ document.addEventListener('DOMContentLoaded', function() { url_base = settings['url'] || settings_defaults['url']; user = settings['user'] || settings_defaults['user']; pass = settings['pass'] || settings_defaults['pass']; - fetchpage('index.htm', initpopup); + chrome.permissions.contains({ + origins: [url_base + '/*'] + }, function(granted) { + if (granted) { + fetchpage('index.htm', initpopup); + } else { + setstatus( + 'Missing permissions;
please visit the ' + + 'settings page' + + '
to grant access.
' + + '
' + ); + // Work around http://crbug.com/125706. + document.getElementById('retry').onclick = function() { + chrome.permissions.request({origins: [url_base + '/*']}); + fetchpage('index.htm', initpopup); + }; + } + }); }); });