NS_IMETHODIMP nsNSSDialogs::NotifyCACertExists(nsIInterfaceRequestor *ctx) { nsresult rv; nsCOMPtr<nsIPromptService> promptSvc(do_GetService(NS_PROMPTSERVICE_CONTRACTID)); if (!promptSvc) return NS_ERROR_FAILURE; // Get the parent window for the dialog nsCOMPtr<nsIDOMWindow> parent = do_GetInterface(ctx); nsAutoString title; rv = mPIPStringBundle->GetStringFromName(MOZ_UTF16("caCertExistsTitle"), getter_Copies(title)); NS_ENSURE_SUCCESS(rv, rv); nsAutoString msg; rv = mPIPStringBundle->GetStringFromName(MOZ_UTF16("caCertExistsMessage"), getter_Copies(msg)); NS_ENSURE_SUCCESS(rv, rv); rv = promptSvc->Alert(parent, title.get(), msg.get()); return rv; }
NS_IMETHODIMP nsNSSDialogs::GetPKCS12FilePassword(nsIInterfaceRequestor* ctx, nsAString& _password, bool* _retval) { *_retval = false; nsCOMPtr<nsIPromptService> promptSvc( do_GetService(NS_PROMPTSERVICE_CONTRACTID)); if (!promptSvc) { return NS_ERROR_FAILURE; } nsAutoString msg; nsresult rv = mPIPStringBundle->GetStringFromName( MOZ_UTF16("getPKCS12FilePasswordMessage"), getter_Copies(msg)); if (NS_FAILED(rv)) { return rv; } // Get the parent window for the dialog nsCOMPtr<mozIDOMWindowProxy> parent = do_GetInterface(ctx); bool ignored = false; char16_t* pwTemp = nullptr; rv = promptSvc->PromptPassword(parent, nullptr, msg.get(), &pwTemp, nullptr, &ignored, _retval); if (NS_FAILED(rv)) { return rv; } if (*_retval) { _password.Assign(pwTemp); free(pwTemp); } return NS_OK; }