Bug 1613562 - Add a permission for modifying draft messages. r=mkmelin
authorGeoff Lankow <geoff@darktrojan.net>
Thu, 06 Feb 2020 15:26:19 +1300
changeset 38091 ef09d4e957808535d27b33c5d2ff627216afb53e
parent 38090 33e611ec360536dec3aff23b0cd998019ffbef39
child 38092 dbc7f4937bb1a317544c21b5f3ed0a6684bcc30f
push id398
push userclokep@gmail.com
push dateMon, 09 Mar 2020 19:10:28 +0000
reviewersmkmelin
bugs1613562
Bug 1613562 - Add a permission for modifying draft messages. r=mkmelin
mail/components/extensions/schemas/compose.json
mail/components/extensions/test/browser/browser_ext_compose_details.js
mail/components/extensions/test/browser/browser_ext_compose_onBeforeSend.js
mail/locales/en-US/chrome/messenger/addons.properties
--- a/mail/components/extensions/schemas/compose.json
+++ b/mail/components/extensions/schemas/compose.json
@@ -1,10 +1,26 @@
 [
   {
+    "namespace": "manifest",
+    "types": [
+      {
+        "$extend": "OptionalPermission",
+        "choices": [
+          {
+            "type": "string",
+            "enum": [
+              "compose"
+            ]
+          }
+        ]
+      }
+    ]
+  },
+  {
     "namespace": "compose",
     "types": [
       {
         "id": "ComposeRecipient",
         "choices": [
           {
             "type": "string",
             "description": "A name and email address in the format \"Name <email@example.com>\", or just an email address."
@@ -95,16 +111,19 @@
         }
       }
     ],
     "events": [
       {
         "name": "onBeforeSend",
         "type": "function",
         "description": "Fired when a message is about to be sent from the compose window.",
+        "permissions": [
+          "compose"
+        ],
         "parameters": [
           {
             "name": "details",
             "$ref": "ComposeDetails",
             "description": "The current state of the compose window. This is functionally the same as the :ref:`compose.getComposeDetails` function."
           }
         ],
         "returns": {
@@ -187,29 +206,35 @@
           }
         ]
       },
       {
         "name": "getComposeDetails",
         "type": "function",
         "async": true,
         "description": "Fetches the current state of a compose window. Currently only a limited amount of information is available, more will be added in later versions.",
+        "permissions": [
+          "compose"
+        ],
         "parameters": [
           {
             "type": "integer",
             "name": "tabId",
             "minimum": 0
           }
         ]
       },
       {
         "name": "setComposeDetails",
         "type": "function",
         "async": true,
         "description": "Updates the compose window. Specify only fields that you want to change. Currently only the to/cc/bcc/replyTo/followupTo/newsgroups fields and the subject are implemented.",
+        "permissions": [
+          "compose"
+        ],
         "parameters": [
           {
             "type": "integer",
             "name": "tabId",
             "minimum": 0
           },
           {
             "name": "details",
--- a/mail/components/extensions/test/browser/browser_ext_compose_details.js
+++ b/mail/components/extensions/test/browser/browser_ext_compose_details.js
@@ -234,17 +234,19 @@ add_task(async () => {
 
       let removedWindowPromise = waitForEvent("onRemoved");
       browser.windows.remove(createdWindow.id);
       await removedWindowPromise;
 
       await browser.addressBooks.delete(addressBook);
       browser.test.notifyPass("finished");
     },
-    manifest: { permissions: ["accountsRead", "addressBooks", "messagesRead"] },
+    manifest: {
+      permissions: ["accountsRead", "addressBooks", "compose", "messagesRead"],
+    },
   });
 
   extension.onMessage("checkWindow", async expected => {
     await checkComposeHeaders(expected);
     extension.sendMessage();
   });
 
   await extension.startup();
--- a/mail/components/extensions/test/browser/browser_ext_compose_onBeforeSend.js
+++ b/mail/components/extensions/test/browser/browser_ext_compose_onBeforeSend.js
@@ -167,17 +167,17 @@ add_task(async () => {
       // Clean up.
 
       let removedWindowPromise = waitForEvent("onRemoved");
       browser.windows.remove(createdWindow.id);
       await removedWindowPromise;
 
       browser.test.notifyPass("finished");
     },
-    manifest: { permissions: ["accountsRead", "messagesRead"] },
+    manifest: { permissions: ["accountsRead", "compose", "messagesRead"] },
   });
 
   // We can't allow sending to actually happen, this is a test. For every
   // compose window that opens, replace the function which does the actual
   // sending with one that only records when it has been called.
   let didTryToSendMessage = false;
   ExtensionSupport.registerWindowListener("xpcshell", {
     chromeURLs: [
--- a/mail/locales/en-US/chrome/messenger/addons.properties
+++ b/mail/locales/en-US/chrome/messenger/addons.properties
@@ -153,16 +153,17 @@ webextPerms.optionalPermsDeny.accessKey=
 webextPerms.description.accountsFolders=Create, rename, or delete your mail account folders
 webextPerms.description.accountsRead=See your mail accounts and their folders
 webextPerms.description.addressBooks=Read and modify your address books and contacts
 webextPerms.description.bookmarks=Read and modify bookmarks
 webextPerms.description.browserSettings=Read and modify browser settings
 webextPerms.description.browsingData=Clear recent browsing history, cookies, and related data
 webextPerms.description.clipboardRead=Get data from the clipboard
 webextPerms.description.clipboardWrite=Input data to the clipboard
+webextPerms.description.compose=Read and modify your email messages as you compose and send them
 webextPerms.description.devtools=Extend developer tools to access your data in open tabs
 webextPerms.description.dns=Access IP address and hostname information
 webextPerms.description.downloads=Download files and read and modify the browser’s download history
 webextPerms.description.downloads.open=Open files downloaded to your computer
 webextPerms.description.find=Read the text of all open tabs
 webextPerms.description.geolocation=Access your location
 webextPerms.description.history=Access browsing history
 webextPerms.description.management=Monitor extension usage and manage themes