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 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | #include "nsFormSigningDialog.h" |
michael@0 | 6 | #include "nsNSSDialogHelper.h" |
michael@0 | 7 | #include "nsCOMPtr.h" |
michael@0 | 8 | #include "nsIDialogParamBlock.h" |
michael@0 | 9 | #include "nsIComponentManager.h" |
michael@0 | 10 | #include "nsIServiceManager.h" |
michael@0 | 11 | #include "nsIInterfaceRequestor.h" |
michael@0 | 12 | #include "nsIInterfaceRequestorUtils.h" |
michael@0 | 13 | #include "nsLiteralString.h" |
michael@0 | 14 | #include "nsXPIDLString.h" |
michael@0 | 15 | |
michael@0 | 16 | nsFormSigningDialog::nsFormSigningDialog() |
michael@0 | 17 | { |
michael@0 | 18 | } |
michael@0 | 19 | |
michael@0 | 20 | nsFormSigningDialog::~nsFormSigningDialog() |
michael@0 | 21 | { |
michael@0 | 22 | } |
michael@0 | 23 | |
michael@0 | 24 | NS_IMPL_ISUPPORTS(nsFormSigningDialog, nsIFormSigningDialog) |
michael@0 | 25 | |
michael@0 | 26 | NS_IMETHODIMP |
michael@0 | 27 | nsFormSigningDialog::ConfirmSignText(nsIInterfaceRequestor *aContext, |
michael@0 | 28 | const nsAString &aHost, |
michael@0 | 29 | const nsAString &aSignText, |
michael@0 | 30 | const char16_t **aCertNickList, |
michael@0 | 31 | const char16_t **aCertDetailsList, |
michael@0 | 32 | uint32_t aCount, int32_t *aSelectedIndex, |
michael@0 | 33 | nsAString &aPassword, bool *aCanceled) |
michael@0 | 34 | { |
michael@0 | 35 | *aCanceled = true; |
michael@0 | 36 | |
michael@0 | 37 | // Get the parent window for the dialog |
michael@0 | 38 | nsCOMPtr<nsIDOMWindow> parent = do_GetInterface(aContext); |
michael@0 | 39 | |
michael@0 | 40 | nsresult rv; |
michael@0 | 41 | nsCOMPtr<nsIDialogParamBlock> block = |
michael@0 | 42 | do_CreateInstance(NS_DIALOGPARAMBLOCK_CONTRACTID, &rv); |
michael@0 | 43 | NS_ENSURE_SUCCESS(rv, rv); |
michael@0 | 44 | |
michael@0 | 45 | block->SetNumberStrings(3 + aCount * 2); |
michael@0 | 46 | |
michael@0 | 47 | rv = block->SetString(0, PromiseFlatString(aHost).get()); |
michael@0 | 48 | NS_ENSURE_SUCCESS(rv, rv); |
michael@0 | 49 | |
michael@0 | 50 | rv = block->SetString(1, PromiseFlatString(aSignText).get()); |
michael@0 | 51 | NS_ENSURE_SUCCESS(rv, rv); |
michael@0 | 52 | |
michael@0 | 53 | uint32_t i; |
michael@0 | 54 | for (i = 0; i < aCount; ++i) { |
michael@0 | 55 | rv = block->SetString(2 + 2 * i, aCertNickList[i]); |
michael@0 | 56 | NS_ENSURE_SUCCESS(rv, rv); |
michael@0 | 57 | |
michael@0 | 58 | rv = block->SetString(2 + (2 * i + 1), aCertDetailsList[i]); |
michael@0 | 59 | NS_ENSURE_SUCCESS(rv, rv); |
michael@0 | 60 | } |
michael@0 | 61 | |
michael@0 | 62 | rv = block->SetInt(0, aCount); |
michael@0 | 63 | NS_ENSURE_SUCCESS(rv, rv); |
michael@0 | 64 | |
michael@0 | 65 | rv = nsNSSDialogHelper::openDialog(parent, |
michael@0 | 66 | "chrome://pippki/content/formsigning.xul", |
michael@0 | 67 | block); |
michael@0 | 68 | NS_ENSURE_SUCCESS(rv, rv); |
michael@0 | 69 | |
michael@0 | 70 | int32_t status; |
michael@0 | 71 | rv = block->GetInt(0, &status); |
michael@0 | 72 | NS_ENSURE_SUCCESS(rv, rv); |
michael@0 | 73 | |
michael@0 | 74 | if (status == 0) { |
michael@0 | 75 | *aCanceled = true; |
michael@0 | 76 | } |
michael@0 | 77 | else { |
michael@0 | 78 | *aCanceled = false; |
michael@0 | 79 | |
michael@0 | 80 | rv = block->GetInt(1, aSelectedIndex); |
michael@0 | 81 | NS_ENSURE_SUCCESS(rv, rv); |
michael@0 | 82 | |
michael@0 | 83 | nsXPIDLString pw; |
michael@0 | 84 | rv = block->GetString(0, getter_Copies(pw)); |
michael@0 | 85 | NS_ENSURE_SUCCESS(rv, rv); |
michael@0 | 86 | |
michael@0 | 87 | aPassword = pw; |
michael@0 | 88 | } |
michael@0 | 89 | |
michael@0 | 90 | return NS_OK; |
michael@0 | 91 | } |