зеркало из https://github.com/mozilla/pjs.git
Bug 385904, Actually hook up the new NSS error strings
r=rrelyea
This commit is contained in:
Родитель
c3775378ff
Коммит
4289efca97
|
@ -138,6 +138,7 @@ extern char * PR_CALLBACK
|
|||
pk11PasswordPrompt(PK11SlotInfo *slot, PRBool retry, void *arg);
|
||||
|
||||
#define PIPNSS_STRBUNDLE_URL "chrome://pipnss/locale/pipnss.properties"
|
||||
#define NSSERR_STRBUNDLE_URL "chrome://pipnss/locale/nsserrors.properties"
|
||||
|
||||
|
||||
static PLHashNumber PR_CALLBACK certHashtable_keyHash(const void *key)
|
||||
|
@ -545,6 +546,46 @@ nsNSSComponent::GetPIPNSSBundleString(const char *name,
|
|||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNSSComponent::NSSBundleFormatStringFromName(const char *name,
|
||||
const PRUnichar **params,
|
||||
PRUint32 numParams,
|
||||
nsAString &outString)
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
if (mNSSErrorsBundle && name) {
|
||||
nsXPIDLString result;
|
||||
rv = mNSSErrorsBundle->FormatStringFromName(NS_ConvertASCIItoUTF16(name).get(),
|
||||
params, numParams,
|
||||
getter_Copies(result));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
outString = result;
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNSSComponent::GetNSSBundleString(const char *name,
|
||||
nsAString &outString)
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
outString.SetLength(0);
|
||||
if (mNSSErrorsBundle && name) {
|
||||
nsXPIDLString result;
|
||||
rv = mNSSErrorsBundle->GetStringFromName(NS_ConvertASCIItoUTF16(name).get(),
|
||||
getter_Copies(result));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
outString = result;
|
||||
rv = NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNSSComponent::SkipOcsp()
|
||||
|
@ -858,6 +899,11 @@ nsNSSComponent::InitializePIPNSSBundle()
|
|||
if (!mPIPNSSBundle)
|
||||
rv = NS_ERROR_FAILURE;
|
||||
|
||||
bundleService->CreateBundle(NSSERR_STRBUNDLE_URL,
|
||||
getter_AddRefs(mNSSErrorsBundle));
|
||||
if (!mNSSErrorsBundle)
|
||||
rv = NS_ERROR_FAILURE;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -2177,18 +2223,21 @@ nsNSSComponent::GetErrorMessage(nsresult aXPCOMErrorCode, nsAString &aErrorMessa
|
|||
if (!IS_SEC_ERROR(aNSPRCode) && !IS_SSL_ERROR(aNSPRCode))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIStringBundle> theBundle = mPIPNSSBundle;
|
||||
const char *id_str = nsNSSErrors::getOverrideErrorStringName(aNSPRCode);
|
||||
|
||||
if (!id_str)
|
||||
if (!id_str) {
|
||||
id_str = nsNSSErrors::getDefaultErrorStringName(aNSPRCode);
|
||||
theBundle = mNSSErrorsBundle;
|
||||
}
|
||||
|
||||
if (!id_str || !mPIPNSSBundle)
|
||||
if (!id_str || !theBundle)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsAutoString msg;
|
||||
nsresult rv =
|
||||
mPIPNSSBundle->GetStringFromName(NS_ConvertASCIItoUTF16(id_str).get(),
|
||||
getter_Copies(msg));
|
||||
theBundle->GetStringFromName(NS_ConvertASCIItoUTF16(id_str).get(),
|
||||
getter_Copies(msg));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
aErrorMessage = msg;
|
||||
}
|
||||
|
|
|
@ -134,6 +134,13 @@ class NS_NO_VTABLE nsINSSComponent : public nsISupports {
|
|||
PRUint32 numParams,
|
||||
nsAString &outString) = 0;
|
||||
|
||||
NS_IMETHOD GetNSSBundleString(const char *name,
|
||||
nsAString &outString) = 0;
|
||||
NS_IMETHOD NSSBundleFormatStringFromName(const char *name,
|
||||
const PRUnichar **params,
|
||||
PRUint32 numParams,
|
||||
nsAString &outString) = 0;
|
||||
|
||||
// This method will just disable OCSP in NSS, it will not
|
||||
// alter the respective pref values.
|
||||
NS_IMETHOD SkipOcsp() = 0;
|
||||
|
@ -212,6 +219,12 @@ public:
|
|||
const PRUnichar **params,
|
||||
PRUint32 numParams,
|
||||
nsAString &outString);
|
||||
NS_IMETHOD GetNSSBundleString(const char *name,
|
||||
nsAString &outString);
|
||||
NS_IMETHOD NSSBundleFormatStringFromName(const char *name,
|
||||
const PRUnichar **params,
|
||||
PRUint32 numParams,
|
||||
nsAString &outString);
|
||||
NS_IMETHOD SkipOcsp();
|
||||
NS_IMETHOD SkipOcspOff();
|
||||
nsresult InitializeCRLUpdateTimer();
|
||||
|
@ -270,6 +283,7 @@ private:
|
|||
|
||||
nsCOMPtr<nsIScriptSecurityManager> mScriptSecurityManager;
|
||||
nsCOMPtr<nsIStringBundle> mPIPNSSBundle;
|
||||
nsCOMPtr<nsIStringBundle> mNSSErrorsBundle;
|
||||
nsCOMPtr<nsIURIContentListener> mPSMContentListener;
|
||||
nsCOMPtr<nsIPrefBranch> mPrefBranch;
|
||||
nsCOMPtr<nsITimer> mTimer;
|
||||
|
|
|
@ -348,13 +348,19 @@ nsNSSErrors::getErrorMessageFromCode(PRInt32 err,
|
|||
const char *nss_error_id_str = getDefaultErrorStringName(err);
|
||||
const char *id_str = getOverrideErrorStringName(err);
|
||||
|
||||
if (!id_str)
|
||||
id_str = nss_error_id_str;
|
||||
|
||||
if (id_str)
|
||||
if (id_str || nss_error_id_str)
|
||||
{
|
||||
nsString defMsg;
|
||||
nsresult rv = component->GetPIPNSSBundleString(id_str, defMsg);
|
||||
nsresult rv;
|
||||
if (id_str)
|
||||
{
|
||||
rv = component->GetPIPNSSBundleString(id_str, defMsg);
|
||||
}
|
||||
else
|
||||
{
|
||||
rv = component->GetNSSBundleString(nss_error_id_str, defMsg);
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
returnedMessage.Append(defMsg);
|
||||
|
|
Загрузка…
Ссылка в новой задаче