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