Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/security/manager/pki/nsNSSDialogHelper.cpp
Line
Count
Source (jump to first uncovered line)
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
9
#include "mozilla/dom/ScriptSettings.h"
10
#include "nsCOMPtr.h"
11
#include "nsIDOMWindow.h"
12
#include "nsIServiceManager.h"
13
#include "nsIWindowWatcher.h"
14
15
static const char kOpenDialogParam[] = "centerscreen,chrome,modal,titlebar";
16
static const char kOpenWindowParam[] = "centerscreen,chrome,titlebar";
17
18
nsresult
19
nsNSSDialogHelper::openDialog(mozIDOMWindowProxy* window, const char* url,
20
                              nsISupports* params, bool modal)
21
0
{
22
0
  nsresult rv;
23
0
  nsCOMPtr<nsIWindowWatcher> windowWatcher =
24
0
           do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv);
25
0
  if (NS_FAILED(rv)) return rv;
26
0
27
0
  nsCOMPtr<mozIDOMWindowProxy> parent = window;
28
0
29
0
  if (!parent) {
30
0
    windowWatcher->GetActiveWindow(getter_AddRefs(parent));
31
0
  }
32
0
33
0
  // We're loading XUL into this window, and it's happening on behalf of the
34
0
  // system, not on behalf of content. Make sure the initial about:blank window
35
0
  // gets a system principal, otherwise we'll bork when trying to wrap the
36
0
  // nsIKeyGenThread |arguments| property into the unprivileged scoope.
37
0
  MOZ_ASSERT(!strncmp("chrome://", url, strlen("chrome://")));
38
0
  mozilla::dom::AutoNoJSAPI nojsapi;
39
0
40
0
  nsCOMPtr<mozIDOMWindowProxy> newWindow;
41
0
  rv = windowWatcher->OpenWindow(parent,
42
0
                                 url,
43
0
                                 "_blank",
44
0
                                 modal
45
0
                                 ? kOpenDialogParam
46
0
                                 : kOpenWindowParam,
47
0
                                 params,
48
0
                                 getter_AddRefs(newWindow));
49
0
  return rv;
50
0
}