]> git.wh0rd.org Git - chrome-ext/web-power-switch.git/commitdiff
add a permission check to display a helpful message to the user v2.1
authorMike Frysinger <vapier@gentoo.org>
Sat, 24 Aug 2013 06:22:10 +0000 (02:22 -0400)
committerMike Frysinger <vapier@gentoo.org>
Sat, 24 Aug 2013 06:22:24 +0000 (02:22 -0400)
manifest.json
popup.js

index 65a0b897e18cf699870826a3bd9e67dfd10b9a08..52374ef95a4cf95a988408d23c89f427b1ec9f1d 100644 (file)
@@ -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"
index 640aa5bb0c03ea23440fabdb54a3e2351106cec8..ee8659a379a048c2c4eb4742bd7ef5af6c7b942c 100644 (file)
--- 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;<br>please visit the ' +
+                                         '<a href="' + chrome.extension.getURL('options.html') + '" target=_blank>settings page</a>' +
+                                         '<br>to grant access.');
+               });
        });
 });