security/manager/pki/src/nsNSSDialogHelper.cpp

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:d35fa00bacd9
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7 #include "nsNSSDialogHelper.h"
8 #include "nsIWindowWatcher.h"
9 #include "nsCOMPtr.h"
10 #include "nsIComponentManager.h"
11 #include "nsIServiceManager.h"
12 #include "nsIInterfaceRequestor.h"
13 #include "nsIInterfaceRequestorUtils.h"
14 #include "mozilla/dom/ScriptSettings.h"
15
16 static const char kOpenDialogParam[] = "centerscreen,chrome,modal,titlebar";
17 static const char kOpenWindowParam[] = "centerscreen,chrome,titlebar";
18
19 nsresult
20 nsNSSDialogHelper::openDialog(
21 nsIDOMWindow *window,
22 const char *url,
23 nsISupports *params,
24 bool modal)
25 {
26 nsresult rv;
27 nsCOMPtr<nsIWindowWatcher> windowWatcher =
28 do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv);
29 if (NS_FAILED(rv)) return rv;
30
31 nsCOMPtr<nsIDOMWindow> parent = window;
32
33 if (!parent) {
34 windowWatcher->GetActiveWindow(getter_AddRefs(parent));
35 }
36
37 // We're loading XUL into this window, and it's happening on behalf of the
38 // system, not on behalf of content. Make sure the initial about:blank window
39 // gets a system principal, otherwise we'll bork when trying to wrap the
40 // nsIKeyGenThread |arguments| property into the unprivileged scoope.
41 MOZ_ASSERT(!strncmp("chrome://", url, strlen("chrome://")));
42 mozilla::dom::AutoNoJSAPI nojsapi;
43
44 nsCOMPtr<nsIDOMWindow> newWindow;
45 rv = windowWatcher->OpenWindow(parent,
46 url,
47 "_blank",
48 modal
49 ? kOpenDialogParam
50 : kOpenWindowParam,
51 params,
52 getter_AddRefs(newWindow));
53 return rv;
54 }
55

mercurial