security/manager/pki/src/nsNSSDialogHelper.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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/. */
     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"
    16 static const char kOpenDialogParam[] = "centerscreen,chrome,modal,titlebar";
    17 static const char kOpenWindowParam[] = "centerscreen,chrome,titlebar";
    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;
    31   nsCOMPtr<nsIDOMWindow> parent = window;
    33   if (!parent) {
    34     windowWatcher->GetActiveWindow(getter_AddRefs(parent));
    35   }
    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;
    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 }

mercurial