From: Mike Frysinger Date: Sat, 24 Aug 2013 06:22:10 +0000 (-0400) Subject: add a permission check to display a helpful message to the user X-Git-Tag: v2.1 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=ecc284d8a4bb5b0e267b80b3ed6e3cc6f6cf418f;p=chrome-ext%2Fweb-power-switch.git add a permission check to display a helpful message to the user --- diff --git a/manifest.json b/manifest.json index 65a0b89..52374ef 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "minimum_chrome_version": "22", "name": "Web Power Switch Manager", - "version": "2.0", + "version": "2.1", "description": "Quickly control Web Power Switches", "icons": { "128": "images/outlet-128x128.png" diff --git a/popup.js b/popup.js index 640aa5b..ee8659a 100644 --- a/popup.js +++ b/popup.js @@ -166,6 +166,15 @@ 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.'); + }); }); });