Let features request optional host permissions

Sometimes a feature requires additional host permissions to work. This
change allows features to request this.

This change has changed the structure of requiredOptPermissions in the
optionsPrototype.json5 file from being an array of string permissions to
being an object of type chrome.permissions.Permissions (an object
containing property permissions (an array of (string) permissions, as
before) and property origins (an array of (string) hosts).

Bug: twpowertools:86, twpowertools:87
Change-Id: Iacdc6f928876942e213488b12e12f950da7b7c05
diff --git a/src/common/optionsUtils.js b/src/common/optionsUtils.js
index f4009ed..d8045f6 100644
--- a/src/common/optionsUtils.js
+++ b/src/common/optionsUtils.js
@@ -1,4 +1,4 @@
-import {grantedOptPermissions, missingPermissions} from './optionsPermissions.js';
+import {grantedOptPermissions, isPermissionsObjectEmpty, missingPermissions} from './optionsPermissions.js';
 import optionsPrototype from './optionsPrototype.json5';
 import specialOptions from './specialOptions.json5';
 
@@ -45,7 +45,7 @@
 
     Promise.all(permissionChecksPromises).then(missingPerms => {
       for (let i = 0; i < permissionChecksFeatures.length; i++)
-        if (missingPerms[i].length > 0)
+        if (!isPermissionsObjectEmpty(missingPerms[i]))
           items[permissionChecksFeatures[i]] = false;
 
       return items;
@@ -112,10 +112,12 @@
              // If we don't have access to the chrome.permissions API (content
              // scripts don't have access to it[1]), do the final piece of
              // computation in the service worker/background script.
-             // [1]: https://developer.chrome.com/docs/extensions/mv3/content_scripts/
+             // [1]:
+             // https://developer.chrome.com/docs/extensions/mv3/content_scripts/
 
              // #!if !production
-             console.debug('We are about to start checking granted permissions');
+             console.debug(
+                 'We are about to start checking granted permissions');
              console.timeLog(timeLabel);
              // #!endif
              if (!chrome.permissions) {