Fixing bug 470356. Make the cookie dialogs open up modal to their origin tabs chrome window so that the dialog is centered on the window, and no centered on the screen. r=dwitte@stanford.edu, sr+a=jst@mozilla.org

This commit is contained in:
Ben Newman 2009-01-22 21:33:10 -08:00
parent 876f275609
commit 389ba41804

View File

@ -39,6 +39,7 @@
#include "nsICookie.h"
#include "nsICookieAcceptDialog.h"
#include "nsIDOMWindow.h"
#include "nsPIDOMWindow.h"
#include "nsIWindowWatcher.h"
#include "nsIServiceManager.h"
#include "nsString.h"
@ -93,11 +94,22 @@ nsCookiePromptService::CookieDialog(nsIDOMWindow *aParent,
nsCOMPtr<nsISupports> arguments = do_QueryInterface(block);
nsCOMPtr<nsIDOMWindow> dialog;
// Given the nature of this dialog and the frequency of it popping
// up for those few users that have it enabled we do not want this
// dialog to be parented at a window. Pass in nsnull as the
// parent. See bug 405239 for more details.
rv = wwatcher->OpenWindow(nsnull, "chrome://cookie/content/cookieAcceptDialog.xul", "_blank",
nsCOMPtr<nsIDOMWindow> parent(aParent);
if (!parent) // if no parent provided, consult the window watcher:
wwatcher->GetActiveWindow(getter_AddRefs(parent));
if (parent) {
nsCOMPtr<nsPIDOMWindow> privateParent(do_QueryInterface(parent));
if (privateParent)
privateParent = privateParent->GetPrivateRoot();
parent = do_QueryInterface(privateParent);
}
// The cookie dialog will be modal for the root chrome window rather than the
// tab containing the permission-requesting page. This removes confusion
// about which monitor is displaying the dialog (see bug 470356), but also
// avoids unwanted tab switches (see bug 405239).
rv = wwatcher->OpenWindow(parent, "chrome://cookie/content/cookieAcceptDialog.xul", "_blank",
"centerscreen,chrome,modal,titlebar", arguments,
getter_AddRefs(dialog));