bug 1217602 - remove nsIPKIParamBlock r=Cykesiopka

nsIPKIParamBlock was unnecessary.
This commit is contained in:
David Keeler 2015-10-22 13:11:40 -07:00
parent 6f0008b80e
commit bbc7c2c7a2
13 changed files with 59 additions and 222 deletions

View File

@ -8,7 +8,6 @@ DIRS += ['resources']
XPIDL_SOURCES += [
'nsIASN1Tree.idl',
'nsIPKIParamBlock.idl',
]
XPIDL_MODULE = 'pippki'
@ -18,7 +17,6 @@ UNIFIED_SOURCES += [
'nsNSSDialogHelper.cpp',
'nsNSSDialogs.cpp',
'nsPKIModule.cpp',
'nsPKIParamBlock.cpp',
]
GENERATED_INCLUDES += [

View File

@ -1,14 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
[scriptable, uuid(b6fe3d78-1dd1-11b2-9058-ced9016984c8)]
interface nsIPKIParamBlock : nsISupports {
void setISupportAtIndex(in long index, in nsISupports object);
nsISupports getISupportAtIndex(in long index);
};

View File

@ -5,23 +5,19 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsNSSDialogHelper.h"
#include "nsIWindowWatcher.h"
#include "nsCOMPtr.h"
#include "nsIComponentManager.h"
#include "nsIServiceManager.h"
#include "nsIInterfaceRequestor.h"
#include "nsIInterfaceRequestorUtils.h"
#include "mozilla/dom/ScriptSettings.h"
#include "nsCOMPtr.h"
#include "nsIDOMWindow.h"
#include "nsIServiceManager.h"
#include "nsIWindowWatcher.h"
static const char kOpenDialogParam[] = "centerscreen,chrome,modal,titlebar";
static const char kOpenWindowParam[] = "centerscreen,chrome,titlebar";
nsresult
nsNSSDialogHelper::openDialog(
nsIDOMWindow *window,
const char *url,
nsISupports *params,
bool modal)
nsNSSDialogHelper::openDialog(nsIDOMWindow* window, const char* url,
nsISupports* params, bool modal)
{
#ifdef MOZ_WIDGET_GONK
// On b2g devices, we need to proxy the dialog creation & management
@ -58,4 +54,3 @@ nsNSSDialogHelper::openDialog(
getter_AddRefs(newWindow));
return rv;
}

View File

@ -7,7 +7,8 @@
#ifndef nsNSSDialogHelper_h
#define nsNSSDialogHelper_h
#include "nsIDOMWindow.h"
class nsIDOMWindow;
class nsISupports;
/**
* Common class that uses the window watcher service to open a
@ -18,13 +19,9 @@
class nsNSSDialogHelper
{
public:
//The params is going to be either a nsIPKIParamBlock or
//nsIDialogParamBlock
static nsresult openDialog(
nsIDOMWindow *window,
const char *url,
nsISupports *params,
bool modal = true);
// params is a nsIDialogParamBlock or a nsIKeygenThread
static nsresult openDialog(nsIDOMWindow* window, const char* url,
nsISupports* params, bool modal = true);
};
#endif

View File

@ -25,7 +25,6 @@
#include "nsPromiseFlatString.h"
#include "nsNSSDialogs.h"
#include "nsPKIParamBlock.h"
#include "nsIKeygenThread.h"
#include "nsIProtectedAuthThread.h"
#include "nsNSSDialogHelper.h"
@ -111,30 +110,36 @@ nsNSSDialogs::ConfirmDownloadCACert(nsIInterfaceRequestor *ctx,
{
nsresult rv;
*_retval = true;
nsCOMPtr<nsIMutableArray> dlgArray(do_CreateInstance(NS_ARRAY_CONTRACTID));
if (!dlgArray) {
return NS_ERROR_FAILURE;
}
rv = dlgArray->AppendElement(cert, false);
if (NS_FAILED(rv)) {
return rv;
}
nsCOMPtr<nsIDialogParamBlock> dlgParamBlock(
do_CreateInstance(NS_DIALOGPARAMBLOCK_CONTRACTID));
if (!dlgParamBlock) {
return NS_ERROR_FAILURE;
}
rv = dlgParamBlock->SetObjects(dlgArray);
if (NS_FAILED(rv)) {
return rv;
}
// Get the parent window for the dialog
nsCOMPtr<nsIDOMWindow> parent = do_GetInterface(ctx);
nsCOMPtr<nsIPKIParamBlock> block =
do_CreateInstance(NS_PKIPARAMBLOCK_CONTRACTID);
if (!block)
return NS_ERROR_FAILURE;
rv = block->SetISupportAtIndex(1, cert);
if (NS_FAILED(rv))
return rv;
rv = nsNSSDialogHelper::openDialog(parent,
"chrome://pippki/content/downloadcert.xul",
block);
if (NS_FAILED(rv)) return rv;
dlgParamBlock);
if (NS_FAILED(rv)) {
return rv;
}
int32_t status;
int32_t ssl, email, objsign;
nsCOMPtr<nsIDialogParamBlock> dlgParamBlock = do_QueryInterface(block);
rv = dlgParamBlock->GetInt(1, &status);
if (NS_FAILED(rv)) return rv;
rv = dlgParamBlock->GetInt(2, &ssl);
@ -149,12 +154,11 @@ nsNSSDialogs::ConfirmDownloadCACert(nsIInterfaceRequestor *ctx,
*_trust |= (email) ? nsIX509CertDB::TRUSTED_EMAIL : 0;
*_trust |= (objsign) ? nsIX509CertDB::TRUSTED_OBJSIGN : 0;
*_retval = (status == 0)?false:true;
*_retval = (status != 0);
return rv;
}
NS_IMETHODIMP
nsNSSDialogs::NotifyCACertExists(nsIInterfaceRequestor *ctx)
{
@ -378,28 +382,32 @@ nsNSSDialogs::GetPKCS12FilePassword(nsIInterfaceRequestor* ctx,
}
NS_IMETHODIMP
nsNSSDialogs::ViewCert(nsIInterfaceRequestor *ctx,
nsIX509Cert *cert)
nsNSSDialogs::ViewCert(nsIInterfaceRequestor* ctx, nsIX509Cert* cert)
{
nsresult rv;
nsCOMPtr<nsIPKIParamBlock> block =
do_CreateInstance(NS_PKIPARAMBLOCK_CONTRACTID);
if (!block)
nsCOMPtr<nsIMutableArray> dlgArray(do_CreateInstance(NS_ARRAY_CONTRACTID));
if (!dlgArray) {
return NS_ERROR_FAILURE;
rv = block->SetISupportAtIndex(1, cert);
if (NS_FAILED(rv))
}
nsresult rv = dlgArray->AppendElement(cert, false);
if (NS_FAILED(rv)) {
return rv;
}
nsCOMPtr<nsIDialogParamBlock> dlgParamBlock(
do_CreateInstance(NS_DIALOGPARAMBLOCK_CONTRACTID));
if (!dlgParamBlock) {
return NS_ERROR_FAILURE;
}
rv = dlgParamBlock->SetObjects(dlgArray);
if (NS_FAILED(rv)) {
return rv;
}
// Get the parent window for the dialog
nsCOMPtr<nsIDOMWindow> parent = do_GetInterface(ctx);
rv = nsNSSDialogHelper::openDialog(parent,
"chrome://pippki/content/certViewer.xul",
block,
false);
return rv;
return nsNSSDialogHelper::openDialog(parent,
"chrome://pippki/content/certViewer.xul",
dlgParamBlock,
false);
}
NS_IMETHODIMP

View File

@ -7,22 +7,18 @@
#include "mozilla/ModuleUtils.h"
#include "nsNSSDialogs.h"
#include "nsPKIParamBlock.h"
#include "nsASN1Tree.h"
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsNSSDialogs, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPKIParamBlock, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsNSSASN1Tree)
NS_DEFINE_NAMED_CID(NS_NSSDIALOGS_CID);
NS_DEFINE_NAMED_CID(NS_NSSASN1OUTINER_CID);
NS_DEFINE_NAMED_CID(NS_PKIPARAMBLOCK_CID);
static const mozilla::Module::CIDEntry kPKICIDs[] = {
{ &kNS_NSSDIALOGS_CID, false, nullptr, nsNSSDialogsConstructor },
{ &kNS_NSSASN1OUTINER_CID, false, nullptr, nsNSSASN1TreeConstructor },
{ &kNS_PKIPARAMBLOCK_CID, false, nullptr, nsPKIParamBlockConstructor },
{ nullptr }
};
@ -34,7 +30,6 @@ static const mozilla::Module::ContractIDEntry kPKIContracts[] = {
{ NS_TOKENDIALOGS_CONTRACTID, &kNS_NSSDIALOGS_CID },
{ NS_GENERATINGKEYPAIRINFODIALOGS_CONTRACTID, &kNS_NSSDIALOGS_CID },
{ NS_ASN1TREE_CONTRACTID, &kNS_NSSASN1OUTINER_CID },
{ NS_PKIPARAMBLOCK_CONTRACTID, &kNS_PKIPARAMBLOCK_CID },
{ nullptr }
};

View File

@ -1,97 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsPKIParamBlock.h"
#include "nsIServiceManager.h"
#include "nsIDialogParamBlock.h"
#include "nsIMutableArray.h"
NS_IMPL_ISUPPORTS(nsPKIParamBlock, nsIPKIParamBlock, nsIDialogParamBlock)
nsPKIParamBlock::nsPKIParamBlock()
{
}
nsresult
nsPKIParamBlock::Init()
{
mDialogParamBlock = do_CreateInstance(NS_DIALOGPARAMBLOCK_CONTRACTID);
return !mDialogParamBlock ? NS_ERROR_OUT_OF_MEMORY : NS_OK;
}
nsPKIParamBlock::~nsPKIParamBlock()
{
}
NS_IMETHODIMP
nsPKIParamBlock::SetNumberStrings( int32_t inNumStrings )
{
return mDialogParamBlock->SetNumberStrings(inNumStrings);
}
NS_IMETHODIMP
nsPKIParamBlock::SetInt(int32_t inIndex, int32_t inInt)
{
return mDialogParamBlock->SetInt(inIndex, inInt);
}
NS_IMETHODIMP
nsPKIParamBlock::GetInt(int32_t inIndex, int32_t *outInt)
{
return mDialogParamBlock->GetInt(inIndex, outInt);
}
NS_IMETHODIMP
nsPKIParamBlock::GetString(int32_t inIndex, char16_t **_retval)
{
return mDialogParamBlock->GetString(inIndex, _retval);
}
NS_IMETHODIMP
nsPKIParamBlock::SetString(int32_t inIndex, const char16_t *inString)
{
return mDialogParamBlock->SetString(inIndex, inString);
}
NS_IMETHODIMP
nsPKIParamBlock::GetObjects(nsIMutableArray * *aObjects)
{
return mDialogParamBlock->GetObjects(aObjects);
}
NS_IMETHODIMP
nsPKIParamBlock::SetObjects(nsIMutableArray * aObjects)
{
return mDialogParamBlock->SetObjects(aObjects);
}
NS_IMETHODIMP
nsPKIParamBlock::SetISupportAtIndex(int32_t index, nsISupports *object)
{
if (!mSupports) {
mSupports = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID);
if (!mSupports) {
return NS_ERROR_OUT_OF_MEMORY;
}
}
// Ignore any InsertElementAt error, because this function always did that
mSupports->InsertElementAt(object, index-1);
return NS_OK;
}
NS_IMETHODIMP
nsPKIParamBlock::GetISupportAtIndex(int32_t index, nsISupports **_retval)
{
NS_ENSURE_ARG(_retval);
return mSupports->GetElementAt(index - 1, _retval);
}

View File

@ -1,36 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef _NSPKIPARAMBLOCK_
#define _NSPKIPARAMBLOCK_
#include "nsCOMPtr.h"
#include "nsIPKIParamBlock.h"
#include "nsIDialogParamBlock.h"
#include "nsISupportsArray.h"
#define NS_PKIPARAMBLOCK_CID \
{ 0x0bec75a8, 0x1dd2, 0x11b2, \
{ 0x86, 0x3a, 0xf6, 0x9f, 0x77, 0xc3, 0x13, 0x71 }}
#define NS_PKIPARAMBLOCK_CONTRACTID "@mozilla.org/security/pkiparamblock;1"
class nsPKIParamBlock : public nsIPKIParamBlock,
public nsIDialogParamBlock
{
public:
nsPKIParamBlock();
nsresult Init();
NS_DECL_NSIPKIPARAMBLOCK
NS_DECL_NSIDIALOGPARAMBLOCK
NS_DECL_THREADSAFE_ISUPPORTS
private:
virtual ~nsPKIParamBlock();
nsCOMPtr<nsIDialogParamBlock> mDialogParamBlock;
nsCOMPtr<nsISupportsArray> mSupports;
};
#endif //_NSPKIPARAMBLOCK_

View File

@ -11,8 +11,6 @@ const nsICertTree = Components.interfaces.nsICertTree;
const nsCertTree = "@mozilla.org/security/nsCertTree;1";
const nsIDialogParamBlock = Components.interfaces.nsIDialogParamBlock;
const nsDialogParamBlock = "@mozilla.org/embedcomp/dialogparam;1";
const nsIPKIParamBlock = Components.interfaces.nsIPKIParamBlock;
const nsPKIParamBlock = "@mozilla.org/security/pkiparamblock;1";
const gCertFileTypes = "*.p7b; *.crt; *.cert; *.cer; *.pem; *.der";

View File

@ -5,7 +5,6 @@
const nsIX509Cert = Components.interfaces.nsIX509Cert;
const nsX509CertDB = "@mozilla.org/security/x509certdb;1";
const nsIX509CertDB = Components.interfaces.nsIX509CertDB;
const nsIPKIParamBlock = Components.interfaces.nsIPKIParamBlock;
const nsIDialogParamBlock = Components.interfaces.nsIDialogParamBlock;
var certdb;

View File

@ -3,20 +3,16 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const nsIDialogParamBlock = Components.interfaces.nsIDialogParamBlock;
const nsIPKIParamBlock = Components.interfaces.nsIPKIParamBlock;
const nsIX509Cert = Components.interfaces.nsIX509Cert;
var pkiParams;
var params;
var caName;
var cert;
function onLoad()
{
pkiParams = window.arguments[0].QueryInterface(nsIPKIParamBlock);
params = pkiParams.QueryInterface(nsIDialogParamBlock);
var isupport = pkiParams.getISupportAtIndex(1);
cert = isupport.QueryInterface(nsIX509Cert);
params = window.arguments[0].QueryInterface(nsIDialogParamBlock);
cert = params.objects.queryElementAt(0, nsIX509Cert);
caName = cert.commonName;

View File

@ -5,7 +5,6 @@
const nsIX509Cert = Components.interfaces.nsIX509Cert;
const nsX509CertDB = "@mozilla.org/security/x509certdb;1";
const nsIX509CertDB = Components.interfaces.nsIX509CertDB;
const nsIPKIParamBlock = Components.interfaces.nsIPKIParamBlock;
var certdb;
var cert;

View File

@ -7,12 +7,12 @@ const nsX509CertDB = "@mozilla.org/security/x509certdb;1";
const nsIX509CertDB = Components.interfaces.nsIX509CertDB;
const nsPK11TokenDB = "@mozilla.org/security/pk11tokendb;1";
const nsIPK11TokenDB = Components.interfaces.nsIPK11TokenDB;
const nsIPKIParamBlock = Components.interfaces.nsIPKIParamBlock;
const nsIASN1Object = Components.interfaces.nsIASN1Object;
const nsIASN1Sequence = Components.interfaces.nsIASN1Sequence;
const nsIASN1PrintableItem = Components.interfaces.nsIASN1PrintableItem;
const nsIASN1Tree = Components.interfaces.nsIASN1Tree;
const nsASN1Tree = "@mozilla.org/security/nsASN1Tree;1"
const nsIDialogParamBlock = Components.interfaces.nsIDialogParamBlock;
var bundle;
@ -78,9 +78,8 @@ function setWindowName()
//var cert = certdb.findCertByNickname(token, myName);
cert = certdb.findCertByNickname(null, myName);
} else {
var pkiParams = window.arguments[0].QueryInterface(nsIPKIParamBlock);
var isupport = pkiParams.getISupportAtIndex(1);
cert = isupport.QueryInterface(nsIX509Cert);
var params = window.arguments[0].QueryInterface(nsIDialogParamBlock);
var cert = params.objects.queryElementAt(0, nsIX509Cert);
document.title = certDetails + '"' + cert.windowTitle + '"'; // XXX l10n?
}