Bug 152526 Send Link should honour network.protocol-handler.external.mailto setting r=IanN
authorNeil Rashbrook <neil@parkwaycc.co.uk>
Sun, 22 Nov 2009 23:50:04 +0000
changeset 4434 b56cbbc73d87fda8d5816ee94c76ca861bd60c5c
parent 4433 6c647a81c780c1adf34091613b3a1e6dc101256e
child 4435 f8a53324d1af8fa066437f212b97b9b4b20e9099
push idunknown
push userunknown
push dateunknown
reviewersIanN
bugs152526
Bug 152526 Send Link should honour network.protocol-handler.external.mailto setting r=IanN
suite/browser/mailNavigatorOverlay.xul
--- a/suite/browser/mailNavigatorOverlay.xul
+++ b/suite/browser/mailNavigatorOverlay.xul
@@ -4,24 +4,27 @@
 
 <!DOCTYPE overlay SYSTEM "chrome://navigator/locale/mailNavigatorOverlay.dtd" >
 
 <overlay id="mailNavigatorOverlay"
          xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
   <script type="application/javascript">
   <![CDATA[
-    var gHasIntegratedMailClient = ("@mozilla.org/messengercompose/composeparams;1" in Components.classes);
+    var gUseExternalMailto = Application.prefs.getValue("network.protocol-handler.external.mailto", false);
 
     // attachment: 0 - link
     //             1 - page
     //             2 - image
     function openComposeWindow(url, title, attachment, charset)
     {
-      if (gHasIntegratedMailClient) {                                                                      
+      if (gUseExternalMailto) {
+        openExternalMailer(url, title);
+      }
+      else {
         var params = Components.classes["@mozilla.org/messengercompose/composeparams;1"]
                                .createInstance(Components.interfaces.nsIMsgComposeParams);
         if (params)
         {
           params.composeFields = Components.classes['@mozilla.org/messengercompose/composefields;1']
                                            .createInstance(Components.interfaces.nsIMsgCompFields);
           if (params.composeFields)
           {
@@ -54,19 +57,16 @@
               catch (ex) {
                 params.identity = null;
               }
               composeService.OpenComposeWindowWithParams(null, params);
             }
           }                                                                         
         }                                                                         
       }
-      else {
-        openExternalMailer(url, title);
-      }
     }
 
     function openExternalMailer(url, title) {
       var extProtocolSvc = Components.classes["@mozilla.org/uriloader/external-protocol-service;1"]
                                      .getService(Components.interfaces.nsIExternalProtocolService);
       var ioService = Components.classes["@mozilla.org/network/io-service;1"]
                                 .getService(Components.interfaces.nsIIOService);
       var mailto = url ? "mailto:?body="+encodeURIComponent(url)+"&subject="+encodeURIComponent(title) : "mailto:";
@@ -78,33 +78,33 @@
     function openNewCardDialog()
     {
       window.openDialog("chrome://messenger/content/addressbook/abNewCardDialog.xul",
                         "", "chrome,modal,resizable=no,centerscreen");
     }
 
     function goOpenNewMessage()
     {
-      if (gHasIntegratedMailClient) {
+      if (gUseExternalMailto) {
+        openExternalMailer();
+      }
+      else {
         if ("MsgNewMessage" in window)
         {
           MsgNewMessage(null);
           return;
         }
         
         var msgComposeService = Components.classes["@mozilla.org/messengercompose;1"].getService();
         msgComposeService = msgComposeService.QueryInterface(Components.interfaces.nsIMsgComposeService);
         msgComposeService.OpenComposeWindow(null, null, null,
                                            Components.interfaces.nsIMsgCompType.New,
                                            Components.interfaces.nsIMsgCompFormat.Default,
                                            null, null);
       }
-      else {
-        openExternalMailer();
-      }
     }
 
     function sendLink(aURL)
     {
       var title = "";
       if (!aURL) {
         aURL = window.content.document.URL;
         title = window.content.document.title;
@@ -133,34 +133,34 @@
       } catch(ex) { dump("Cannot Send Page: " + ex + "\n"); }
     }
 
     function initMailContextMenuItems(aEvent)
     {
       var shouldShowSendPage = !(gContextMenu.onTextInput || gContextMenu.isContentSelected ||
                                gContextMenu.onVideo || gContextMenu.onAudio) &&
                                !(gContextMenu.onLink && gContextMenu.onImage) &&
-                               gHasIntegratedMailClient;
+                               !gUseExternalMailto;
       gContextMenu.showItem("context-sendpage", shouldShowSendPage);
    
       gContextMenu.showItem("context-sep-apps", gContextMenu.shouldShowSeparator("context-sep-apps"));
     }
       
     function initMailContextMenuPopupListener(aEvent)
     {
       var popup = document.getElementById("contentAreaContextMenu");
       if (popup)
         popup.addEventListener("popupshowing", initMailContextMenuItems, false);
     }
 
     function hideMenuitems() {
-      document.getElementById("menu_newCard").hidden = !gHasIntegratedMailClient;
+      document.getElementById("menu_newCard").hidden = gUseExternalMailto;
       var menu_sendPage = document.getElementById("menu_sendPage");
       if (menu_sendPage)
-        menu_sendPage.hidden = !gHasIntegratedMailClient;
+        menu_sendPage.hidden = gUseExternalMailto;
     }
 
     function initOverlay(aEvent) {
       initMailContextMenuPopupListener(aEvent);
       hideMenuitems();
     }
 
     addEventListener("load", initOverlay, false);