From fc8b2f38ec97eaeb1090c5c4fa10318fa573a76d Mon Sep 17 00:00:00 2001 From: Christian Persch Date: Tue, 16 Nov 2004 14:21:23 +0000 Subject: Add a way to show the cert info dialogue for the page's certificate. 2004-11-16 Christian Persch * embed/ephy-embed.c: (ephy_embed_show_page_certificate): * embed/ephy-embed.h: * embed/mozilla/EphyBrowser.cpp: * embed/mozilla/EphyBrowser.h: * embed/mozilla/mozilla-embed.cpp: Add a way to show the cert info dialogue for the page's certificate. --- embed/mozilla/EphyBrowser.cpp | 36 ++++++++++++++++++++++++++++++++++++ embed/mozilla/EphyBrowser.h | 1 + embed/mozilla/mozilla-embed.cpp | 9 +++++++++ 3 files changed, 46 insertions(+) (limited to 'embed/mozilla') diff --git a/embed/mozilla/EphyBrowser.cpp b/embed/mozilla/EphyBrowser.cpp index 316034c2d..de5def194 100644 --- a/embed/mozilla/EphyBrowser.cpp +++ b/embed/mozilla/EphyBrowser.cpp @@ -63,6 +63,8 @@ #include "nsIDOMNode.h" #include "nsIDOMElement.h" #include "nsIDOMWindow2.h" +#include "nsIDOMDocumentView.h" +#include "nsIDOMAbstractView.h" #define MOZILLA_STRICT_API #include "nsEmbedString.h" #undef MOZILLA_STRICT_API @@ -70,6 +72,7 @@ #include "nsIChannel.h" #include "nsIScriptSecurityManager.h" #include "nsIServiceManager.h" +#include "nsIInterfaceRequestor.h" #ifdef ALLOW_PRIVATE_API /* not frozen yet */ @@ -80,6 +83,11 @@ #ifdef HAVE_MOZILLA_PSM /* not sure about this one: */ #include +/* these are in pipnss/, are they really private? */ +#include +#include +#include +#include #endif #endif @@ -1081,3 +1089,31 @@ EphyBrowser::GetSecurityDescription (nsACString &aDescription) return NS_ERROR_NOT_IMPLEMENTED; #endif } + +nsresult +EphyBrowser::ShowCertificate () +{ +#ifdef HAVE_MOZILLA_PSM + if (!mSecurityInfo) return NS_ERROR_FAILURE; + + nsCOMPtr statusProvider (do_QueryInterface (mSecurityInfo)); + NS_ENSURE_TRUE (statusProvider, NS_ERROR_FAILURE); + + nsCOMPtr SSLStatus; + statusProvider->GetSSLStatus (getter_AddRefs (SSLStatus)); + NS_ENSURE_TRUE (SSLStatus, NS_ERROR_FAILURE); + + nsCOMPtr serverCert; + SSLStatus->GetServerCert (getter_AddRefs (serverCert)); + NS_ENSURE_TRUE (serverCert, NS_ERROR_FAILURE); + + nsCOMPtr certDialogs (do_GetService (NS_CERTIFICATEDIALOGS_CONTRACTID)); + NS_ENSURE_TRUE (certDialogs, NS_ERROR_FAILURE); + + nsCOMPtr requestor(do_QueryInterface (mDOMWindow)); + + return certDialogs->ViewCert (requestor, serverCert); +#else + return NS_OK; +#endif +} diff --git a/embed/mozilla/EphyBrowser.h b/embed/mozilla/EphyBrowser.h index e2892797f..76a5b6bfd 100644 --- a/embed/mozilla/EphyBrowser.h +++ b/embed/mozilla/EphyBrowser.h @@ -136,6 +136,7 @@ public: nsresult SetSecurityInfo (nsIRequest *aRequest); nsresult GetSecurityDescription (nsACString &aDescription); + nsresult ShowCertificate (); nsCOMPtr mWebBrowser; diff --git a/embed/mozilla/mozilla-embed.cpp b/embed/mozilla/mozilla-embed.cpp index c00fc26ab..dcd07d816 100644 --- a/embed/mozilla/mozilla-embed.cpp +++ b/embed/mozilla/mozilla-embed.cpp @@ -652,6 +652,14 @@ impl_get_security_level (EphyEmbed *embed, *level = mozilla_embed_security_level (MOZILLA_EMBED (embed)); } +static void +impl_show_page_certificate (EphyEmbed *embed) +{ + MozillaEmbedPrivate *mpriv = MOZILLA_EMBED (embed)->priv; + + mpriv->browser->ShowCertificate (); +} + static void impl_print (EphyEmbed *embed) { @@ -1143,6 +1151,7 @@ ephy_embed_iface_init (EphyEmbedIface *iface) iface->shistory_get_pos = impl_shistory_get_pos; iface->shistory_go_nth = impl_shistory_go_nth; iface->get_security_level = impl_get_security_level; + iface->show_page_certificate = impl_show_page_certificate; iface->find_next = impl_find_next; iface->activate = impl_activate; iface->find_set_properties = impl_find_set_properties; -- cgit v1.2.3