2002-09-17 18:51:22 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
2012-05-31 09:33:35 +00:00
|
|
|
* 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/. */
|
2002-09-17 18:51:22 +00:00
|
|
|
|
|
|
|
#include "nsNSSDialogHelper.h"
|
|
|
|
#include "nsIWindowWatcher.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIComponentManager.h"
|
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsIInterfaceRequestor.h"
|
|
|
|
#include "nsIInterfaceRequestorUtils.h"
|
2013-12-12 01:51:58 +00:00
|
|
|
#include "mozilla/dom/ScriptSettings.h"
|
2002-09-17 18:51:22 +00:00
|
|
|
|
2010-03-12 06:50:10 +00:00
|
|
|
static const char kOpenDialogParam[] = "centerscreen,chrome,modal,titlebar";
|
|
|
|
static const char kOpenWindowParam[] = "centerscreen,chrome,titlebar";
|
2002-09-17 18:51:22 +00:00
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsNSSDialogHelper::openDialog(
|
2011-07-15 10:31:34 +00:00
|
|
|
nsIDOMWindow *window,
|
2002-09-17 18:51:22 +00:00
|
|
|
const char *url,
|
2010-03-12 06:50:10 +00:00
|
|
|
nsISupports *params,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool modal)
|
2002-09-17 18:51:22 +00:00
|
|
|
{
|
2015-04-23 20:35:49 +00:00
|
|
|
#ifdef MOZ_WIDGET_GONK
|
|
|
|
// On b2g devices, we need to proxy the dialog creation & management
|
|
|
|
// to Gaia.
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
#endif
|
|
|
|
|
2002-09-17 18:51:22 +00:00
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsIWindowWatcher> windowWatcher =
|
|
|
|
do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
2011-07-15 10:31:34 +00:00
|
|
|
nsCOMPtr<nsIDOMWindow> parent = window;
|
2002-09-17 18:51:22 +00:00
|
|
|
|
|
|
|
if (!parent) {
|
2011-07-15 10:31:34 +00:00
|
|
|
windowWatcher->GetActiveWindow(getter_AddRefs(parent));
|
2002-09-17 18:51:22 +00:00
|
|
|
}
|
|
|
|
|
2013-08-22 22:51:34 +00:00
|
|
|
// We're loading XUL into this window, and it's happening on behalf of the
|
|
|
|
// system, not on behalf of content. Make sure the initial about:blank window
|
|
|
|
// gets a system principal, otherwise we'll bork when trying to wrap the
|
|
|
|
// nsIKeyGenThread |arguments| property into the unprivileged scoope.
|
|
|
|
MOZ_ASSERT(!strncmp("chrome://", url, strlen("chrome://")));
|
2014-04-15 03:27:00 +00:00
|
|
|
mozilla::dom::AutoNoJSAPI nojsapi;
|
2013-08-22 22:51:34 +00:00
|
|
|
|
2002-09-17 18:51:22 +00:00
|
|
|
nsCOMPtr<nsIDOMWindow> newWindow;
|
|
|
|
rv = windowWatcher->OpenWindow(parent,
|
|
|
|
url,
|
|
|
|
"_blank",
|
2010-03-12 06:50:10 +00:00
|
|
|
modal
|
|
|
|
? kOpenDialogParam
|
|
|
|
: kOpenWindowParam,
|
2002-09-17 18:51:22 +00:00
|
|
|
params,
|
|
|
|
getter_AddRefs(newWindow));
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|