Bug 1355462 - turn file link chrome icons into data: URLs. r=aceman a=jorgk
authorJorg K <jorgk@jorgk.com>
Mon, 17 Apr 2017 00:14:13 +0200
changeset 24471 9d19a9b732a0
parent 24470 78171c3a96f2
child 24472 7614dd8b69a9
push id2059
push usermozilla@jorgk.com
push dateMon, 17 Apr 2017 06:53:03 +0000
treeherdercomm-aurora@9d19a9b732a0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaceman, jorgk
bugs1355462
Bug 1355462 - turn file link chrome icons into data: URLs. r=aceman a=jorgk
mail/components/cloudfile/content/attachment-24.png
mail/components/cloudfile/jar.mn
mail/components/compose/content/MsgComposeCommands.js
mail/components/compose/content/cloudAttachmentLinkManager.js
deleted file mode 100644
index 1ea3ad4ad1ec95bda879317ac2c098c403aa8fa4..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
--- a/mail/components/cloudfile/jar.mn
+++ b/mail/components/cloudfile/jar.mn
@@ -1,16 +1,15 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 messenger.jar:
 *   content/messenger/cloudfile/addAccountDialog.xul (content/addAccountDialog.xul)
     content/messenger/cloudfile/addAccountDialog.js  (content/addAccountDialog.js)
-    content/messenger/cloudfile/attachment-24.png (content/attachment-24.png)
     content/messenger/cloudfile/emptySettings.xhtml (content/emptySettings.xhtml)
     content/messenger/cloudfile/Box/settings.xhtml (content/Box/settings.xhtml)
     content/messenger/cloudfile/Box/management.xhtml (content/Box/management.xhtml)
     content/messenger/cloudfile/Box/management.js (content/Box/management.js)
     content/messenger/cloudfile/Hightail/management.xhtml (content/Hightail/management.xhtml)
     content/messenger/cloudfile/Hightail/management.js (content/Hightail/management.js)
     content/messenger/cloudfile/Hightail/settings.js (content/Hightail/settings.js)
     content/messenger/cloudfile/Hightail/settings.xhtml (content/Hightail/settings.xhtml)
--- a/mail/components/compose/content/MsgComposeCommands.js
+++ b/mail/components/compose/content/MsgComposeCommands.js
@@ -5680,17 +5680,17 @@ function onUnblockResource(aURL, aNode) 
  *
  * @param {String}  aURL - (necko) URL to unblock
  * @param {Bool}    aReturnDataURL - return data: URL instead of processing image
  * @return {String} the image as data: URL.
  * @throw Error()   if reading the data failed
  */
 function loadBlockedImage(aURL, aReturnDataURL = false) {
   let filename;
-  if (/^file:/i.test(aURL)) {
+  if (/^(file|chrome):/i.test(aURL)) {
     filename = aURL.substr(aURL.lastIndexOf("/") + 1);
   }
   else {
     let fnMatch = /[?&;]filename=([^?&]+)/.exec(aURL);
     filename = (fnMatch && fnMatch[1]) || "";
   }
   filename = decodeURIComponent(filename);
   let uri = Services.io.newURI(aURL);
--- a/mail/components/compose/content/cloudAttachmentLinkManager.js
+++ b/mail/components/compose/content/cloudAttachmentLinkManager.js
@@ -374,17 +374,17 @@ var gCloudAttachmentLinkManager = {
       node.style.marginBottom = "10px";
       node.style.padding = "15px";
 
       let paperclip = aDocument.createElement("img");
       paperclip.style.marginRight = "5px";
       paperclip.style.cssFloat = "left";
       paperclip.style.width = "24px";
       paperclip.style.height = "24px";
-      paperclip.src = "chrome://messenger/content/cloudfile/attachment-24.png";
+      paperclip.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAABVUlEQVR42mNgGChgbGzMqm9slqFnbHZLz8TsPwoGioHkQGrItgBsOLrBaFjfxCydbAvgLjc2zQNymZCkmPRMzfOhllwj3wKoK9EMB4PQ0FBmJHmgWtM1eqZmS8m1gEHXxGyLnon5WlzyyGyyLMBmwKgFoxYMPgv+gdjq1ta8YL6elRhU/i+1LDgAYuuamidC+Q1geVOzzVSxQN/EPAnKvwLM0cFA+hOYb2TmRIkFH0CaDExNDbS1HXgwim1o2QMKNvIsMDafCtW4DOwLMzM1YJl0ChxUxqaNQCFGsDqgRRB1ppdIssDQ3FwLqPE7ermvY2ysDK8zEEH3RdfYWIPkIlvX1DQaasAvfVPTGBQ5E3MvoPhXiAPMYympFxoQ4W7eA/IBKIhASRRiuOkUiutnoGuzYQYi4b/AOCmjWiMAGFz2QEO3gwwGunoXiE+T1oa5uTkfKeoBW+cLhPF1+Q8AAAAASUVORK5CYII=";
       node.appendChild(paperclip);
 
       let link = this._generateLink(aDocument, aAttachment.name,
                                     aAttachment.contentLocation);
       link.setAttribute("moz-do-not-send", "true");
       node.appendChild(link);
 
       let size = aDocument.createElement("span");
@@ -395,19 +395,31 @@ var gCloudAttachmentLinkManager = {
       size.style.color = "grey";
       node.appendChild(size);
 
       let providerIdentity = aDocument.createElement("span");
       providerIdentity.style.cssFloat = "right";
 
       if (aProvider.iconClass) {
         let providerIcon = aDocument.createElement("img");
-        providerIcon.src = aProvider.iconClass;
         providerIcon.style.marginRight = "5px";
         providerIdentity.appendChild(providerIcon);
+
+        if (!/^chrome:\/\//i.test(aProvider.iconClass)) {
+          providerIcon.src = aProvider.iconClass;
+        } else {
+          try {
+            // Let's use the goodness from MsgComposeCommands.js since we're
+            // sitting right in a compose window.
+            providerIcon.src = window.loadBlockedImage(aProvider.iconClass, true);
+          } catch (e) {
+            // Couldn't load the referenced image.
+            Components.utils.reportError(e);
+          }
+        }
       }
 
       if (aProvider.serviceURL) {
         let providerLink = this._generateLink(aDocument, aProvider.displayName,
                                               aProvider.serviceURL);
         providerIdentity.appendChild(providerLink);
       } else {
         let providerName = aDocument.createElement("span");