Bug 1374779 - Open address book dialog from privileged window. r=bz
--- a/mailnews/addrbook/src/nsAbContentHandler.cpp
+++ b/mailnews/addrbook/src/nsAbContentHandler.cpp
@@ -8,16 +8,18 @@
#include "nsNetUtil.h"
#include "nsCOMPtr.h"
#include "nsAutoPtr.h"
#include "NullPrincipal.h"
#include "nsISupportsPrimitives.h"
#include "plstr.h"
#include "nsPIDOMWindow.h"
#include "mozIDOMWindow.h"
+#include "nsIDocShell.h"
+#include "nsIDocShellTreeItem.h"
#include "nsMsgUtils.h"
#include "nsIMsgVCardService.h"
#include "nsIAbCard.h"
#include "nsIAbManager.h"
#include "nsVCard.h"
#include "nsIChannel.h"
//
// nsAbContentHandler
@@ -84,19 +86,24 @@ nsAbContentHandler::HandleContent(const
nsCOMPtr<nsISupportsInterfacePointer> ifptr =
do_CreateInstance(NS_SUPPORTS_INTERFACE_POINTER_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
ifptr->SetData(cardFromVCard);
ifptr->SetDataIID(&NS_GET_IID(nsIAbCard));
- nsCOMPtr<nsPIDOMWindowOuter> dialogWindow;
+ // Find a privileged chrome window to open the dialog from.
+ nsCOMPtr<nsIDocShell> docShell(parentWindow->GetDocShell());
+ nsCOMPtr<nsIDocShellTreeItem> root;
+ docShell->GetRootTreeItem(getter_AddRefs(root));
+ nsCOMPtr<nsPIDOMWindowOuter> window(do_GetInterface(root));
- rv = parentWindow->OpenDialog(
+ nsCOMPtr<nsPIDOMWindowOuter> dialogWindow;
+ rv = window->OpenDialog(
NS_LITERAL_STRING("chrome://messenger/content/addressbook/abNewCardDialog.xul"),
EmptyString(),
NS_LITERAL_STRING("chrome,resizable=no,titlebar,modal,centerscreen"),
ifptr, getter_AddRefs(dialogWindow));
NS_ENSURE_SUCCESS(rv, rv);
}
rv = NS_OK;
}