diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2004-11-18 03:39:38 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2004-11-18 03:39:38 +0800 |
commit | 0b0f98a2a486cfa4257b017446bbe93f7e352d1e (patch) | |
tree | 63a8ded1cb955b4280041fed263acf29d5f55d4f /embed | |
parent | 24619e355a9632293107bda10768b4b5bbc07e49 (diff) | |
download | gsoc2013-epiphany-0b0f98a2a486cfa4257b017446bbe93f7e352d1e.tar gsoc2013-epiphany-0b0f98a2a486cfa4257b017446bbe93f7e352d1e.tar.gz gsoc2013-epiphany-0b0f98a2a486cfa4257b017446bbe93f7e352d1e.tar.bz2 gsoc2013-epiphany-0b0f98a2a486cfa4257b017446bbe93f7e352d1e.tar.lz gsoc2013-epiphany-0b0f98a2a486cfa4257b017446bbe93f7e352d1e.tar.xz gsoc2013-epiphany-0b0f98a2a486cfa4257b017446bbe93f7e352d1e.tar.zst gsoc2013-epiphany-0b0f98a2a486cfa4257b017446bbe93f7e352d1e.zip |
Fix wrong certificate shown; Epiphany equivalent of galeon bug #158453.
2004-11-17 Christian Persch <chpe@cvs.gnome.org>
* embed/mozilla/EphyBrowser.cpp:
* embed/mozilla/EphyBrowser.h:
* embed/mozilla/mozilla-embed.cpp:
Fix wrong certificate shown; Epiphany equivalent of galeon bug #158453.
Diffstat (limited to 'embed')
-rw-r--r-- | embed/mozilla/EphyBrowser.cpp | 49 | ||||
-rw-r--r-- | embed/mozilla/EphyBrowser.h | 11 | ||||
-rw-r--r-- | embed/mozilla/mozilla-embed.cpp | 37 |
3 files changed, 42 insertions, 55 deletions
diff --git a/embed/mozilla/EphyBrowser.cpp b/embed/mozilla/EphyBrowser.cpp index de5def194..bcda45c9e 100644 --- a/embed/mozilla/EphyBrowser.cpp +++ b/embed/mozilla/EphyBrowser.cpp @@ -362,6 +362,16 @@ nsresult EphyBrowser::Init (GtkMozEmbed *mozembed) rv = GetListener(); NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE); +#ifdef HAVE_MOZILLA_PSM + /* FIXME: mozilla sucks! nsWebBrowser already has an instance of this, + * but we cannot get to it! + * See https://bugzilla.mozilla.org/show_bug.cgi?id=94974 + */ + mSecurityInfo = do_CreateInstance(NS_SECURE_BROWSER_UI_CONTRACTID, &rv); + NS_ENSURE_TRUE (NS_SUCCEEDED (rv) && mSecurityInfo, NS_ERROR_FAILURE); + mSecurityInfo->Init (mDOMWindow); +#endif + mInitialized = PR_TRUE; return AttachListeners(); @@ -1049,40 +1059,21 @@ nsresult EphyBrowser::GetHasModifiedForms (PRBool *modified) } nsresult -EphyBrowser::SetSecurityInfo (nsIRequest *aRequest) +EphyBrowser::GetSecurityInfo (PRUint32 *aState, nsACString &aDescription) { #ifdef HAVE_MOZILLA_PSM - /* clear previous security info */ - mSecurityInfo = nsnull; - - nsCOMPtr<nsIChannel> channel (do_QueryInterface (aRequest)); - NS_ENSURE_TRUE (channel, NS_ERROR_FAILURE); - - channel->GetSecurityInfo (getter_AddRefs (mSecurityInfo)); - - return NS_OK; -#else - return NS_ERROR_NOT_IMPLEMENTED; -#endif -} - -nsresult -EphyBrowser::GetSecurityDescription (nsACString &aDescription) -{ -#ifdef HAVE_MOZILLA_PSM - if (!mSecurityInfo) return NS_ERROR_FAILURE; - - nsCOMPtr<nsITransportSecurityInfo> tsInfo (do_QueryInterface (mSecurityInfo)); - NS_ENSURE_TRUE (tsInfo, NS_ERROR_FAILURE); + NS_ENSURE_TRUE (mSecurityInfo, NS_ERROR_FAILURE); nsresult rv; - PRUnichar *tooltip = nsnull; - rv = tsInfo->GetShortSecurityDescription (&tooltip); - NS_ENSURE_TRUE (NS_SUCCEEDED (rv) && tooltip, NS_ERROR_FAILURE); + rv = mSecurityInfo->GetState (aState); + NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE); + + nsEmbedString tooltip; + rv = mSecurityInfo->GetTooltipText (tooltip); + NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE); - NS_UTF16ToCString (nsEmbedString (tooltip), + NS_UTF16ToCString (tooltip, NS_CSTRING_ENCODING_UTF8, aDescription); - if (tooltip) nsMemory::Free (tooltip); return NS_OK; #else @@ -1094,7 +1085,7 @@ nsresult EphyBrowser::ShowCertificate () { #ifdef HAVE_MOZILLA_PSM - if (!mSecurityInfo) return NS_ERROR_FAILURE; + NS_ENSURE_TRUE (mSecurityInfo, NS_ERROR_FAILURE); nsCOMPtr<nsISSLStatusProvider> statusProvider (do_QueryInterface (mSecurityInfo)); NS_ENSURE_TRUE (statusProvider, NS_ERROR_FAILURE); diff --git a/embed/mozilla/EphyBrowser.h b/embed/mozilla/EphyBrowser.h index 76a5b6bfd..4a27ed106 100644 --- a/embed/mozilla/EphyBrowser.h +++ b/embed/mozilla/EphyBrowser.h @@ -39,7 +39,11 @@ #include <nsIRequest.h> #ifdef ALLOW_PRIVATE_API -#include "nsIContentViewer.h" +#include <nsIContentViewer.h> +#endif + +#ifdef HAVE_MOZILLA_PSM +#include <nsISecureBrowserUI.h> #endif class EphyEventListener : public nsIDOMEventListener @@ -134,8 +138,7 @@ public: nsresult GetHasModifiedForms (PRBool *modified); - nsresult SetSecurityInfo (nsIRequest *aRequest); - nsresult GetSecurityDescription (nsACString &aDescription); + nsresult GetSecurityInfo (PRUint32 *aState, nsACString &aDescription); nsresult ShowCertificate (); nsCOMPtr<nsIWebBrowser> mWebBrowser; @@ -144,7 +147,7 @@ private: nsCOMPtr<nsIDOMDocument> mTargetDocument; nsCOMPtr<nsIDOMEventTarget> mEventTarget; nsCOMPtr<nsIDOMWindow> mDOMWindow; - nsCOMPtr<nsISupports> mSecurityInfo; + nsCOMPtr<nsISecureBrowserUI> mSecurityInfo; EphyFaviconEventListener *mFaviconEventListener; EphyPopupBlockEventListener *mPopupBlockEventListener; EphyModalAlertEventListener *mModalAlertListener; diff --git a/embed/mozilla/mozilla-embed.cpp b/embed/mozilla/mozilla-embed.cpp index dcd07d816..fd71b5cb9 100644 --- a/embed/mozilla/mozilla-embed.cpp +++ b/embed/mozilla/mozilla-embed.cpp @@ -72,8 +72,9 @@ static void mozilla_embed_new_window_cb (GtkMozEmbed *embed, MozillaEmbed *membed); static void mozilla_embed_security_change_cb (GtkMozEmbed *embed, gpointer request, - guint state, MozillaEmbed *membed); -static EmbedSecurityLevel mozilla_embed_security_level (MozillaEmbed *membed); + PRUint32 state, + MozillaEmbed *membed); +static EmbedSecurityLevel mozilla_embed_security_level (PRUint32 state); #define MOZILLA_EMBED_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), MOZILLA_TYPE_EMBED, MozillaEmbedPrivate)) @@ -88,7 +89,6 @@ typedef enum struct MozillaEmbedPrivate { EphyBrowser *browser; - guint security_state; MozillaEmbedLoadState load_state; }; @@ -260,7 +260,6 @@ mozilla_embed_init (MozillaEmbed *embed) { embed->priv = MOZILLA_EMBED_GET_PRIVATE (embed); embed->priv->browser = new EphyBrowser (); - embed->priv->security_state = STATE_IS_UNKNOWN; g_signal_connect_object (G_OBJECT (embed), "location", G_CALLBACK (mozilla_embed_location_changed_cb), @@ -632,24 +631,23 @@ impl_shistory_go_nth (EphyEmbed *embed, } static void -impl_get_security_level (EphyEmbed *embed, +impl_get_security_level (EphyEmbed *embed, EmbedSecurityLevel *level, char **description) { MozillaEmbedPrivate *mpriv = MOZILLA_EMBED (embed)->priv; - g_return_if_fail (description != NULL && level != NULL); - - *description = NULL; - *level = STATE_IS_UNKNOWN; + if (level) *level = STATE_IS_UNKNOWN; + if (description) *description = NULL; nsresult rv; + PRUint32 state; nsEmbedCString desc; - rv = mpriv->browser->GetSecurityDescription (desc); + rv = mpriv->browser->GetSecurityInfo (&state, desc); if (NS_FAILED (rv)) return; - *description = g_strdup (desc.get()); - *level = mozilla_embed_security_level (MOZILLA_EMBED (embed)); + if (level) *level = mozilla_embed_security_level (state); + if (description) *description = g_strdup (desc.get()); } static void @@ -1083,24 +1081,19 @@ mozilla_embed_new_window_cb (GtkMozEmbed *embed, static void mozilla_embed_security_change_cb (GtkMozEmbed *embed, gpointer requestptr, - guint state, + PRUint32 state, MozillaEmbed *membed) { - EmbedSecurityLevel level; - - membed->priv->browser->SetSecurityInfo (static_cast<nsIRequest*>(requestptr)); - membed->priv->security_state = state; - level = mozilla_embed_security_level (membed); - - g_signal_emit_by_name (membed, "ge_security_change", level); + g_signal_emit_by_name (membed, "ge_security_change", + mozilla_embed_security_level (state)); } static EmbedSecurityLevel -mozilla_embed_security_level (MozillaEmbed *membed) +mozilla_embed_security_level (PRUint32 state) { EmbedSecurityLevel level; - switch (membed->priv->security_state) + switch (state) { case nsIWebProgressListener::STATE_IS_INSECURE: level = STATE_IS_INSECURE; |