]> git.wh0rd.org - chrome-ext/web-power-switch.git/blobdiff - popup.js
smooth over the permission workaround
[chrome-ext/web-power-switch.git] / popup.js
index ee8659a379a048c2c4eb4742bd7ef5af6c7b942c..742962dd074def469fca2bed4e2743b8b7176888 100644 (file)
--- a/popup.js
+++ b/popup.js
@@ -169,12 +169,21 @@ document.addEventListener('DOMContentLoaded', function() {
                chrome.permissions.contains({
                        origins: [url_base + '/*']
                }, function(granted) {
-                       if (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.');
+                       } else {
+                               setstatus(
+                                       'Missing permissions;<br>please visit the ' +
+                                       '<a href="' + chrome.extension.getURL('options.html') + '" target=_blank>settings page</a>' +
+                                       '<br>to grant access.<br>' +
+                                       '<center><input id=retry type=submit value=Retry></center>'
+                               );
+                               // Work around http://crbug.com/125706.
+                               document.getElementById('retry').onclick = function() {
+                                       chrome.permissions.request({origins: [url_base + '/*']});
+                                       fetchpage('index.htm', initpopup);
+                               };
+                       }
                });
        });
 });