Bug 662203 - Enhance openLocation so that it can be used by message compose r=neil
authorIan Neal <iann_cvs@blueyonder.co.uk>
Tue, 05 Jul 2011 16:46:25 +0100
changeset 8274 8c885c3fc9acbf97cfd9d6044137f62cc379bdf0
parent 8273 2bfa709f04ce425daf07825f288140b27dfb74b3
child 8275 72f40b7e9357b68a2fe8ca356e5aba049604ff9c
push idunknown
push userunknown
push dateunknown
reviewersneil
bugs662203
Bug 662203 - Enhance openLocation so that it can be used by message compose r=neil
editor/ui/composer/content/ComposerCommands.js
mailnews/compose/content/MsgAttachPage.js
mailnews/compose/content/MsgAttachPage.xul
mailnews/jar.mn
suite/browser/navigator.js
suite/common/openLocation.js
suite/common/openLocation.xul
suite/locales/en-US/chrome/common/openLocation.dtd
suite/locales/en-US/chrome/common/openLocation.properties
suite/locales/en-US/chrome/mailnews/compose/MsgAttachPage.dtd
suite/locales/en-US/chrome/mailnews/compose/composeMsgs.properties
suite/locales/jar.mn
suite/mailnews/compose/MsgComposeCommands.js
--- a/editor/ui/composer/content/ComposerCommands.js
+++ b/editor/ui/composer/content/ComposerCommands.js
@@ -2167,17 +2167,17 @@ var nsOpenRemoteCommand =
     return true;    // we can always do this
   },
 
   getCommandStateParams: function(aCommand, aParams, aRefCon) {},
   doCommandParams: function(aCommand, aParams, aRefCon) {},
 
   doCommand: function(aCommand)
   {
-    var params = { browser: null, action: null, url: "" };
+    var params = { action: "2", url: "" };
     openDialog( "chrome://communicator/content/openLocation.xul", "_blank", "chrome,modal,titlebar", params);
     var win = getTopWin();
     switch (params.action) {
       case "0": // current window
         win.focus();
         win.loadURI(params.url, null,
                     nsIWebNavigation.LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP);
         break;
deleted file mode 100644
--- a/mailnews/compose/content/MsgAttachPage.js
+++ /dev/null
@@ -1,118 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- *
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Communicator client code, released
- * March 31, 1998.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Michael Lowe   <michael.lowe@bigfoot.com>
- *   Blake Ross     <blaker@netscape.com>
- *   Neil Rashbrook <neil@parkwaycc.co.uk>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-var browser;
-var dialog = {};
-var pref = null;
-try {
-  pref = Components.classes["@mozilla.org/preferences-service;1"]
-                   .getService(Components.interfaces.nsIPrefBranch);
-} catch (ex) {
-  // not critical, remain silent
-}
-
-function onLoad()
-{
-  dialog.input = document.getElementById("dialog.input");
-  dialog.attach = document.documentElement.getButton("accept");
-  dialog.bundle = document.getElementById("attachWebPageBundle");
-
-  // change OK button text to 'attach'
-  dialog.attach.label = dialog.bundle.getString("attachButtonLabel");
-
-  if (pref) {
-    try {
-      dialog.input.value =
-        pref.getComplexValue("mailnews.attach_web_page.last_url",
-          Components.interfaces.nsISupportsString).data;
-    }
-    catch(ex) {
-    }
-  }
-
-  doEnabling();
-}
-
-function doEnabling()
-{
-  dialog.attach.disabled = !dialog.input.value;
-}
-
-function attach()
-{
-  var attachment = Components.classes["@mozilla.org/messengercompose/attachment;1"]
-                             .createInstance(Components.interfaces.nsIMsgAttachment);
-  attachment.url = dialog.input.value;
-  window.arguments[0].attachment = attachment;
-  if (pref) {
-    var str = Components.classes["@mozilla.org/supports-string;1"]
-                        .createInstance(Components.interfaces.nsISupportsString);
-    str.data = dialog.input.value;
-    pref.setComplexValue("mailnews.attach_web_page.last_url",
-                         Components.interfaces.nsISupportsString, str);
-  }
-  return true;
-}
-
-function onChooseFile()
-{
-  try {
-    var fp = Components.classes["@mozilla.org/filepicker;1"]
-                       .createInstance(Components.interfaces.nsIFilePicker);
-    fp.init(window, dialog.bundle.getString("chooseFileDialogTitle"), fp.modeOpen);
-    fp.appendFilters(fp.filterHTML | fp.filterText |
-                     fp.filterAll | fp.filterImages | fp.filterXML);
-    if (fp.show() == fp.returnOK && fp.fileURL.spec && fp.fileURL.spec.length > 0)
-      dialog.input.value = fp.fileURL.spec;
-  }
-  catch(ex) {
-  }
-  doEnabling();
-}
-
-function useUBHistoryItem(aMenuItem)
-{
-  var urlbar = document.getElementById("dialog.input");
-  urlbar.value = aMenuItem.getAttribute("label");
-  urlbar.select();
-  doEnabling();
-}
deleted file mode 100644
--- a/mailnews/compose/content/MsgAttachPage.xul
+++ /dev/null
@@ -1,77 +0,0 @@
-<?xml version="1.0"?> 
-
-<!-- ***** BEGIN LICENSE BLOCK *****
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
-
- The contents of this file are subject to the Mozilla Public License Version
- 1.1 (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
- http://www.mozilla.org/MPL/
-
- Software distributed under the License is distributed on an "AS IS" basis,
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- for the specific language governing rights and limitations under the
- License.
-
- The Original Code is Mozilla Communicator client code, released
- March 31, 1998.
-
- The Initial Developer of the Original Code is
- Netscape Communications Corporation.
- Portions created by the Initial Developer are Copyright (C) 1998-1999
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
-   Ben Goodger <ben@netscape.com>
-   Michael Lowe <michael.lowe@bigfoot.com>
-   Neil Rashbrook <neil@parkwaycc.co.uk>
-
- Alternatively, the contents of this file may be used under the terms of
- either of the GNU General Public License Version 2 or later (the "GPL"),
- or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- in which case the provisions of the GPL or the LGPL are applicable instead
- of those above. If you wish to allow use of your version of this file only
- under the terms of either the GPL or the LGPL, and not to allow others to
- use your version of this file under the terms of the MPL, indicate your
- decision by deleting the provisions above and replace them with the notice
- and other provisions required by the GPL or the LGPL. If you do not delete
- the provisions above, a recipient may use your version of this file under
- the terms of any one of the MPL, the GPL or the LGPL.
-
- ***** END LICENSE BLOCK ***** -->
-
-<?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
-
-<!DOCTYPE dialog SYSTEM "chrome://messenger/locale/messengercompose/MsgAttachPage.dtd">
-
-<dialog id="MsgAttachPage"
-        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
-        title="&caption.label;"
-        onload="onLoad();"
-        ondialogaccept="return attach();"
-        style="width: 40em;"
-        persist="screenX screenY"
-        screenX="24" screenY="24">
-
-  <script type="application/javascript" src="chrome://messenger/content/messengercompose/MsgAttachPage.js"/>
-  <script type="application/javascript" src="chrome://navigator/content/sessionHistoryUI.js"/>
-
-  <stringbundle id="attachWebPageBundle" src="chrome://messenger/locale/messengercompose/composeMsgs.properties"/>
-
-  <label value="&enter.label;" control="dialog.input" accesskey="&enter.accesskey;"/>
-  <separator class="thin"/>
-
-  <hbox align="center">
-    <textbox id="dialog.input" flex="1" type="autocomplete"
-              autocompletesearch="history" timeout="50" maxrows="6"
-              enablehistory="true" class="uri-element"
-              oninput="doEnabling();">
-      <menupopup id="ubhist-popup" class="autocomplete-history-popup"
-                 popupalign="topleft" popupanchor="bottomleft"
-                 onpopupshowing="createUBHistoryMenu(event.target);"
-                 oncommand="useUBHistoryItem(event.target);"/>
-    </textbox>
-    <button label="&chooseFile.label;" accesskey="&chooseFile.accesskey;" oncommand="onChooseFile();"/>
-  </hbox>
-
-</dialog>
--- a/mailnews/jar.mn
+++ b/mailnews/jar.mn
@@ -106,18 +106,16 @@ messenger.jar:
     content/messenger/FilterEditor.js                                          (base/search/content/FilterEditor.js)
 *   content/messenger/searchWidgets.xml                                        (base/search/content/searchWidgets.xml)
     content/messenger/viewLog.xul                                              (base/search/content/viewLog.xul)
     content/messenger/viewLog.js                                               (base/search/content/viewLog.js)
     content/messenger/messengercompose/askSendFormat.js                        (compose/content/askSendFormat.js)
     content/messenger/messengercompose/askSendFormat.xul                       (compose/content/askSendFormat.xul)
     content/messenger/messengercompose/sendProgress.xul                        (compose/content/sendProgress.xul)
     content/messenger/messengercompose/sendProgress.js                         (compose/content/sendProgress.js)
-    content/messenger/messengercompose/MsgAttachPage.xul                       (compose/content/MsgAttachPage.xul)
-    content/messenger/messengercompose/MsgAttachPage.js                        (compose/content/MsgAttachPage.js)
     content/messenger/messengercompose/mailComposeEditorOverlay.xul            (compose/content/mailComposeEditorOverlay.xul)
 *   content/messenger/importDialog.js                                          (import/content/importDialog.js)
 *   content/messenger/importDialog.xul                                         (import/content/importDialog.xul)
     content/messenger/fieldMapImport.xul                                       (import/content/fieldMapImport.xul)
     content/messenger/fieldMapImport.js                                        (import/content/fieldMapImport.js)
     content/messenger/downloadheaders.js                                       (news/content/downloadheaders.js)
     content/messenger/downloadheaders.xul                                      (news/content/downloadheaders.xul)
     content/messenger/markByDate.js                                            (base/content/markByDate.js)
--- a/suite/browser/navigator.js
+++ b/suite/browser/navigator.js
@@ -1292,17 +1292,17 @@ function QualifySearchTerm()
   return "";
 }
 
 //Note: BrowserNewEditorWindow() was moved to globalOverlay.xul and renamed to NewEditorWindow()
 
 function BrowserOpenWindow()
 {
   //opens a window where users can select a web location to open
-  var params = { browser: window, action: null, url: "" };
+  var params = { action: "0", url: "" };
   openDialog("chrome://communicator/content/openLocation.xul", "_blank", "chrome,modal,titlebar", params);
   var postData = { };
   var url = getShortcutOrURI(params.url, postData);
   switch (params.action) {
     case "0": // current window
       loadURI(url, null, postData.value, true);
       break;
     case "1": // new window
--- a/suite/common/openLocation.js
+++ b/suite/common/openLocation.js
@@ -19,141 +19,142 @@
  * The Initial Developer of the Original Code is
  * Netscape Communications Corporation.
  * Portions created by the Initial Developer are Copyright (C) 1998
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Michael Lowe <michael.lowe@bigfoot.com>
  *   Blake Ross   <blaker@netscape.com>
+ *   Neil Rashbrook <neil@parkwaycc.co.uk>
+ *   Ian Neal <iann_bugzilla@blueyonder.co.uk>
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either of the GNU General Public License Version 2 or later (the "GPL"),
  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  * in which case the provisions of the GPL or the LGPL are applicable instead
  * of those above. If you wish to allow use of your version of this file only
  * under the terms of either the GPL or the LGPL, and not to allow others to
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-var browser;
-var dialog = {};
-var pref = null;
-try {
-  pref = Components.classes["@mozilla.org/preferences-service;1"]
-                   .getService(Components.interfaces.nsIPrefBranch);
-} catch (ex) {
-  // not critical, remain silent
-}
+var gInput;
+var gAcceptButton;
+var gLastPref = "general.open_location.last_url";
+var gOpenAppList;
+var gBundle;
+var gAction;
 
 function onLoad()
 {
-  dialog.input          = document.getElementById("dialog.input");
-  dialog.open           = document.documentElement.getButton("accept");
-  dialog.openAppList    = document.getElementById("openAppList");
-  dialog.openTopWindow  = document.getElementById("currentWindow");
-  dialog.openNewWindow  = document.getElementById("newWindow");
-  dialog.openEditWindow = document.getElementById("editWindow");
-  dialog.openNewTab     = document.getElementById("newTab");
-  dialog.bundle         = document.getElementById("openLocationBundle");
+  gInput = document.getElementById("dialog.input");
+  gAcceptButton = document.documentElement.getButton("accept");
+  gOpenAppList = document.getElementById("openAppList");
+  gBundle = document.getElementById("openLocationBundle");
+  gAction = window.arguments[0].action;
+  // Set arguments action to prevent problems on cancel.
+  window.arguments[0].action = "-1";
 
-  browser = window.arguments[0].browser;
-   
-  if (!browser) {
-    // No browser supplied - we are calling from Composer
-    dialog.openAppList.selectedItem = dialog.openEditWindow;
+  switch (gAction) {
+    case "4": // attach web page
+      document.title = gBundle.getString("attachTitle");
+      document.getElementById("enterLabel").value = gBundle.getString("attachEnterLabel");
+      document.getElementById("openWhereBox").setAttribute("hidden", true);
+
+      // Change accept button text to 'attach'.
+      gAcceptButton.label = gBundle.getString("attachButtonLabel");
+      gLastPref = "mailnews.attach_web_page.last_url";
+
+      break;
 
-    // Change string to make more sense for Composer
-    dialog.openTopWindow.setAttribute("label", dialog.bundle.getString("existingNavigatorWindow"));
+    case "2": // open web page from composer
+      gOpenAppList.selectedItem = document.getElementById("editWindow");
+      var openTopWindow = document.getElementById("currentTab");
 
-    // Find most recent browser window
-    var windowManager = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService();
-    var windowManagerInterface = windowManager.QueryInterface( Components.interfaces.nsIWindowMediator);
-    if (windowManagerInterface)
-      browser = windowManagerInterface.getMostRecentWindow( "navigator:browser" );
+      // Change string to make more sense for Composer.
+      openTopWindow.setAttribute("label",
+                                 gBundle.getString("existingNavigatorWindow"));
 
-    // Disable "current browser" item if no browser is open
-    if (!browser) {
-      dialog.openTopWindow.setAttribute("disabled", "true");
-      dialog.openNewTab.setAttribute("disabled", "true");
-    }
-  }
-  else {
-    dialog.openAppList.selectedItem = dialog.openTopWindow;
+      // Disable existing browser and new tab menuitems and create indicator
+      // if no browser windows found.
+      if (!Services.wm.getMostRecentWindow("navigator:browser")) {
+        openTopWindow.setAttribute("disabled", "true");
+        document.getElementById("newTab").setAttribute("disabled", "true");
+        gAction = "-1";
+      }
+      break;
+
+    default: // open web page
+      gOpenAppList.value = Services.prefs.getIntPref("general.open_location.last_window_choice");
   }
 
-  if (pref) {
-    try {
-      dialog.openAppList.value = pref.getIntPref("general.open_location.last_window_choice");
-      dialog.input.value = pref.getComplexValue("general.open_location.last_url",
-                                                Components.interfaces.nsISupportsString).data;
-    }
-    catch(ex) {
-    }
-    if (dialog.input.value)
-      dialog.input.select(); // XXX should probably be done automatically
-  }
+  gInput.value = GetStringPref(gLastPref);
+  if (gInput.value)
+    gInput.select(); // XXX should probably be done automatically
 
   doEnabling();
 }
 
 function doEnabling()
 {
-    dialog.open.disabled = !dialog.input.value;
+  gAcceptButton.disabled = !gInput.value;
 }
 
-function open()
+function accept()
 {
   var params = window.arguments[0];
-  params.url = dialog.input.value;
-  params.action = dialog.openAppList.value;
-  if (!browser && params.action != "2")
-    params.action = "1";
+  params.url = gInput.value;
+  if (gAction != "4") { // open web page
+    params.action = gOpenAppList.value;
+    // If there were no browser windows open and not set to open in composer
+    // then set to open in a new window.
+    if (gAction == "-1" && params.action != "2")
+      params.action = "1";
 
-  if (pref) {
-    var str = Components.classes["@mozilla.org/supports-string;1"]
-                        .createInstance(Components.interfaces.nsISupportsString);
-    str.data = dialog.input.value;
-    pref.setComplexValue("general.open_location.last_url",
-                         Components.interfaces.nsISupportsString, str);
-    pref.setIntPref("general.open_location.last_window_choice", dialog.openAppList.value);
+    // If open web page from navigator window, save last window choice.
+    if (gAction == "0")
+      Services.prefs.setIntPref("general.open_location.last_window_choice",
+                                gOpenAppList.value);
   }
+
+  var str = Components.classes["@mozilla.org/supports-string;1"]
+                      .createInstance(Components.interfaces.nsISupportsString);
+  str.data = gInput.value;
+  Services.prefs.setComplexValue(gLastPref,
+                                 Components.interfaces.nsISupportsString, str);
 }
 
-const nsIFilePicker = Components.interfaces.nsIFilePicker;
 function onChooseFile()
 {
+  const nsIFilePicker = Components.interfaces.nsIFilePicker;
   try {
     var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
-    fp.init(window, dialog.bundle.getString("chooseFileDialogTitle"), nsIFilePicker.modeOpen);
-    if (dialog.openAppList.value == "2") {
-      // When loading into Composer, direct user to prefer HTML files and text files,
-      // so we call separately to control the order of the filter list
+    fp.init(window, gBundle.getString("chooseFileDialogTitle"), nsIFilePicker.modeOpen);
+    if (window.arguments[0].action != "4" && gOpenAppList.value == "2") {
+      // When loading into Composer, direct user to prefer HTML files and text
+      // files, so we call separately to control the order of the filter list.
       fp.appendFilters(nsIFilePicker.filterHTML | nsIFilePicker.filterText);
-      fp.appendFilters(nsIFilePicker.filterText);
       fp.appendFilters(nsIFilePicker.filterAll);
     }
     else {
       fp.appendFilters(nsIFilePicker.filterHTML | nsIFilePicker.filterText |
                        nsIFilePicker.filterAll | nsIFilePicker.filterImages | nsIFilePicker.filterXML);
     }
 
     if (fp.show() == nsIFilePicker.returnOK && fp.fileURL.spec && fp.fileURL.spec.length > 0)
-      dialog.input.value = fp.fileURL.spec;
+      gInput.value = fp.fileURL.spec;
   }
   catch(ex) {
   }
   doEnabling();
 }
 
-function useUBHistoryItem(aMenuItem)
+function useUBHistoryItem(aValue)
 {
-  var urlbar = document.getElementById("dialog.input");
-  urlbar.value = aMenuItem.getAttribute("label");
-  urlbar.focus();
+  gInput.value = aValue;
+  gInput.focus();
   doEnabling();
 }
-
--- a/suite/common/openLocation.xul
+++ b/suite/common/openLocation.xul
@@ -19,16 +19,18 @@
  The Initial Developer of the Original Code is
  Netscape Communications Corporation.
  Portions created by the Initial Developer are Copyright (C) 1998-1999
  the Initial Developer. All Rights Reserved.
 
  Contributor(s):
    Ben Goodger <ben@netscape.com>
    Michael Lowe <michael.lowe@bigfoot.com>
+   Neil Rashbrook <neil@parkwaycc.co.uk>
+   Ian Neal <iann_bugzilla@blueyonder.co.uk>
 
  Alternatively, the contents of this file may be used under the terms of
  either of the GNU General Public License Version 2 or later (the "GPL"),
  or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  in which case the provisions of the GPL or the LGPL are applicable instead
  of those above. If you wish to allow use of your version of this file only
  under the terms of either the GPL or the LGPL, and not to allow others to
  use your version of this file under the terms of the MPL, indicate your
@@ -47,54 +49,60 @@
   <!ENTITY % openDialogDTD SYSTEM "chrome://communicator/locale/openLocation.dtd" >
   %openDialogDTD;
 ]>            
  
 <dialog id="openLocation"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="&caption.label;"
         onload="onLoad()"
-        ondialogaccept="open()"
+        ondialogaccept="return accept();"
         buttonlabelaccept="&open.label;"
         style="width: 40em;"
         persist="screenX screenY"
         screenX="24" screenY="24">
               
   <script type="application/javascript" src="chrome://global/content/globalOverlay.js"/>  
   <script type="application/javascript" src="chrome://communicator/content/openLocation.js"/>
   <script type="application/javascript" src="chrome://communicator/content/utilityOverlay.js"/>
   <script type="application/javascript" src="chrome://navigator/content/sessionHistoryUI.js"/>
   
   <stringbundle id="openLocationBundle" src="chrome://communicator/locale/openLocation.properties"/>
 
   <hbox>
     <separator orient="vertical" class="thin"/>
     <vbox flex="1">
-      <label value="&enter.label;" control="dialog.input" accesskey="&enter.accesskey;"/>
+      <label id="enterLabel"
+             value="&enter.label;"
+             control="dialog.input"
+             accesskey="&enter.accesskey;"/>
       <separator class="thin"/>
 
       <hbox align="center">
         <textbox id="dialog.input" flex="1" type="autocomplete"
                   autocompletesearch="history file" timeout="50" maxrows="6"
                   enablehistory="true" class="uri-element"
                   oninput="doEnabling();">
           <menupopup id="ubhist-popup" class="autocomplete-history-popup"
                      popupalign="topleft" popupanchor="bottomleft"
                      onpopupshowing="createUBHistoryMenu(event.target);"
-                     oncommand="useUBHistoryItem(event.target)"/>
+                     oncommand="useUBHistoryItem(event.target.label);"/>
         </textbox>
         <button label="&chooseFile.label;" accesskey="&chooseFile.accesskey;" oncommand="onChooseFile();"/>
       </hbox>
-      <hbox align="center">
+      <hbox id="openWhereBox" align="center">
         <label value="&openWhere.label;" accesskey="&openWhere.accesskey;" control="openAppList"/>
         <menulist id="openAppList">
           <menupopup>
-            <menuitem value="0" id="currentWindow" label="&topWindow.label;"/>
+            <menuitem value="0"
+                      id="currentTab"
+                      label="&currentTab.label;"
+                      selected="true"/>
+            <menuitem value="3" id="newTab" label="&newTab.label;"/>
             <menuitem value="1" id="newWindow" label="&newWindow.label;"/>
-            <menuitem value="3" id="newTab" label="&newTab.label;"/>
             <menuseparator/>
             <menuitem value="2" id="editWindow" label="&editNewWindow.label;"/>
           </menupopup>
         </menulist>
         <spacer flex="1"/>
       </hbox>
     </vbox>
   </hbox> 
--- a/suite/locales/en-US/chrome/common/openLocation.dtd
+++ b/suite/locales/en-US/chrome/common/openLocation.dtd
@@ -1,14 +1,17 @@
 <!-- extracted from content/openLocation.xul -->
 
-<!ENTITY enter.label "Enter the web location (URL), or specify the local file you would like to open:">  
+<!ENTITY enter.label "Enter the web location (URL), or specify the local file you would like to open:">
+<!-- LOCALIZATION NOTE (enter.accesskey): should be present in both enter.label
+     as defined above and attachEnterLabel as defined in
+     openLocation.properties -->
 <!ENTITY enter.accesskey "E">
 <!ENTITY chooseFile.label "Choose File…">
 <!ENTITY chooseFile.accesskey "C">
 <!ENTITY newWindow.label "New browser window">
 <!ENTITY newTab.label "New browser tab">
-<!ENTITY topWindow.label "Current browser window">
+<!ENTITY currentTab.label "Current browser tab">
 <!ENTITY editNewWindow.label "New Composer window">
 <!ENTITY open.label "Open">
 <!ENTITY caption.label "Open Web Location">
 <!ENTITY openWhere.label "Open in:">
 <!ENTITY openWhere.accesskey "O">
--- a/suite/locales/en-US/chrome/common/openLocation.properties
+++ b/suite/locales/en-US/chrome/common/openLocation.properties
@@ -1,2 +1,7 @@
+attachTitle=Attach Web Page
+# LOCALIZATION NOTE (attachEnterLabel): should contain "enter.accesskey"
+# as defined in openLocation.dtd
+attachEnterLabel=Enter the web location (URL), or specify the local file you would like to attach:
+attachButtonLabel=Attach
 chooseFileDialogTitle=Choose File
 existingNavigatorWindow=Existing browser window
deleted file mode 100644
--- a/suite/locales/en-US/chrome/mailnews/compose/MsgAttachPage.dtd
+++ /dev/null
@@ -1,40 +0,0 @@
-<!-- ***** BEGIN LICENSE BLOCK *****
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
-
- The contents of this file are subject to the Mozilla Public License Version
- 1.1 (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
- http://www.mozilla.org/MPL/
-
- Software distributed under the License is distributed on an "AS IS" basis,
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- for the specific language governing rights and limitations under the
- License.
-
- The Original Code is Attach Web Page Dialog.
-
- The Initial Developer of the Original Code is Neil Rashbrook.
- Portions created by the Initial Developer are Copyright (C) 2004
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
-
- Alternatively, the contents of this file may be used under the terms of
- either of the GNU General Public License Version 2 or later (the "GPL"),
- or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- in which case the provisions of the GPL or the LGPL are applicable instead
- of those above. If you wish to allow use of your version of this file only
- under the terms of either the GPL or the LGPL, and not to allow others to
- use your version of this file under the terms of the MPL, indicate your
- decision by deleting the provisions above and replace them with the notice
- and other provisions required by the GPL or the LGPL. If you do not delete
- the provisions above, a recipient may use your version of this file under
- the terms of any one of the MPL, the GPL or the LGPL.
-
- ***** END LICENSE BLOCK ***** -->
-
-<!ENTITY caption.label "Attach Web Page">
-<!ENTITY enter.label "Enter the web location (URL), or specify the local file you would like to attach:">
-<!ENTITY enter.accesskey "E">
-<!ENTITY chooseFile.label "Choose File…">
-<!ENTITY chooseFile.accesskey "C">
--- a/suite/locales/en-US/chrome/mailnews/compose/composeMsgs.properties
+++ b/suite/locales/en-US/chrome/mailnews/compose/composeMsgs.properties
@@ -280,20 +280,16 @@ sendMsgTitle=Send Message
 subjectDlogMessage=You did not specify a subject for this message. If you would like to provide one, please type it now.
 
 ## String used by the dialog that informs the user about the newsgroup recipient
 recipientDlogMessage=This account only supports email recipients. Continuing will ignore newsgroups.
 
 #String used by the alert that tells the user an e-mail address is invalid
 addressInvalid=%1$S is not a valid e-mail address because it is not of the form user@host. You must correct it before sending the e-mail.
 
-## String used by the dialog that ask the user to attach a web page
-attachButtonLabel=Attach
-chooseFileDialogTitle=Choose File
-
 ## String used for attachment pretty name, when attachment is a message
 messageAttachmentSafeName=Attached Message
 ## String used for attachment pretty name, when attachment is message part
 partAttachmentSafeName=Attached Message Part
 
 ## String used by the Initialization Error dialog
 initErrorDlogTitle=Message Compose
 initErrorDlgMessage=An error occurred while creating a message compose window. Please try again.
--- a/suite/locales/jar.mn
+++ b/suite/locales/jar.mn
@@ -268,17 +268,16 @@
   locale/@AB_CD@/messenger/messenger.dtd                                    (%chrome/mailnews/messenger.dtd)
   locale/@AB_CD@/messenger/messenger.properties                             (%chrome/mailnews/messenger.properties)
   locale/@AB_CD@/messenger/messengercompose/addressingWidgetOverlay.dtd     (%chrome/mailnews/compose/addressingWidgetOverlay.dtd)
   locale/@AB_CD@/messenger/messengercompose/askSendFormat.dtd               (%chrome/mailnews/compose/askSendFormat.dtd)
   locale/@AB_CD@/messenger/messengercompose/askSendFormat.properties        (%chrome/mailnews/compose/askSendFormat.properties)
   locale/@AB_CD@/messenger/messengercompose/composeMsgs.properties          (%chrome/mailnews/compose/composeMsgs.properties)
   locale/@AB_CD@/messenger/messengercompose/mailComposeEditorOverlay.dtd    (%chrome/mailnews/compose/mailComposeEditorOverlay.dtd)
   locale/@AB_CD@/messenger/messengercompose/messengercompose.dtd            (%chrome/mailnews/compose/messengercompose.dtd)
-  locale/@AB_CD@/messenger/messengercompose/MsgAttachPage.dtd               (%chrome/mailnews/compose/MsgAttachPage.dtd)
   locale/@AB_CD@/messenger/messengercompose/pref-composing_messages.dtd     (%chrome/mailnews/pref/pref-composing_messages.dtd)
   locale/@AB_CD@/messenger/messengercompose/pref-formatting.dtd             (%chrome/mailnews/pref/pref-formatting.dtd)
   locale/@AB_CD@/messenger/messengercompose/sendProgress.dtd                (%chrome/mailnews/compose/sendProgress.dtd)
   locale/@AB_CD@/messenger/messengercompose/sendProgress.properties         (%chrome/mailnews/compose/sendProgress.properties)
   locale/@AB_CD@/messenger/mime.properties                                  (%chrome/mailnews/mime.properties)
   locale/@AB_CD@/messenger/mimeheader.properties                            (%chrome/mailnews/mimeheader.properties)
   locale/@AB_CD@/messenger/msgAccountCentral.dtd                            (%chrome/mailnews/msgAccountCentral.dtd)
   locale/@AB_CD@/messenger/msgFolderPickerOverlay.dtd                       (%chrome/mailnews/msgFolderPickerOverlay.dtd)
--- a/suite/mailnews/compose/MsgComposeCommands.js
+++ b/suite/mailnews/compose/MsgComposeCommands.js
@@ -2636,20 +2636,27 @@ function MessageHasAttachments()
 function MessageGetNumSelectedAttachments()
 {
   var bucketList = document.getElementById("attachmentBucket");
   return (bucketList) ? bucketList.selectedItems.length : 0;
 }
 
 function AttachPage()
 {
-  var result = { attachment: null };
-  window.openDialog("chrome://messenger/content/messengercompose/MsgAttachPage.xul", "_blank", "chrome,close,titlebar,modal", result);
-  if (result.attachment)
-    AddAttachment(result.attachment);
+  var params = { action: "4", url: null };
+  window.openDialog("chrome://communicator/content/openLocation.xul",
+                    "_blank", "chrome,close,titlebar,modal", params);
+  if (params.url)
+  {
+    var attachment =
+        Components.classes["@mozilla.org/messengercompose/attachment;1"]
+                  .createInstance(Components.interfaces.nsIMsgAttachment);
+    attachment.url = params.url;
+    AddAttachment(attachment);
+  }
 }
 
 function DuplicateFileCheck(FileUrl)
 {
   var bucket = document.getElementById('attachmentBucket');
   for (let i = 0; i < bucket.childNodes.length; i++)
   {
     let attachment = bucket.childNodes[i].attachment;